17 #include <mrpt/otherlibs/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 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);
216 r *= float(1.0 / this->m_maxRange);
217 m_win_range[sensor_id]->showImage(
img);
222 if (++m_preview_decim_counter_rgb > m_preview_window_decimation)
224 m_preview_decim_counter_rgb = 0;
225 if (!m_win_int[sensor_id])
227 m_win_int[sensor_id] =
229 "Preview INTENSITY");
230 m_win_int[sensor_id]->setPos(330, 5 + 250 * sensor_id);
232 m_win_int[sensor_id]->showImage(
239 if (m_win_range[sensor_id]) m_win_range[sensor_id].reset();
240 if (m_win_int[sensor_id]) m_win_int[sensor_id].reset();
243 cout <<
"getNextObservation took " << 1000 * tictac.
Tac() <<
"ms\n";
250 #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"...
double DEG2RAD(const double x)
Degrees to radians.
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.
mrpt::math::CMatrixF rangeImages[NUM_SENSORS]
If hasRangeImage=true, a matrix of floats with the range data as captured by the camera (in meters) ...
This namespace contains representation of robot actions and observations.
GLsizei const GLchar ** string
#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.
GLdouble GLdouble GLdouble r
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)
This template class provides the basic functionality for a general 2D any-size, resizable container o...
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.