Main MRPT website > C++ reference for MRPT 1.9.9
COpenNI2Generic.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef mrpt_COpenNI2Generic_H
10 #define mrpt_COpenNI2Generic_H
11 
13 
14 namespace mrpt
15 {
16 namespace hwdrivers
17 {
18 /** An abstract class for accessing OpenNI2 compatible sensors.
19  * This class permits to access several sensors simultaneously. The same
20  *options (resolution, fps, etc.) are used for every sensor.
21  *
22  * More references to read:
23  * - http://http://www.openni.org/
24  * \ingroup mrpt_hwdrivers_grp
25  */
27 {
28  public:
29  /** Default ctor (width=640, height=480, fps=30)
30  */
32  /** Ctor. \sa start()
33  */
35  int width, int height, float fps = 30.0f, bool open_streams_now = true);
36 
37  /** Default ctor
38  */
40 
41  /**Get the number of OpenNI2 cameras currently open via COpenNI2Generic*/
42  static int getNumInstances();
43 
44  /** The main data retrieving function, to be called after calling
45  * loadConfig() and initialize().
46  * \param out_img The output retrieved RGB image (only if
47  * there_is_obs=true).
48  * \param timestamp The timestamp of the capture (only if
49  * there_is_obs=true).
50  * \param there_is_obs If set to false, there was no new observation.
51  * \param hardware_error True on hardware/comms error.
52  * \param sensor_id The index of the sensor accessed. */
53  void getNextFrameRGB(
54  mrpt::img::CImage& rgb_img, uint64_t& timestamp, bool& there_is_obs,
55  bool& hardware_error, unsigned sensor_id = 0);
56 
57  /** The main data retrieving function, to be called after calling
58  * loadConfig() and initialize().
59  * \param depth_img The output retrieved depth image (only if
60  * there_is_obs=true).
61  * \param timestamp The timestamp of the capture (only if
62  * there_is_obs=true).
63  * \param there_is_obs If set to false, there was no new observation.
64  * \param hardware_error True on hardware/comms error.
65  * \param sensor_id The index of the sensor accessed. */
66  void getNextFrameD(
67  mrpt::math::CMatrix& depth_img, uint64_t& timestamp, bool& there_is_obs,
68  bool& hardware_error, unsigned sensor_id = 0);
69 
70  /** The main data retrieving function, to be called after calling
71  * loadConfig() and initialize().
72  * \param out_obs The output retrieved observation (only if
73  * there_is_obs=true).
74  * \param there_is_obs If set to false, there was no new observation.
75  * \param hardware_error True on hardware/comms error.
76  * \param sensor_id The index of the sensor accessed.
77  *
78  * \sa doProcess
79  */
80  void getNextFrameRGBD(
81  mrpt::obs::CObservation3DRangeScan& out_obs, bool& there_is_obs,
82  bool& hardware_error, unsigned sensor_id = 0);
83 
84  /** @name Open/Close device methods
85  @{ */
86  /** Try to open the camera (all the parameters [resolution,fps,...] must be
87  * set before calling this) - users may also call initialize(), which in
88  * turn calls this method.
89  * Raises an exception upon error.
90  * \exception std::exception A textual description of the error.
91  */
92  void open(unsigned sensor_id = 0);
93 
94  /** Open a set of RGBD devices specified by their serial number. Raises an
95  * exception when the demanded serial numbers
96  * are not among the connected devices. This function also fills a vector
97  * with the serial numbers of the connected
98  * OpenNI2 sensors (this requires openning the sensors which are still
99  * closed to read their serial)
100  */
101  unsigned int openDevicesBySerialNum(
102  const std::set<unsigned>& vSerialRequired);
103 
104  /** Open a RGBD device specified by its serial number. This method is a
105  * wrapper for
106  * openDevicesBySerialNum(const std::set<unsigned>& vSerialRequired)
107  * This method requires to open the sensors which are still closed to read
108  * their serial.
109  */
110  unsigned int openDeviceBySerial(const unsigned int SerialRequired);
111 
112  /** Get the ID of the device corresponding to 'SerialRequired'.
113  */
115  const unsigned int SerialRequired, int& sensor_id) const;
116  /** Open all sensor streams (normally called automatically at constructor,
117  * no need to call it manually). \return false on error \sa kill() to close
118  */
119  bool start();
120  /** Kill the OpenNI2 driver \sa start()
121  */
122  void kill();
123  /** Whether there is a working connection to the sensor
124  */
125  bool isOpen(const unsigned sensor_id) const;
126  /** Close the connection to the sensor (no need to call it manually unless
127  * desired for some reason, since it's called at destructor
128  */
129  void close(unsigned sensor_id = 0);
130  /** The number of available devices at initialization
131  */
132  int getNumDevices() const;
133  /** Get a list of the connected OpenNI2 sensors.
134  */
135  int getConnectedDevices();
136 
137  /** @} */
138 
139  void setVerbose(bool verbose);
140  bool isVerbose() const;
141 
142  bool getColorSensorParam(
143  mrpt::img::TCamera& param, unsigned sensor_id = 0) const;
144  bool getDepthSensorParam(
145  mrpt::img::TCamera& param, unsigned sensor_id = 0) const;
146 
147  class CDevice;
148 
149  protected:
150  /** A vector with the serial numbers of the available devices */
151  std::vector<int> vSerialNums;
152 
153  /** The same options (width, height and fps) are set for all the sensors.
154  * (This could be changed if necessary) */
156  float m_fps;
158  bool m_verbose;
159  void showLog(const std::string& message) const;
160  /** The data that the RGBD sensors can return */
161  /** Default: all true
162  */
164 }; // End of class
165 } // namespace hwdrivers
166 } // namespace mrpt
167 #endif
mrpt::hwdrivers::COpenNI2Generic::getNumDevices
int getNumDevices() const
The number of available devices at initialization.
Definition: COpenNI2Generic.cpp:155
mrpt::hwdrivers::COpenNI2Generic::getDepthSensorParam
bool getDepthSensorParam(mrpt::img::TCamera &param, unsigned sensor_id=0) const
Definition: COpenNI2Generic.cpp:566
mrpt::hwdrivers::COpenNI2Generic::m_grab_image
bool m_grab_image
The data that the RGBD sensors can return.
Definition: COpenNI2Generic.h:163
mrpt::hwdrivers::COpenNI2Generic::getNextFrameRGB
void getNextFrameRGB(mrpt::img::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().
Definition: COpenNI2Generic.cpp:436
mrpt::hwdrivers::COpenNI2Generic::setVerbose
void setVerbose(bool verbose)
Definition: COpenNI2Generic.cpp:160
mrpt::hwdrivers::COpenNI2Generic::COpenNI2Generic
COpenNI2Generic()
Default ctor (width=640, height=480, fps=30)
Definition: COpenNI2Generic.cpp:63
mrpt::hwdrivers::COpenNI2Generic::m_verbose
bool m_verbose
Definition: COpenNI2Generic.h:158
mrpt::hwdrivers::COpenNI2Generic::m_depth_format
int m_depth_format
Definition: COpenNI2Generic.h:157
mrpt::hwdrivers::COpenNI2Generic::getNextFrameRGBD
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().
Definition: COpenNI2Generic.cpp:518
mrpt::hwdrivers::COpenNI2Generic
An abstract class for accessing OpenNI2 compatible sensors.
Definition: COpenNI2Generic.h:26
mrpt::hwdrivers::COpenNI2Generic::m_width
int m_width
The same options (width, height and fps) are set for all the sensors.
Definition: COpenNI2Generic.h:155
CObservation3DRangeScan.h
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::hwdrivers::COpenNI2Generic::start
bool start()
Open all sensor streams (normally called automatically at constructor, no need to call it manually).
Definition: COpenNI2Generic.cpp:121
mrpt::hwdrivers::COpenNI2Generic::kill
void kill()
Kill the OpenNI2 driver.
Definition: COpenNI2Generic.cpp:245
mrpt::hwdrivers::COpenNI2Generic::isOpen
bool isOpen(const unsigned sensor_id) const
Whether there is a working connection to the sensor.
Definition: COpenNI2Generic.cpp:256
mrpt::hwdrivers::COpenNI2Generic::openDeviceBySerial
unsigned int openDeviceBySerial(const unsigned int SerialRequired)
Open a RGBD device specified by its serial number.
Definition: COpenNI2Generic.cpp:372
mrpt::hwdrivers::COpenNI2Generic::getNumInstances
static int getNumInstances()
Get the number of OpenNI2 cameras currently open via COpenNI2Generic.
Definition: COpenNI2Generic.cpp:55
mrpt::hwdrivers::COpenNI2Generic::close
void close(unsigned sensor_id=0)
Close the connection to the sensor (no need to call it manually unless desired for some reason,...
Definition: COpenNI2Generic.cpp:406
mrpt::hwdrivers::COpenNI2Generic::getColorSensorParam
bool getColorSensorParam(mrpt::img::TCamera &param, unsigned sensor_id=0) const
Definition: COpenNI2Generic.cpp:549
mrpt::hwdrivers::COpenNI2Generic::vSerialNums
std::vector< int > vSerialNums
A vector with the serial numbers of the available devices.
Definition: COpenNI2Generic.h:147
mrpt::math::CMatrix
This class is a "CSerializable" wrapper for "CMatrixFloat".
Definition: CMatrix.h:24
mrpt::obs::CObservation3DRangeScan
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement,...
Definition: CObservation3DRangeScan.h:224
uint64_t
unsigned __int64 uint64_t
Definition: rptypes.h:50
mrpt::img::TCamera
Structure to hold the parameters of a pinhole camera model.
Definition: TCamera.h:29
mrpt::hwdrivers::COpenNI2Generic::m_fps
float m_fps
Definition: COpenNI2Generic.h:156
mrpt::hwdrivers::COpenNI2Generic::getNextFrameD
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().
Definition: COpenNI2Generic.cpp:478
mrpt::hwdrivers::COpenNI2Generic::openDevicesBySerialNum
unsigned int openDevicesBySerialNum(const std::set< unsigned > &vSerialRequired)
Open a set of RGBD devices specified by their serial number.
Definition: COpenNI2Generic.cpp:316
height
GLenum GLsizei GLsizei height
Definition: glext.h:3554
mrpt::img::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130
mrpt::hwdrivers::COpenNI2Generic::m_height
int m_height
Definition: COpenNI2Generic.h:155
mrpt::hwdrivers::COpenNI2Generic::CDevice
Definition: COpenNI2Generic_CDevice.h:18
mrpt::hwdrivers::COpenNI2Generic::getConnectedDevices
int getConnectedDevices()
Get a list of the connected OpenNI2 sensors.
Definition: COpenNI2Generic.cpp:175
mrpt::hwdrivers::COpenNI2Generic::isVerbose
bool isVerbose() const
Definition: COpenNI2Generic.cpp:161
mrpt::hwdrivers::COpenNI2Generic::getDeviceIDFromSerialNum
bool getDeviceIDFromSerialNum(const unsigned int SerialRequired, int &sensor_id) const
Get the ID of the device corresponding to 'SerialRequired'.
Definition: COpenNI2Generic.cpp:380
width
GLenum GLsizei width
Definition: glext.h:3531
mrpt::hwdrivers::COpenNI2Generic::m_grab_3D_points
bool m_grab_3D_points
Definition: COpenNI2Generic.h:163
mrpt::hwdrivers::COpenNI2Generic::m_grab_depth
bool m_grab_depth
Definition: COpenNI2Generic.h:163
mrpt::hwdrivers::COpenNI2Generic::m_rgb_format
int m_rgb_format
Definition: COpenNI2Generic.h:157
mrpt::hwdrivers::COpenNI2Generic::open
void open(unsigned sensor_id=0)
Try to open the camera (all the parameters [resolution,fps,...] must be set before calling this) - us...
Definition: COpenNI2Generic.cpp:271
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::hwdrivers::COpenNI2Generic::showLog
void showLog(const std::string &message) const
Definition: COpenNI2Generic.cpp:162
mrpt::hwdrivers::COpenNI2Generic::~COpenNI2Generic
~COpenNI2Generic()
Default ctor.
Definition: COpenNI2Generic.cpp:146
param
GLfloat param
Definition: glext.h:3831



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST