Main MRPT website > C++ reference for MRPT 1.9.9
CObservationVelodyneScan.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef CObservationVelodyneScan_H
10 #define CObservationVelodyneScan_H
11 
13 #include <mrpt/obs/CObservation.h>
15 #include <mrpt/poses/CPose3D.h>
17 #include <vector>
18 
19 namespace mrpt
20 {
21 namespace poses
22 {
23 class CPose3DInterpolator;
24 }
25 namespace obs
26 {
27 /** A `CObservation`-derived class for RAW DATA (and optionally, point cloud) of
28  * scans from 3D Velodyne LIDAR scanners.
29  * A scan comprises one or more "velodyne packets" (refer to Velodyne user
30  * manual).
31  *
32  * <h2>Main data fields:</h2><hr>
33  * - CObservationVelodyneScan::scan_packets with raw data packets.
34  * - CObservationVelodyneScan::point_cloud normally empty after grabbing for
35  * efficiency, can be generated calling \a
36  * CObservationVelodyneScan::generatePointCloud()
37  *
38  * Axes convention for point cloud (x,y,z) coordinates:
39  *
40  * <div align=center> <img src="velodyne_axes.jpg"> </div>
41  *
42  * If it can be assumed that the sensor moves SLOWLY through the environment
43  * (i.e. its pose can be approximated to be the same since the beginning to the
44  * end of one complete scan)
45  * then this observation can be converted / loaded into the following other
46  * classes:
47  * - Maps of points (these require first generating the pointcloud in this
48  * observation object with
49  * mrpt::obs::CObservationVelodyneScan::generatePointCloud() ):
50  * - mrpt::maps::CPointsMap::loadFromVelodyneScan() (available in all
51  * derived classes)
52  * - and the generic method:mrpt::maps::CPointsMap::insertObservation()
53  * - mrpt::opengl::CPointCloud and mrpt::opengl::CPointCloudColoured is
54  * supported by first converting
55  * this scan to a mrpt::maps::CPointsMap-derived class, then loading it into
56  * the opengl object.
57  *
58  * Otherwise, the following API exists for accurate reconstruction of the
59  * sensor path in SE(3) over time:
60  * - CObservationVelodyneScan::generatePointCloudAlongSE3Trajectory()
61  *
62  * Note that this object has \b two timestamp fields:
63  * - The standard CObservation::timestamp field in the base class, which
64  * should contain the accurate satellite-based UTC timestamp, and
65  * - the field CObservationVelodyneScan::originalReceivedTimestamp, with the
66  * local computer-based timestamp based on the reception of the message in the
67  * computer.
68  * Both timestamps correspond to the firing of the <b>first</b> laser in the
69  * <b>first</b> CObservationVelodyneScan::scan_packets packet.
70  *
71  * \note New in MRPT 1.4.0
72  * \sa CObservation, CPointsMap, CVelodyneScanner
73  * \ingroup mrpt_obs_grp
74  */
76 {
78 
79  public:
81  virtual ~CObservationVelodyneScan();
82 
83  /** @name Raw scan fixed parameters
84  @{ */
85  static const int SIZE_BLOCK = 100;
86  static const int RAW_SCAN_SIZE = 3;
87  static const int SCANS_PER_BLOCK = 32;
89 
90  static const float ROTATION_RESOLUTION; // = 0.01f; /**< degrees */
92  36000; /**< hundredths of degrees */
93 
94  static const float DISTANCE_MAX; /**< meters */
95  static const float DISTANCE_RESOLUTION; /**< meters */
96  static const float DISTANCE_MAX_UNITS;
97 
98  /** Blocks 0-31 */
99  static const uint16_t UPPER_BANK = 0xeeff;
100  /** Blocks 32-63 */
101  static const uint16_t LOWER_BANK = 0xddff;
102 
103  static const int PACKET_SIZE = 1206;
104  static const int POS_PACKET_SIZE = 512;
105  static const int BLOCKS_PER_PACKET = 12;
106  static const int PACKET_STATUS_SIZE = 4;
108 
109  static const uint8_t RETMODE_STRONGEST = 0x37;
110  static const uint8_t RETMODE_LAST = 0x38;
111  static const uint8_t RETMODE_DUAL = 0x39;
112 /** @} */
113 
114 /** @name Scan data
115  @{ */
116 
117 #pragma pack(push, 1)
119  {
122  };
123  /** Raw Velodyne data block.
124  * Each block contains data from either the upper or lower laser
125  * bank. The device returns three times as many upper bank blocks. */
126  struct raw_block_t
127  {
128  uint16_t header; ///< Block id: UPPER_BANK or LOWER_BANK
129  uint16_t rotation; ///< 0-35999, divide by 100 to get degrees
131  };
132 
133  /** One unit of data from the scanner (the payload of one UDP DATA packet)
134  */
136  {
138  /** us from top of hour */
140  /** 0x37: strongest, 0x38: last, 0x39: dual return */
142  /** 0x21: HDL-32E, 0x22: VLP-16 */
144  };
145 
146  /** Payload of one POSITION packet */
148  {
149  char unused1[198];
152  /** the full $GPRMC message, as received by Velodyne, terminated with
153  * "\r\n\0" */
154  char NMEA_GPRMC[72 + 234];
155  };
156 #pragma pack(pop)
157 
158  /** The maximum range allowed by the device, in meters (e.g. 100m). Stored
159  * here by the driver while capturing based on the sensor model. */
161  /** The 6D pose of the sensor on the robot/vehicle frame of reference */
163  /** The main content of this object: raw data packet from the LIDAR. \sa
164  * point_cloud */
165  std::vector<TVelodyneRawPacket> scan_packets;
166  /** The calibration data for the LIDAR device. See
167  * mrpt::hwdrivers::CVelodyneScanner and mrpt::obs::VelodyneCalibration for
168  * details. */
170  /** The local computer-based timestamp based on the reception of the message
171  * in the computer. \sa has_satellite_timestamp, CObservation::timestamp in
172  * the base class, which should contain the accurate satellite-based UTC
173  * timestamp. */
175  /** If true, CObservation::timestamp has been generated from accurate
176  * satellite clock. Otherwise, no GPS data is available and timestamps are
177  * based on the local computer clock. */
179 
181  const override; // See base class docs
182 
183  /** See \a point_cloud and \a scan_packets */
184  struct TPointCloud
185  {
186  std::vector<float> x, y, z;
187  /** Color [0,255] */
188  std::vector<uint8_t> intensity;
189  /** Timestamp for each point (if `generatePerPointTimestamp`=true in
190  * `TGeneratePointCloudParameters`), or empty vector if not populated
191  * (default). */
192  std::vector<mrpt::system::TTimeStamp> timestamp;
193  /** Original azimuth of each point (if `generatePerPointAzimuth`=true,
194  * empty otherwise ) */
195  std::vector<float> azimuth;
196 
197  inline size_t size() const { return x.size(); }
198  /** Sets all vectors to zero length */
199  void clear();
200  /** Like clear(), but also enforcing freeing memory */
201  void clear_deep();
202  };
203 
204  /** Optionally, raw data can be converted into a 3D point cloud (local
205  * coordinates wrt the sensor, not the vehicle)
206  * with intensity (graylevel) information. See axes convention in
207  * mrpt::obs::CObservationVelodyneScan \sa generatePointCloud()
208  */
210  /** @} */
211 
212  /** @name Related to conversion to 3D point cloud
213  * @{ */
215  {
216  /** Minimum azimuth, in degrees (Default=0). Points will be generated
217  * only the the area of interest [minAzimuth, maxAzimuth] */
219  /** Minimum azimuth, in degrees (Default=360). Points will be generated
220  * only the the area of interest [minAzimuth, maxAzimuth] */
222  /** Minimum (default=1.0f) and maximum (default: Infinity)
223  * distances/ranges for a point to be considered. Points must pass this
224  * (application specific) condition and also the minRange/maxRange
225  * values in CObservationVelodyneScan (sensor-specific). */
227  /** The limits of the 3D box (default=infinity) in sensor (not vehicle)
228  * local coordinates for the ROI filter \sa filterByROI */
230  /** The limits of the 3D box (default=0) in sensor (not vehicle) local
231  * coordinates for the nROI filter \sa filterBynROI */
233  nROI_z_max;
234  /** (Default:2.0 meters) Minimum distance between a point and its two
235  * neighbors to be considered an invalid point. */
237 
238  /** Enable ROI filter (Default:false): add points inside a given 3D box
239  */
241  /** Enable nROI filter (Default:false): do NOT add points inside a given
242  * 3D box */
244  /** (Default:false) Simple filter to remove spurious returns (e.g. Sun
245  * reflected on large water extensions) */
247  /** (Default:true) In VLP16 dual mode, keep both or just one of the
248  * returns. */
250  /** (Default:false) If `true`, populate the vector timestamp */
252  /** (Default:false) If `true`, populate the vector azimuth */
254 
256  };
257 
259 
260  /** Generates the point cloud into the point cloud data fields in \a
261  * CObservationVelodyneScan::point_cloud
262  * where it is stored in local coordinates wrt the sensor (neither the
263  * vehicle nor the world).
264  * So, this method does not take into account the possible motion of the
265  * sensor through the world as it collects LIDAR scans.
266  * For high dynamics, see the more costly API
267  * generatePointCloudAlongSE3Trajectory()
268  * \note Points with ranges out of [minRange,maxRange] are discarded; as
269  * well, other filters are available in \a params.
270  * \sa generatePointCloudAlongSE3Trajectory(),
271  * TGeneratePointCloudParameters
272  */
273  void generatePointCloud(
275 
276  /** Results for generatePointCloudAlongSE3Trajectory() */
278  {
279  /** Number of points in the observation */
280  size_t num_points;
281  /** Number of points for which a valid interpolated SE(3) pose could be
282  * determined */
285  };
286 
287  /** An alternative to generatePointCloud() for cases where the motion of the
288  * sensor as it grabs one scan (360 deg horiz FOV) cannot be ignored.
289  * \param[in] vehicle_path Timestamped sequence of known poses for the
290  * VEHICLE. Recall that the sensor has a relative pose wrt the vehicle
291  * according to CObservationVelodyneScan::getSensorPose() &
292  * CObservationVelodyneScan::setSensorPose()
293  * \param[out] out_points The generated points, in the same coordinates
294  * frame than \a vehicle_path. Points are APPENDED to the list, so prevous
295  * contents are kept.
296  * \param[out] results_stats Stats
297  * \param[in] params Filtering and other parameters
298  * \sa generatePointCloud(), TGeneratePointCloudParameters
299  */
301  const mrpt::poses::CPose3DInterpolator& vehicle_path,
302  std::vector<mrpt::math::TPointXYZIu8>& out_points,
303  TGeneratePointCloudSE3Results& results_stats,
305 
306  /** @} */
307 
308  void getSensorPose(mrpt::poses::CPose3D& out_sensorPose) const override
309  {
310  out_sensorPose = sensorPose;
311  } // See base class docs
312  void setSensorPose(const mrpt::poses::CPose3D& newSensorPose) override
313  {
314  sensorPose = newSensorPose;
315  } // See base class docs
317  std::ostream& o) const override; // See base class docs
318 
319 }; // End of class def.
320 
321 } // End of namespace
322 
323 namespace utils
324 { // Specialization must occur in the same namespace
325 MRPT_DECLARE_TTYPENAME_PTR_NAMESPACE(CObservationVelodyneScan, ::mrpt::obs)
326 }
327 
328 } // End of namespace
329 
330 #endif
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:32
float ROI_x_min
The limits of the 3D box (default=infinity) in sensor (not vehicle) local coordinates for the ROI fil...
Velodyne calibration data, for usage in mrpt::obs::CObservationVelodyneScan.
A CObservation-derived class for RAW DATA (and optionally, point cloud) of scans from 3D Velodyne LID...
unsigned __int16 uint16_t
Definition: rptypes.h:44
bool filterOutIsolatedPoints
(Default:false) Simple filter to remove spurious returns (e.g.
std::vector< mrpt::system::TTimeStamp > timestamp
Timestamp for each point (if generatePerPointTimestamp=true in TGeneratePointCloudParameters), or empty vector if not populated (default).
std::vector< float > azimuth
Original azimuth of each point (if generatePerPointAzimuth=true, empty otherwise ) ...
static const uint16_t LOWER_BANK
Blocks 32-63.
mrpt::system::TTimeStamp originalReceivedTimestamp
The local computer-based timestamp based on the reception of the message in the computer.
bool generatePerPointAzimuth
(Default:false) If true, populate the vector azimuth
mrpt::obs::VelodyneCalibration calibration
The calibration data for the LIDAR device.
void clear_deep()
Like clear(), but also enforcing freeing memory.
bool has_satellite_timestamp
If true, CObservation::timestamp has been generated from accurate satellite clock.
bool filterByROI
Enable ROI filter (Default:false): add points inside a given 3D box.
mrpt::poses::CPose3D sensorPose
The 6D pose of the sensor on the robot/vehicle frame of reference.
char NMEA_GPRMC[72+234]
the full $GPRMC message, as received by Velodyne, terminated with "\r\n\0"
static const uint16_t ROTATION_MAX_UNITS
hundredths of degrees
void getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
unsigned char uint8_t
Definition: rptypes.h:41
double maxAzimuth_deg
Minimum azimuth, in degrees (Default=360).
void generatePointCloudAlongSE3Trajectory(const mrpt::poses::CPose3DInterpolator &vehicle_path, std::vector< mrpt::math::TPointXYZIu8 > &out_points, TGeneratePointCloudSE3Results &results_stats, const TGeneratePointCloudParameters &params=defaultPointCloudParams)
An alternative to generatePointCloud() for cases where the motion of the sensor as it grabs one scan ...
TPointCloud point_cloud
Optionally, raw data can be converted into a 3D point cloud (local coordinates wrt the sensor...
double minRange
The maximum range allowed by the device, in meters (e.g.
mrpt::system::TTimeStamp getOriginalReceivedTimeStamp() const override
By default, returns CObservation::timestamp but in sensors capable of satellite (or otherwise) accura...
float isolatedPointsFilterDistance
(Default:2.0 meters) Minimum distance between a point and its two neighbors to be considered an inval...
float minDistance
Minimum (default=1.0f) and maximum (default: Infinity) distances/ranges for a point to be considered...
void generatePointCloud(const TGeneratePointCloudParameters &params=defaultPointCloudParams)
Generates the point cloud into the point cloud data fields in CObservationVelodyneScan::point_cloud w...
This namespace contains representation of robot actions and observations.
size_t num_correctly_inserted_points
Number of points for which a valid interpolated SE(3) pose could be determined.
uint16_t header
Block id: UPPER_BANK or LOWER_BANK.
bool generatePerPointTimestamp
(Default:false) If true, populate the vector timestamp
#define MRPT_DECLARE_TTYPENAME_PTR_NAMESPACE(_TYPE, __NS)
Definition: TTypeName.h:93
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
One unit of data from the scanner (the payload of one UDP DATA packet)
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:41
static const uint16_t UPPER_BANK
Blocks 0-31.
void getSensorPose(mrpt::poses::CPose3D &out_sensorPose) const override
A general method to retrieve the sensor pose on the robot.
uint8_t laser_return_mode
0x37: strongest, 0x38: last, 0x39: dual return
static const float DISTANCE_RESOLUTION
meters
static const TGeneratePointCloudParameters defaultPointCloudParams
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) override
A general method to change the sensor pose on the robot.
This class stores a time-stamped trajectory in SE(3) (CPose3D poses).
uint16_t rotation
0-35999, divide by 100 to get degrees
std::vector< TVelodyneRawPacket > scan_packets
The main content of this object: raw data packet from the LIDAR.
GLenum GLint x
Definition: glext.h:3538
bool dualKeepStrongest
(Default:true) In VLP16 dual mode, keep both or just one of the returns.
float nROI_x_min
The limits of the 3D box (default=0) in sensor (not vehicle) local coordinates for the nROI filter...
unsigned __int32 uint32_t
Definition: rptypes.h:47
GLenum const GLfloat * params
Definition: glext.h:3534
static const float ROTATION_RESOLUTION
degrees
bool filterBynROI
Enable nROI filter (Default:false): do NOT add points inside a given 3D box.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019