Go to the documentation of this file.
29 int main(
int argc,
char** argv)
35 cerr <<
"Usage: " << argv[0] <<
" <sensor_id/sensor_serial\n";
36 cerr <<
"Example: " << argv[0] <<
" 0 \n";
46 unsigned sensor_id_or_serial = 0;
50 sensor_id_or_serial = atoi(argv[1]);
51 if (sensor_id_or_serial > 10)
63 cout <<
"OK " << rgbd_sensor.
getNumDevices() <<
" available devices."
65 cout <<
"\nUse device " << sensor_id_or_serial << endl << endl;
67 bool showImages =
false;
74 unsigned int nFrames = 0;
76 bool bObs =
false, bError =
true;
81 cout <<
"Get a new frame\n";
84 double fps = ++nFrames / tictac.
Tac();
87 cout <<
"FPS: " << fps << endl;
96 std::this_thread::sleep_for(10ms);
105 win3D.setCameraAzimuthDeg(140);
106 win3D.setCameraElevationDeg(20);
107 win3D.setCameraZoom(8.0);
109 win3D.setCameraPointingToPoint(2.5, 0, 0);
112 mrpt::make_aligned_shared<mrpt::opengl::CPointCloudColoured>();
113 gl_points->setPointSize(2.5);
119 win3D.get3DSceneAndLock();
122 scene->insert(gl_points);
124 mrpt::make_aligned_shared<mrpt::opengl::CGridPlaneXY>());
127 const double aspect_ratio = 480.0 / 640.0;
128 const int VW_WIDTH = 400;
130 const int VW_HEIGHT = aspect_ratio * VW_WIDTH;
133 viewInt = scene->createViewport(
"view2d_int");
134 viewInt->setViewportPosition(5, 30, VW_WIDTH, VW_HEIGHT);
135 win3D.addTextMessage(
136 10, 30 + VW_HEIGHT + 10,
"Intensity data",
TColorf(1, 1, 1),
139 win3D.addTextMessage(
140 5, 5,
format(
"'o'/'i'-zoom out/in, ESC: quit"),
143 win3D.unlockAccess3DScene();
150 bool bObs =
false, bError =
true;
153 while (!win3D.keyHit())
157 mrpt::make_aligned_shared<CObservation3DRangeScan>();
160 if (bObs && !bError && newObs &&
162 newObs->timestamp != last_obs_tim)
165 last_obs_tim = newObs->timestamp;
170 win3D.get3DSceneAndLock();
173 win3D.addTextMessage(
183 if (newObs->hasIntensityImage)
185 viewInt->setImageView(
186 newObs->intensityImage);
191 win3D.unlockAccess3DScene();
201 if (newObs->hasRangeImage)
204 static pcl::PointCloud<pcl::PointXYZRGB> cloud;
205 newObs->project3DPointsFromDepthImageInto(cloud,
false );
207 win3D.get3DSceneAndLock();
208 gl_points->loadFromPointsMap(&cloud);
209 win3D.unlockAccess3DScene();
214 win3D.get3DSceneAndLock();
217 newObs->project3DPointsFromDepthImageInto(
219 win3D.unlockAccess3DScene();
228 cout <<
"\nClosing RGBD sensor...\n";
232 catch (std::exception& e)
234 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
239 printf(
"Untyped exception!!");
int getNumDevices() const
The number of available devices at initialization.
bool kbhit() noexcept
An OS-independent version of kbhit, which returns true if a key has been pushed.
std::string dateTimeLocalToString(const mrpt::system::TTimeStamp t)
Convert a timestamp into this textual form (in local time): YEAR/MONTH/DAY,HH:MM:SS....
Used in CObservation3DRangeScan::project3DPointsFromDepthImageInto()
A high-performance stopwatch, with typical resolution of nanoseconds.
virtual void initialize()
Initializes the 3D camera - should be invoked after calling loadConfig() or setting the different par...
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
void getNextObservation(mrpt::obs::CObservation3DRangeScan &out_obs, bool &there_is_obs, bool &hardware_error)
The main data retrieving function, to be called after calling loadConfig() and initialize().
Contains classes for various device interfaces.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void setSerialToOpen(const unsigned serial)
Set the serial number of the device to open.
std::shared_ptr< CPointCloudColoured > Ptr
@ MRPT_GLUT_BITMAP_HELVETICA_12
This namespace contains representation of robot actions and observations.
@ MRPT_GLUT_BITMAP_HELVETICA_18
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1,...
double Tac() noexcept
Stops the stopwatch.
mrpt::img::CImage intensityImage
If hasIntensityImage=true, a color or gray-level intensity image of the same size than "rangeImage".
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement,...
void setSensorIDToOpen(const unsigned sensor_id)
Set the sensor_id of the device to open.
mrpt::gui::CDisplayWindow3D::Ptr win
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
A RGB color - floats in the range [0,1].
void Tic() noexcept
Starts the stopwatch.
This class creates a window as a graphical user interface (GUI) for displaying images to the user.
@ FILL
renders glyphs as filled polygons
CSetOfObjects::Ptr CornerXYZ(float scale=1.0)
Returns three arrows representing a X,Y,Z 3D corner.
std::shared_ptr< CObservation3DRangeScan > Ptr
std::shared_ptr< COpenGLScene > Ptr
bool takeIntoAccountSensorPoseOnRobot
(Default: false) If false, local (sensor-centric) coordinates of points are generated.
The namespace for 3D scene representation and rendering.
std::shared_ptr< COpenGLViewport > Ptr
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.
A class for grabing "range images", intensity images (either RGB or IR) and other information from an...
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |