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::serialization::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
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.
~COpenNI2_RGBD360()
Default ctor.
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
virtual void doProcess()
To be called at a high rate (>XX Hz), this method populates the internal buffer of received observati...
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.
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 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 loadConfig_sensorSpecific(const mrpt::config::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 config::CConfigFileBase and derived classes)
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
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().
A matrix of dynamic size.
std::shared_ptr< T > make_aligned_shared(Args &&... args)
Creates a shared_ptr with aligned memory via aligned_allocator_cpp11<>.
void Tic() noexcept
Starts the stopwatch.
A class for storing images as grayscale or RGB bitmaps.
bool hasRangeImage
true means the field rangeImage contains valid data
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.