Main MRPT website > C++ reference for MRPT 1.5.5
List of all members | Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
mrpt::hwdrivers::COpenNI2Generic Class Reference

Detailed Description

An abstract class for accessing OpenNI2 compatible sensors.

This class permits to access several sensors simultaneously. The same options (resolution, fps, etc.) are used for every sensor.

More references to read:

Definition at line 28 of file COpenNI2Generic.h.

#include <mrpt/hwdrivers/COpenNI2Generic.h>

Inheritance diagram for mrpt::hwdrivers::COpenNI2Generic:
Inheritance graph

Classes

class  CDevice
 

Public Member Functions

 COpenNI2Generic ()
 Default ctor (width=640, height=480, fps=30) More...
 
 COpenNI2Generic (int width, int height, float fps=30.0f, bool open_streams_now=true)
 Ctor. More...
 
 ~COpenNI2Generic ()
 Default ctor. More...
 
void getNextFrameRGB (mrpt::utils::CImage &rgb_img, uint64_t &timestamp, bool &there_is_obs, bool &hardware_error, unsigned sensor_id=0)
 The main data retrieving function, to be called after calling loadConfig() and initialize(). More...
 
void getNextFrameD (mrpt::math::CMatrix &depth_img, uint64_t &timestamp, bool &there_is_obs, bool &hardware_error, unsigned sensor_id=0)
 The main data retrieving function, to be called after calling loadConfig() and initialize(). More...
 
void getNextFrameRGBD (mrpt::obs::CObservation3DRangeScan &out_obs, bool &there_is_obs, bool &hardware_error, unsigned sensor_id=0)
 The main data retrieving function, to be called after calling loadConfig() and initialize(). More...
 
void setVerbose (bool verbose)
 
bool isVerbose () const
 
bool getColorSensorParam (mrpt::utils::TCamera &param, unsigned sensor_id=0) const
 
bool getDepthSensorParam (mrpt::utils::TCamera &param, unsigned sensor_id=0) const
 
Open/Close device methods
void open (unsigned sensor_id=0)
 Try to open the camera (all the parameters [resolution,fps,...] must be set before calling this) - users may also call initialize(), which in turn calls this method. More...
 
unsigned int openDevicesBySerialNum (const std::set< unsigned > &vSerialRequired)
 Open a set of RGBD devices specified by their serial number. More...
 
unsigned int openDeviceBySerial (const unsigned int SerialRequired)
 Open a RGBD device specified by its serial number. More...
 
bool getDeviceIDFromSerialNum (const unsigned int SerialRequired, int &sensor_id) const
 Get the ID of the device corresponding to 'SerialRequired'. More...
 
bool start ()
 Open all sensor streams (normally called automatically at constructor, no need to call it manually). More...
 
void kill ()
 Kill the OpenNI2 driver. More...
 
bool isOpen (const unsigned sensor_id) const
 Whether there is a working connection to the sensor. More...
 
void close (unsigned sensor_id=0)
 Close the connection to the sensor (no need to call it manually unless desired for some reason, since it's called at destructor. More...
 
int getNumDevices () const
 The number of available devices at initialization. More...
 
int getConnectedDevices ()
 Get a list of the connected OpenNI2 sensors. More...
 

Protected Member Functions

void showLog (const std::string &message) const
 

Protected Attributes

class HWDRIVERS_IMPEXP CDevice
 The list of available devices. More...
 
std::vector< int > vSerialNums
 A vector with the serial numbers of the available devices. More...
 
int m_width
 The same options (width, height and fps) are set for all the sensors. More...
 
int m_height
 
float m_fps
 
int m_rgb_format
 
int m_depth_format
 
bool m_verbose
 
bool m_grab_image
 The data that the RGBD sensors can return. More...
 
bool m_grab_depth
 
bool m_grab_3D_points
 Default: all true. More...
 

Static Protected Attributes

static std::vector< stlplus::smart_ptr< CDevice > > vDevices = std::vector<stlplus::smart_ptr<COpenNI2Generic::CDevice> >()
 
static int numInstances = 0
 

Constructor & Destructor Documentation

◆ COpenNI2Generic() [1/2]

COpenNI2Generic::COpenNI2Generic ( )

Default ctor (width=640, height=480, fps=30)

Definition at line 53 of file COpenNI2Generic.cpp.

References mrpt::mrpt::format(), m_verbose, start(), and THROW_EXCEPTION.

◆ COpenNI2Generic() [2/2]

COpenNI2Generic::COpenNI2Generic ( int  width,
int  height,
float  fps = 30.0f,
bool  open_streams_now = true 
)

Ctor.

See also
start()

Definition at line 76 of file COpenNI2Generic.cpp.

References mrpt::mrpt::format(), m_verbose, start(), and THROW_EXCEPTION.

◆ ~COpenNI2Generic()

COpenNI2Generic::~COpenNI2Generic ( )

Default ctor.

Definition at line 121 of file COpenNI2Generic.cpp.

References kill(), and numInstances.

Member Function Documentation

◆ close()

void COpenNI2Generic::close ( unsigned  sensor_id = 0)

Close the connection to the sensor (no need to call it manually unless desired for some reason, since it's called at destructor.

Definition at line 323 of file COpenNI2Generic.cpp.

References getNumDevices(), MRPT_UNUSED_PARAM, THROW_EXCEPTION, and vDevices.

◆ getColorSensorParam()

bool COpenNI2Generic::getColorSensorParam ( mrpt::utils::TCamera param,
unsigned  sensor_id = 0 
) const

◆ getConnectedDevices()

int COpenNI2Generic::getConnectedDevices ( )

Get a list of the connected OpenNI2 sensors.

This method can or cannot be implemented in the derived class, depending on the need for it.

Exceptions
Thismethod must throw an exception with a descriptive message if some critical error is found.

Definition at line 150 of file COpenNI2Generic.cpp.

References mrpt::mrpt::format(), getNumDevices(), info, m_depth_format, m_rgb_format, m_verbose, showLog(), THROW_EXCEPTION, and vDevices.

◆ getDepthSensorParam()

bool COpenNI2Generic::getDepthSensorParam ( mrpt::utils::TCamera param,
unsigned  sensor_id = 0 
) const

◆ getDeviceIDFromSerialNum()

bool COpenNI2Generic::getDeviceIDFromSerialNum ( const unsigned int  SerialRequired,
int &  sensor_id 
) const

Get the ID of the device corresponding to 'SerialRequired'.

Definition at line 304 of file COpenNI2Generic.cpp.

References MRPT_UNUSED_PARAM, THROW_EXCEPTION, and vDevices.

◆ getNextFrameD()

void COpenNI2Generic::getNextFrameD ( mrpt::math::CMatrix depth_img,
uint64_t timestamp,
bool &  there_is_obs,
bool &  hardware_error,
unsigned  sensor_id = 0 
)

The main data retrieving function, to be called after calling loadConfig() and initialize().

Parameters
depth_imgThe output retrieved depth image (only if there_is_obs=true).
timestampThe timestamp of the capture (only if there_is_obs=true).
there_is_obsIf set to false, there was no new observation.
hardware_errorTrue on hardware/comms error.
sensor_idThe index of the sensor accessed.

Definition at line 383 of file COpenNI2Generic.cpp.

References mrpt::mrpt::format(), getNumDevices(), MRPT_UNUSED_PARAM, showLog(), THROW_EXCEPTION, and vDevices.

◆ getNextFrameRGB()

void COpenNI2Generic::getNextFrameRGB ( mrpt::utils::CImage rgb_img,
uint64_t timestamp,
bool &  there_is_obs,
bool &  hardware_error,
unsigned  sensor_id = 0 
)

The main data retrieving function, to be called after calling loadConfig() and initialize().

Parameters
out_imgThe output retrieved RGB image (only if there_is_obs=true).
timestampThe timestamp of the capture (only if there_is_obs=true).
there_is_obsIf set to false, there was no new observation.
hardware_errorTrue on hardware/comms error.
sensor_idThe index of the sensor accessed.
out_obsThe output retrieved observation (only if there_is_obs=true).
timestampThe timestamp of the capture (only if there_is_obs=true).
there_is_obsIf set to false, there was no new observation.
hardware_errorTrue on hardware/comms error.
sensor_idThe index of the sensor accessed.

Definition at line 348 of file COpenNI2Generic.cpp.

References mrpt::mrpt::format(), getNumDevices(), MRPT_UNUSED_PARAM, showLog(), THROW_EXCEPTION, and vDevices.

◆ getNextFrameRGBD()

void COpenNI2Generic::getNextFrameRGBD ( mrpt::obs::CObservation3DRangeScan out_obs,
bool &  there_is_obs,
bool &  hardware_error,
unsigned  sensor_id = 0 
)

The main data retrieving function, to be called after calling loadConfig() and initialize().

Parameters
out_obsThe output retrieved observation (only if there_is_obs=true).
there_is_obsIf set to false, there was no new observation.
hardware_errorTrue on hardware/comms error.
sensor_idThe index of the sensor accessed.
See also
doProcess
Parameters
out_obsThe output retrieved observation (only if there_is_obs=true).
there_is_obsIf set to false, there was no new observation.
hardware_errorTrue on hardware/comms error.
sensor_idThe index of the sensor accessed.

Definition at line 417 of file COpenNI2Generic.cpp.

References mrpt::mrpt::format(), getNumDevices(), MRPT_UNUSED_PARAM, showLog(), THROW_EXCEPTION, and vDevices.

◆ getNumDevices()

int COpenNI2Generic::getNumDevices ( ) const

The number of available devices at initialization.

Definition at line 129 of file COpenNI2Generic.cpp.

References vDevices.

Referenced by close(), getConnectedDevices(), getNextFrameD(), getNextFrameRGB(), getNextFrameRGBD(), isOpen(), and open().

◆ isOpen()

bool COpenNI2Generic::isOpen ( const unsigned  sensor_id) const

Whether there is a working connection to the sensor.

Definition at line 212 of file COpenNI2Generic.cpp.

References getNumDevices(), MRPT_UNUSED_PARAM, THROW_EXCEPTION, and vDevices.

Referenced by getColorSensorParam(), getDepthSensorParam(), open(), and openDevicesBySerialNum().

◆ isVerbose()

bool COpenNI2Generic::isVerbose ( ) const

Definition at line 137 of file COpenNI2Generic.cpp.

References m_verbose.

Referenced by showLog().

◆ kill()

void COpenNI2Generic::kill ( )

Kill the OpenNI2 driver.

See also
start()

Definition at line 202 of file COpenNI2Generic.cpp.

References THROW_EXCEPTION, and vDevices.

Referenced by ~COpenNI2Generic().

◆ open()

void COpenNI2Generic::open ( unsigned  sensor_id = 0)

Try to open the camera (all the parameters [resolution,fps,...] must be set before calling this) - users may also call initialize(), which in turn calls this method.

Raises an exception upon error.

Exceptions
std::exceptionA textual description of the error.

Definition at line 225 of file COpenNI2Generic.cpp.

References mrpt::mrpt::format(), getNumDevices(), isOpen(), m_fps, m_height, m_verbose, m_width, MRPT_UNUSED_PARAM, showLog(), mrpt::system::sleep(), THROW_EXCEPTION, and vDevices.

Referenced by openDevicesBySerialNum().

◆ openDeviceBySerial()

unsigned int COpenNI2Generic::openDeviceBySerial ( const unsigned int  SerialRequired)

Open a RGBD device specified by its serial number.

This method is a wrapper for openDevicesBySerialNum(const std::set<unsigned>& vSerialRequired) This method requires to open the sensors which are still closed to read their serial.

Definition at line 298 of file COpenNI2Generic.cpp.

References openDevicesBySerialNum().

◆ openDevicesBySerialNum()

unsigned int COpenNI2Generic::openDevicesBySerialNum ( const std::set< unsigned > &  vSerialRequired)

Open a set of RGBD devices specified by their serial number.

Raises an exception when the demanded serial numbers are not among the connected devices. This function also fills a vector with the serial numbers of the connected OpenNI2 sensors (this requires openning the sensors which are still closed to read their serial)

Definition at line 258 of file COpenNI2Generic.cpp.

References mrpt::mrpt::format(), isOpen(), m_fps, m_height, m_verbose, m_width, MRPT_UNUSED_PARAM, open(), showLog(), THROW_EXCEPTION, and vDevices.

Referenced by openDeviceBySerial().

◆ setVerbose()

void COpenNI2Generic::setVerbose ( bool  verbose)

Definition at line 133 of file COpenNI2Generic.cpp.

References m_verbose.

◆ showLog()

void COpenNI2Generic::showLog ( const std::string message) const
protected

◆ start()

bool COpenNI2Generic::start ( )

Open all sensor streams (normally called automatically at constructor, no need to call it manually).

Returns
false on error
See also
kill() to close

Definition at line 101 of file COpenNI2Generic.cpp.

References numInstances, and THROW_EXCEPTION.

Referenced by COpenNI2Generic().

Member Data Documentation

◆ CDevice

The list of available devices.

Definition at line 115 of file COpenNI2Generic.h.

◆ m_depth_format

int mrpt::hwdrivers::COpenNI2Generic::m_depth_format
protected

Definition at line 125 of file COpenNI2Generic.h.

Referenced by getConnectedDevices().

◆ m_fps

float mrpt::hwdrivers::COpenNI2Generic::m_fps
protected

Definition at line 124 of file COpenNI2Generic.h.

Referenced by open(), and openDevicesBySerialNum().

◆ m_grab_3D_points

bool mrpt::hwdrivers::COpenNI2Generic::m_grab_3D_points
protected

Default: all true.

Definition at line 129 of file COpenNI2Generic.h.

◆ m_grab_depth

bool mrpt::hwdrivers::COpenNI2Generic::m_grab_depth
protected

Definition at line 129 of file COpenNI2Generic.h.

◆ m_grab_image

bool mrpt::hwdrivers::COpenNI2Generic::m_grab_image
protected

The data that the RGBD sensors can return.

Definition at line 129 of file COpenNI2Generic.h.

◆ m_height

int mrpt::hwdrivers::COpenNI2Generic::m_height
protected

Definition at line 123 of file COpenNI2Generic.h.

Referenced by open(), and openDevicesBySerialNum().

◆ m_rgb_format

int mrpt::hwdrivers::COpenNI2Generic::m_rgb_format
protected

Definition at line 125 of file COpenNI2Generic.h.

Referenced by getConnectedDevices().

◆ m_verbose

bool mrpt::hwdrivers::COpenNI2Generic::m_verbose
protected

◆ m_width

int mrpt::hwdrivers::COpenNI2Generic::m_width
protected

The same options (width, height and fps) are set for all the sensors.

(This could be changed if necessary)

Definition at line 123 of file COpenNI2Generic.h.

Referenced by open(), and openDevicesBySerialNum().

◆ numInstances

int COpenNI2Generic::numInstances = 0
staticprotected

Definition at line 117 of file COpenNI2Generic.h.

Referenced by start(), and ~COpenNI2Generic().

◆ vDevices

std::vector< stlplus::smart_ptr< COpenNI2Generic::CDevice > > COpenNI2Generic::vDevices = std::vector<stlplus::smart_ptr<COpenNI2Generic::CDevice> >()
staticprotected

◆ vSerialNums

std::vector<int> mrpt::hwdrivers::COpenNI2Generic::vSerialNums
protected

A vector with the serial numbers of the available devices.

Definition at line 120 of file COpenNI2Generic.h.




Page generated by Doxygen 1.8.14 for MRPT 1.5.5 Git: e06b63dbf Fri Dec 1 14:41:11 2017 +0100 at lun oct 28 01:31:35 CET 2019