30 int main(
int argc,
char** argv)
36 cerr <<
"Usage: " << argv[0] <<
" <sensor_id/sensor_serial\n";
37 cerr <<
"Example: " << argv[0] <<
" 0 \n";
47 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;
71 win3D.setCameraAzimuthDeg(140);
72 win3D.setCameraElevationDeg(20);
73 win3D.setCameraZoom(8.0);
75 win3D.setCameraPointingToPoint(2.5, 0, 0);
78 mrpt::make_aligned_shared<mrpt::opengl::CPointCloudColoured>();
79 gl_points->setPointSize(2.5);
83 mrpt::make_aligned_shared<mrpt::opengl::CPlanarLaserScan>();
84 gl_2d_scan->enablePoints(
true);
85 gl_2d_scan->enableLine(
true);
86 gl_2d_scan->enableSurface(
true);
87 gl_2d_scan->setSurfaceColor(0, 0, 1, 0.3);
95 scene->insert(gl_points);
97 mrpt::make_aligned_shared<mrpt::opengl::CGridPlaneXY>());
99 scene->insert(gl_2d_scan);
101 const double aspect_ratio = 480.0 / 640.0;
104 const int VW_HEIGHT = aspect_ratio * VW_WIDTH;
107 viewInt = scene->createViewport(
"view2d_int");
108 viewInt->setViewportPosition(5, 30, VW_WIDTH, VW_HEIGHT);
109 win3D.addTextMessage(
110 10, 30 + VW_HEIGHT + 10,
"Intensity data",
TColorf(1, 1, 1), 2,
113 win3D.addTextMessage(
114 5, 5,
format(
"'o'/'i'-zoom out/in, ESC: quit"),
117 win3D.unlockAccess3DScene();
124 bool bObs =
false, bError =
true;
127 while (!win3D.keyHit())
131 mrpt::make_aligned_shared<CObservation3DRangeScan>();
136 if (bObs && !bError && newObs &&
138 newObs->timestamp != last_obs_tim)
141 last_obs_tim = newObs->timestamp;
144 if (newObs->hasRangeImage)
148 mrpt::make_aligned_shared<CObservation2DRangeScan>();
153 p2s.sensorLabel =
"KINECT_2D_SCAN";
154 newObs->convertTo2DScan(*obs_2d, p2s);
159 win3D.get3DSceneAndLock();
162 win3D.addTextMessage(
172 if (newObs->hasIntensityImage)
174 viewInt->setImageView(
175 newObs->intensityImage);
179 win3D.unlockAccess3DScene();
189 if (newObs->hasRangeImage)
192 win3D.get3DSceneAndLock();
195 newObs->project3DPointsFromDepthImageInto(
197 win3D.unlockAccess3DScene();
201 gl_2d_scan->setScan(*obs_2d);
207 cout <<
"\nClosing RGBD sensor...\n";
211 catch (std::exception& e)
213 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
218 printf(
"Untyped exception!!");
int getNumDevices() const
The number of available devices at initialization.
double DEG2RAD(const double x)
Degrees to radians.
double angle_sup
(Default=5 degrees) [Only if use_origin_sensor_pose=false] The upper & lower half-FOV angle (in radia...
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.
virtual void initialize()
Initializes the 3D camera - should be invoked after calling loadConfig() or setting the different par...
A class for grabing "range images", intensity images (either RGB or IR) and other information from an...
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
void setSerialToOpen(const unsigned serial)
Set the serial number of the device to open.
Used in CObservation3DRangeScan::convertTo2DScan()
This namespace contains representation of robot actions and observations.
void setSensorIDToOpen(const unsigned sensor_id)
Set the sensor_id of the device to open.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
CSetOfObjects::Ptr CornerXYZ(float scale=1.0)
Returns three arrows representing a X,Y,Z 3D corner.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Used in CObservation3DRangeScan::project3DPointsFromDepthImageInto()
A RGB color - floats in the range [0,1].
The namespace for 3D scene representation and rendering.
std::string dateTimeLocalToString(const mrpt::system::TTimeStamp t)
Convert a timestamp into this textual form (in local time): YEAR/MONTH/DAY,HH:MM:SS.MMM.
renders glyphs as filled polygons
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
bool takeIntoAccountSensorPoseOnRobot
(Default: false) If false, local (sensor-centric) coordinates of points are generated.
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.