17 #include <mrpt/3rdparty/do_opencv_includes.h>    37     m_sensorLabel = 
"RGBD360";
    47 #endif  // MRPT_HAS_OPENNI2    59     getConnectedDevices();
    61     if (getNumDevices() < NUM_SENSORS)
    63         cout << 
"Num required sensors " << NUM_SENSORS << endl;
    64         cout << 
"Not enough devices connected -> EXIT\n";
    67     cout << 
"COpenNI2_RGBD360 initializes correctly.\n";
    69     for (
unsigned sensor_id = 0; sensor_id < (
unsigned int)NUM_SENSORS;
    74 #endif  // MRPT_HAS_OPENNI2    84     cout << 
"COpenNI2_RGBD360::doProcess...\n";
    86     bool thereIs, hwError;
    92     assert(getNumDevices() > 0);
    94     getNextObservation(*newObs, thereIs, hwError);
   106         std::vector<mrpt::serialization::CSerializable::Ptr> objs;
   107         if (m_grab_rgb || m_grab_depth || m_grab_3D_points)
   108             objs.push_back(newObs);
   110         appendObservations(objs);
   114 #endif  // MRPT_HAS_OPENNI2   125     const std::string& iniSection)
   127     cout << 
"COpenNI2_RGBD360::loadConfig_sensorSpecific...\n";
   129     m_sensorPoseOnRobot.setFromValues(
   130         configSource.
read_float(iniSection, 
"pose_x", 0),
   131         configSource.
read_float(iniSection, 
"pose_y", 0),
   132         configSource.
read_float(iniSection, 
"pose_z", 0),
   138         configSource.
read_bool(iniSection, 
"preview_window", m_preview_window);
   140     m_width = configSource.
read_int(iniSection, 
"width", 0);
   141     m_height = configSource.
read_int(iniSection, 
"height", 0);
   142     m_fps = configSource.
read_float(iniSection, 
"fps", 0);
   143     std::cout << 
"width " << m_width << 
" height " << m_height << 
" fps "   146     m_grab_rgb = configSource.
read_bool(iniSection, 
"grab_image", m_grab_rgb);
   148         configSource.
read_bool(iniSection, 
"grab_depth", m_grab_depth);
   150         configSource.
read_bool(iniSection, 
"grab_3D_points", m_grab_3D_points);
   171     there_is_obs = 
false;
   172     hardware_error = 
false;
   178     if (m_grab_depth || m_grab_3D_points) newObs.
hasRangeImage = 
true;
   182     for (
unsigned sensor_id = 0; sensor_id < (
unsigned int)NUM_SENSORS;
   187             there_is_obs, hardware_error, sensor_id);
   190             there_is_obs, hardware_error, sensor_id);
   194     for (
unsigned sensor_id = 0; sensor_id < (
unsigned int)NUM_SENSORS;
   197         if (m_preview_window)
   201                 if (++m_preview_decim_counter_range >
   202                     m_preview_window_decimation)
   204                     m_preview_decim_counter_range = 0;
   205                     if (!m_win_range[sensor_id])
   207                         m_win_range[sensor_id] =
   209                         m_win_range[sensor_id]->setPos(5, 5 + 250 * sensor_id);
   214                     const Eigen::MatrixXf r =
   216                         out_obs.
rangeUnits * 
float(1.0 / this->m_maxRange);
   218                     m_win_range[sensor_id]->showImage(img);
   223                 if (++m_preview_decim_counter_rgb > m_preview_window_decimation)
   225                     m_preview_decim_counter_rgb = 0;
   226                     if (!m_win_int[sensor_id])
   228                         m_win_int[sensor_id] =
   230                                 "Preview INTENSITY");
   231                         m_win_int[sensor_id]->setPos(330, 5 + 250 * sensor_id);
   233                     m_win_int[sensor_id]->showImage(
   240             if (m_win_range[sensor_id]) m_win_range[sensor_id].reset();
   241             if (m_win_int[sensor_id]) m_win_int[sensor_id].reset();
   244     cout << 
"getNextObservation took " << 1000 * tictac.
Tac() << 
"ms\n";
   251 #endif  // MRPT_HAS_OPENNI2 
double Tac() noexcept
Stops the stopwatch. 
 
Declares a class derived from "CObservation" that encapsules an omnidirectional RGBD measurement from...
 
#define THROW_EXCEPTION(msg)
 
mrpt::system::TTimeStamp getCurrentTime()
Returns the current (UTC) system time. 
 
mrpt::img::CImage intensityImages[NUM_SENSORS]
If hasIntensityImage=true, a color or gray-level intensity image of the same size than "rangeImage"...
 
A high-performance stopwatch, with typical resolution of nanoseconds. 
 
Contains classes for various device interfaces. 
 
mrpt::system::TTimeStamp timestamps[NUM_SENSORS]
 
float read_float(const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const
 
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
 
mrpt::system::CTicTac CTicTac
 
A class for grabing RGBD images from several OpenNI2 sensors. 
 
This class allows loading and storing values and vectors of different types from a configuration text...
 
This base provides a set of functions for maths stuff. 
 
constexpr double DEG2RAD(const double x)
Degrees to radians. 
 
This namespace contains representation of robot actions and observations. 
 
mrpt::math::CMatrix_u16 rangeImages[NUM_SENSORS]
If hasRangeImage=true, a matrix of floats with the range data as captured by the camera (in meters) ...
 
void setFromMatrix(const MAT &m, bool matrix_is_normalized=true)
Set the image from a matrix, interpreted as grayscale intensity values, in the range [0...
 
#define IMPLEMENTS_GENERIC_SENSOR(class_name, NameSpace)
This must be inserted in all CGenericSensor classes implementation files: 
 
bool hasIntensityImage
true means the field intensityImage contains valid data 
 
~COpenNI2_RGBD360() override
Default ctor. 
 
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp. 
 
bool read_bool(const std::string §ion, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
 
void getNextObservation(mrpt::obs::CObservationRGBD360 &out_obs, bool &there_is_obs, bool &hardware_error)
The main data retrieving function, to be called after calling loadConfig() and initialize(). 
 
void initialize() override
Initializes the 3D camera - should be invoked after calling loadConfig() or setting the different par...
 
float rangeUnits
Units for integer depth values in rangeImages. 
 
static CDisplayWindow::Ptr Create(const std::string &windowCaption, unsigned int initWidth=400, unsigned int initHeight=400)
Class factory returning a smart pointer. 
 
void Tic() noexcept
Starts the stopwatch. 
 
void loadConfig_sensorSpecific(const mrpt::config::CConfigFileBase &configSource, const std::string §ion) override
Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see config::CConfigFileBase and derived classes) 
 
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object. 
 
void doProcess() override
To be called at a high rate (>XX Hz), this method populates the internal buffer of received observati...
 
A class for storing images as grayscale or RGB bitmaps. 
 
bool hasRangeImage
true means the field rangeImage contains valid data 
 
void setPathForExternalImages(const std::string &directory) override
Set the path where to save off-rawlog image files (this class DOES take into account this path)...
 
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.