18 #include <mrpt/otherlibs/do_opencv_includes.h> 36 m_sensorPoseOnRobot(),
37 m_preview_window(false),
38 m_preview_window_decimation(1),
39 m_preview_decim_counter_range(0),
40 m_preview_decim_counter_rgb(0),
44 m_grab_3D_points(true)
48 m_sensorLabel =
"RGBD360";
59 #endif // MRPT_HAS_OPENNI2 69 getConnectedDevices();
71 if(getNumDevices() < NUM_SENSORS)
73 cout <<
"Num required sensors " << NUM_SENSORS << endl;
74 cout <<
"Not enough devices connected -> EXIT\n";
77 cout <<
"COpenNI2_RGBD360 initializes correctly.\n";
79 for(
unsigned sensor_id=0; sensor_id < (
unsigned int)NUM_SENSORS; sensor_id++)
83 #endif // MRPT_HAS_OPENNI2 92 cout <<
"COpenNI2_RGBD360::doProcess...\n";
94 bool thereIs, hwError;
96 CObservationRGBD360Ptr newObs = CObservationRGBD360::Create();
99 assert(getNumDevices() > 0);
101 getNextObservation( *newObs, thereIs, hwError );
113 std::vector<mrpt::utils::CSerializablePtr> objs;
114 if (m_grab_rgb || m_grab_depth || m_grab_3D_points) objs.push_back(newObs);
116 appendObservations( objs );
120 #endif // MRPT_HAS_OPENNI2 130 cout <<
"COpenNI2_RGBD360::loadConfig_sensorSpecific...\n";
132 m_sensorPoseOnRobot.setFromValues(
133 configSource.
read_float(iniSection,
"pose_x",0),
134 configSource.
read_float(iniSection,
"pose_y",0),
135 configSource.
read_float(iniSection,
"pose_z",0),
141 m_preview_window = configSource.
read_bool(iniSection,
"preview_window",m_preview_window);
143 m_width = configSource.
read_int(iniSection,
"width",0);
144 m_height = configSource.
read_int(iniSection,
"height",0);
145 m_fps = configSource.
read_float(iniSection,
"fps",0);
146 std::cout <<
"width " << m_width <<
" height " << m_height <<
" fps " << m_fps << endl;
148 m_grab_rgb = configSource.
read_bool(iniSection,
"grab_image",m_grab_rgb);
149 m_grab_depth = configSource.
read_bool(iniSection,
"grab_depth",m_grab_depth);
150 m_grab_3D_points = configSource.
read_bool(iniSection,
"grab_3D_points",m_grab_3D_points);
166 bool &hardware_error )
174 hardware_error =
false;
181 if (m_grab_depth || m_grab_3D_points)
186 for(
unsigned sensor_id=0; sensor_id < (
unsigned int)NUM_SENSORS; sensor_id++)
189 bool there_is_obs, hardware_error;
190 getNextFrameRGB(newObs.
intensityImages[sensor_id],newObs.
timestamps[sensor_id], there_is_obs, hardware_error, sensor_id);
191 getNextFrameD(newObs.
rangeImages[sensor_id],newObs.
timestamps[sensor_id], there_is_obs, hardware_error, sensor_id);
196 for(
unsigned sensor_id=0; sensor_id < (
unsigned int)NUM_SENSORS; sensor_id++) {
197 if (m_preview_window)
201 if (++m_preview_decim_counter_range>m_preview_window_decimation)
203 m_preview_decim_counter_range=0;
210 m_win_range[sensor_id]->showImage(
img);
215 if (++m_preview_decim_counter_rgb>m_preview_window_decimation)
217 m_preview_decim_counter_rgb=0;
225 if (m_win_range[sensor_id]) m_win_range[sensor_id].clear();
226 if (m_win_int[sensor_id]) m_win_int[sensor_id].clear();
229 cout <<
"getNextObservation took " << 1000*tictac.
Tac() <<
"ms\n";
234 #endif // MRPT_HAS_OPENNI2
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 BASE_IMPEXP 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.
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.
This namespace provides multitask, synchronization utilities.
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:
bool hasIntensityImage
true means the field intensityImage contains valid data
static CDisplayWindowPtr Create()
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp. Where available, this should contain the accurate satellite-based time...
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.
bool hasRangeImage
true means the field rangeImage contains valid data