17 #include <mrpt/otherlibs/do_opencv_includes.h> 34 : m_sensorPoseOnRobot(),
35 m_preview_window(false),
36 m_preview_window_decimation(1),
37 m_preview_decim_counter_range(0),
38 m_preview_decim_counter_rgb(0),
42 m_grab_3D_points(true)
45 m_sensorLabel =
"RGBD360";
55 #endif // MRPT_HAS_OPENNI2 67 getConnectedDevices();
69 if (getNumDevices() < NUM_SENSORS)
71 cout <<
"Num required sensors " << NUM_SENSORS << endl;
72 cout <<
"Not enough devices connected -> EXIT\n";
75 cout <<
"COpenNI2_RGBD360 initializes correctly.\n";
77 for (
unsigned sensor_id = 0; sensor_id < (
unsigned int)NUM_SENSORS;
82 #endif // MRPT_HAS_OPENNI2 92 cout <<
"COpenNI2_RGBD360::doProcess...\n";
94 bool thereIs, hwError;
97 mrpt::make_aligned_shared<CObservationRGBD360>();
101 assert(getNumDevices() > 0);
103 getNextObservation(*newObs, thereIs, hwError);
115 std::vector<mrpt::utils::CSerializable::Ptr> objs;
116 if (m_grab_rgb || m_grab_depth || m_grab_3D_points)
117 objs.push_back(newObs);
119 appendObservations(objs);
123 #endif // MRPT_HAS_OPENNI2 136 cout <<
"COpenNI2_RGBD360::loadConfig_sensorSpecific...\n";
138 m_sensorPoseOnRobot.setFromValues(
139 configSource.
read_float(iniSection,
"pose_x", 0),
140 configSource.
read_float(iniSection,
"pose_y", 0),
141 configSource.
read_float(iniSection,
"pose_z", 0),
147 configSource.
read_bool(iniSection,
"preview_window", m_preview_window);
149 m_width = configSource.
read_int(iniSection,
"width", 0);
150 m_height = configSource.
read_int(iniSection,
"height", 0);
151 m_fps = configSource.
read_float(iniSection,
"fps", 0);
152 std::cout <<
"width " << m_width <<
" height " << m_height <<
" fps " 155 m_grab_rgb = configSource.
read_bool(iniSection,
"grab_image", m_grab_rgb);
157 configSource.
read_bool(iniSection,
"grab_depth", m_grab_depth);
159 configSource.
read_bool(iniSection,
"grab_3D_points", m_grab_3D_points);
180 there_is_obs =
false;
181 hardware_error =
false;
187 if (m_grab_depth || m_grab_3D_points) newObs.
hasRangeImage =
true;
191 for (
unsigned sensor_id = 0; sensor_id < (
unsigned int)NUM_SENSORS;
195 bool there_is_obs, hardware_error;
198 there_is_obs, hardware_error, sensor_id);
201 there_is_obs, hardware_error, sensor_id);
205 for (
unsigned sensor_id = 0; sensor_id < (
unsigned int)NUM_SENSORS;
208 if (m_preview_window)
212 if (++m_preview_decim_counter_range >
213 m_preview_window_decimation)
215 m_preview_decim_counter_range = 0;
216 if (!m_win_range[sensor_id])
220 m_win_range[sensor_id]->
setPos(5, 5 + 250 * sensor_id);
227 float(1.0 / this->m_maxRange);
228 m_win_range[sensor_id]->showImage(
img);
233 if (++m_preview_decim_counter_rgb > m_preview_window_decimation)
235 m_preview_decim_counter_rgb = 0;
236 if (!m_win_int[sensor_id])
240 m_win_int[sensor_id]->
setPos(330, 5 + 250 * sensor_id);
242 m_win_int[sensor_id]->showImage(
249 if (m_win_range[sensor_id]) m_win_range[sensor_id].reset();
250 if (m_win_int[sensor_id]) m_win_int[sensor_id].reset();
253 cout <<
"getNextObservation took " << 1000 * tictac.
Tac() <<
"ms\n";
260 #endif // MRPT_HAS_OPENNI2
std::shared_ptr< CObservationRGBD360 > Ptr
Declares a class derived from "CObservation" that encapsules an omnidirectional RGBD measurement from...
bool read_bool(const std::string §ion, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
mrpt::utils::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.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
float read_float(const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const
virtual void loadConfig_sensorSpecific(const mrpt::utils::CConfigFileBase &configSource, const std::string §ion)
Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes)
A class for storing images as grayscale or RGB bitmaps.
mrpt::system::TTimeStamp getCurrentTime()
Returns the current (UTC) system time.
~COpenNI2_RGBD360()
Default ctor.
#define THROW_EXCEPTION(msg)
Contains classes for various device interfaces.
mrpt::system::TTimeStamp timestamps[NUM_SENSORS]
virtual void doProcess()
To be called at a high rate (>XX Hz), this method populates the internal buffer of received observati...
void Tic()
Starts the stopwatch.
This class allows loading and storing values and vectors of different types from a configuration text...
A class for grabing RGBD images from several OpenNI2 sensors.
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
This base provides a set of functions for maths stuff.
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
virtual void setPathForExternalImages(const std::string &directory)
Set the path where to save off-rawlog image files (this class DOES take into account this path)...
This class implements a high-performance stopwatch.
This class creates a window as a graphical user interface (GUI) for displaying images to the user...
mrpt::math::CMatrix 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.
virtual void initialize()
Initializes the 3D camera - should be invoked after calling loadConfig() or setting the different par...
GLsizei const GLchar ** string
#define IMPLEMENTS_GENERIC_SENSOR(class_name, NameSpace)
This must be inserted in all CGenericSensor classes implementation files:
void setPos(int x, int y) override
Changes the position of the window on the screen.
bool hasIntensityImage
true means the field intensityImage contains valid data
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
GLdouble GLdouble GLdouble r
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().
double Tac()
Stops the stopwatch.
A matrix of dynamic size.
std::shared_ptr< T > make_aligned_shared(Args &&... args)
Creates a shared_ptr with 16-byte aligned memory.
bool hasRangeImage
true means the field rangeImage contains valid data