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);
   165     [[maybe_unused]] 
bool& there_is_obs, [[maybe_unused]] 
bool& hardware_error)
   172     there_is_obs = 
false;
   173     hardware_error = 
false;
   179     if (m_grab_depth || m_grab_3D_points) newObs.
hasRangeImage = 
true;
   183     for (
unsigned sensor_id = 0; sensor_id < (
unsigned int)NUM_SENSORS;
   188             there_is_obs, hardware_error, sensor_id);
   191             there_is_obs, hardware_error, sensor_id);
   195     for (
unsigned sensor_id = 0; sensor_id < (
unsigned int)NUM_SENSORS;
   198         if (m_preview_window)
   200             if (out_obs.hasRangeImage)
   202                 if (++m_preview_decim_counter_range >
   203                     m_preview_window_decimation)
   205                     m_preview_decim_counter_range = 0;
   206                     if (!m_win_range[sensor_id])
   208                         m_win_range[sensor_id] =
   210                         m_win_range[sensor_id]->setPos(5, 5 + 250 * sensor_id);
   215                     const Eigen::MatrixXf r =
   216                         out_obs.rangeImages[sensor_id].asEigen().cast<
float>() *
   217                         out_obs.rangeUnits * 
float(1.0 / this->m_maxRange);
   219                     m_win_range[sensor_id]->showImage(img);
   222             if (out_obs.hasIntensityImage)
   224                 if (++m_preview_decim_counter_rgb > m_preview_window_decimation)
   226                     m_preview_decim_counter_rgb = 0;
   227                     if (!m_win_int[sensor_id])
   229                         m_win_int[sensor_id] =
   231                                 "Preview INTENSITY");
   232                         m_win_int[sensor_id]->setPos(330, 5 + 250 * sensor_id);
   234                     m_win_int[sensor_id]->showImage(
   235                         out_obs.intensityImages[sensor_id]);
   241             if (m_win_range[sensor_id]) m_win_range[sensor_id].reset();
   242             if (m_win_int[sensor_id]) m_win_int[sensor_id].reset();
   245     cout << 
"getNextObservation took " << 1000 * tictac.
Tac() << 
"ms\n";
   248 #endif  // MRPT_HAS_OPENNI2   255     [maybe_unused]] 
const std::string& directory)
 
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...
 
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) 
 
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)...