MRPT  2.0.1
CObservationRotatingScan.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
12 #include <mrpt/obs/CObservation.h>
14 #include <mrpt/poses/CPose3D.h>
16 #include <variant>
17 #include <vector>
18 
19 namespace mrpt::obs
20 {
21 class CObservationVelodyneScan;
22 class CObservation2DRangeScan;
23 class CObservationPointCloud;
24 
25 /** \addtogroup mrpt_obs_grp
26  * @{ */
27 
28 /** A `CObservation`-derived class for raw range data from a 2D or 3D
29  * rotating scanner. This class is the preferred alternative to
30  * CObservationVelodyneScan and CObservation2DRangeScan in MRPT 2.x, since it
31  * exposes range data as an organized matrix, more convenient for feature
32  * detection directly on "range images".
33  * This class can also import data from KITTI dataset-like binary files
34  * containing unorganized (non "undistorted", i.e. without compensation for
35  * lidar motion) point clouds, which get organized into a 2D range image for
36  * easier filtering and postprocessing.
37  *
38  * Check out the main data fields in the list of members below.
39  *
40  * Note that this object has \b two timestamp fields:
41  * - The standard `CObservation::timestamp` field in the base class, which
42  * should contain the accurate satellite-based UTC timestamp if available,
43  * and
44  * - the field originalReceivedTimestamp, with the
45  * local computer-based timestamp based on the reception of the message in
46  * the computer.
47  *
48  * Both timestamps correspond to the firing of the <b>first</b> laser in
49  * the <b>first</b> CObservationRotatingScan::scan_packets packet.
50  *
51  * <div align=center> <img src="velodyne_axes.jpg"> </div>
52  *
53  * API for accurate reconstruction of point clouds from raw range images:
54  * - generatePointCloud()
55  * - generatePointCloudAlongSE3Trajectory()
56  *
57  * \note New in MRPT 2.0.0
58  * \sa CObservation, mrpt::hwdrivers::CVelodyneScanner
59  */
61 {
63 
64  public:
65  /** @name Scan range data
66  @{ */
67 
68  /** Number of "Lidar rings" (e.g. 16 for a Velodyne VLP16, etc.). This
69  * should be constant for a given LiDAR scanner.
70  * All matrices in `imageLayer_*` have this number of rows.
71  */
72  uint16_t rowCount{0};
73 
74  /** Number of lidar "firings" for this scan. It is assumed
75  * that firings occur at a fixed rate. Consecutive scans ("scan"=instance of
76  * this class) may have different number of firings, and different start and
77  * end azimuth. All matrices defined below have this number of columns.
78  */
79  uint16_t columnCount{0};
80 
81  /** The NxM matrix of distances (ranges) for each direction
82  * (columns) and for each laser "ring" (rows). Matrix element are integers
83  * for efficiency of post-processing filters, etc. Zero means no return
84  * (i.e. invalid range). This member must be always provided, containing the
85  * ranges for the STRONGEST ray returns.
86  */
88 
89  /** Optionally, an intensity channel. Matrix with a 0x0 size if not
90  * provided. */
92 
93  /** Optional additional layers, e.g. LAST return, etc. for lidars with
94  * multiple returns per firing. A descriptive name of what the alternative
95  * range means as std::map Key, e.g. `FIRST`, `SECOND`. */
96  std::map<std::string, mrpt::math::CMatrix_u16> rangeOtherLayers;
97 
98  /** Real-world scale (in meters) of integer units in range images (e.g.
99  * 0.002 means 1 range unit is 2 millimeters) */
101 
102  /** Azimuth of the first and last columns in `ranges`, with respect to the
103  * *sensor* forward direction.
104  * Note that startAzimuth may be possitive or negative, and azimuthSpan can
105  * be too to reflect the direction of rotation of the scanner:
106  * >0 is CCW, <0 is CW.
107  */
109 
110  /** Time(in seconds) that passed since `startAzimuth` to* `endAzimuth`. */
111  double sweepDuration{.0};
112 
113  /** The driver should fill in this observation */
114  std::string lidarModel{"UNKNOWN_SCANNER"};
115 
116  /** The maximum range allowed by the device, in meters (e.g. 100m).
117  * Stored
118  * here by the driver while capturing based on the sensor model. */
119  double minRange{1.0}, maxRange{130.0};
120 
121  /** The SE(3) pose of the sensor on the robot/vehicle frame
122  * of reference */
124 
125  // TODO: Calibration!!
126 
127  /** The local computer-based timestamp based on the
128  * reception of the message in the computer. \sa
129  * has_satellite_timestamp, CObservation::timestamp in the
130  * base class, which should contain the accurate
131  * satellite-based UTC timestamp. */
133 
134  /** If true, CObservation::timestamp has been generated
135  * from accurate satellite clock. Otherwise, no GPS data
136  * is available and timestamps are based on the local
137  * computer clock. */
139 
140  /** @} */
141 
142  /** @name "Convert from" API
143  * @{ */
144 
148 
149  /** Will convert from another observation if it's any of the supported
150  * source types (see fromVelodyne(), fromScan2D(), fromPointCloud()) and
151  * return true, or will return false otherwise if there is no known way to
152  * convert from the passed object. */
153  bool fromGeneric(const mrpt::obs::CObservation& o);
154 
155  /** @} */
156 
157  /** @name "Convert to" API
158  * @{ */
159 
160  /** @} */
161 
162  // See base class docs
164 
165  // See base class docs
166  void getSensorPose(mrpt::poses::CPose3D& out_sensorPose) const override
167  {
168  out_sensorPose = sensorPose;
169  }
170  void setSensorPose(const mrpt::poses::CPose3D& newSensorPose) override
171  {
172  sensorPose = newSensorPose;
173  }
174  void getDescriptionAsText(std::ostream& o) const override;
175 
176 }; // End of class def.
177 
178 /** @} */
179 
180 } // namespace mrpt::obs
181 
182 namespace mrpt::typemeta
183 { // Specialization must occur in the same namespace
184 MRPT_DECLARE_TTYPENAME_PTR_NAMESPACE(CObservationRotatingScan, ::mrpt::obs)
185 }
void getSensorPose(mrpt::poses::CPose3D &out_sensorPose) const override
A general method to retrieve the sensor pose on the robot.
A CObservation-derived class for RAW DATA (and optionally, point cloud) of scans from 3D Velodyne LID...
void fromPointCloud(const mrpt::obs::CObservationPointCloud &o)
double minRange
The maximum range allowed by the device, in meters (e.g.
An observation from any sensor that can be summarized as a pointcloud.
std::string lidarModel
The driver should fill in this observation.
mrpt::poses::CPose3D sensorPose
The SE(3) pose of the sensor on the robot/vehicle frame of reference.
uint16_t columnCount
Number of lidar "firings" for this scan.
bool has_satellite_timestamp
If true, CObservation::timestamp has been generated from accurate satellite clock.
void fromVelodyne(const mrpt::obs::CObservationVelodyneScan &o)
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:40
void getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
uint16_t rowCount
Number of "Lidar rings" (e.g.
mrpt::math::CMatrix_u8 intensityImage
Optionally, an intensity channel.
This namespace contains representation of robot actions and observations.
double rangeResolution
Real-world scale (in meters) of integer units in range images (e.g.
#define MRPT_DECLARE_TTYPENAME_PTR_NAMESPACE(_TYPE, __NS)
Definition: TTypeName.h:142
mrpt::math::CMatrix_u16 rangeImage
The NxM matrix of distances (ranges) for each direction (columns) and for each laser "ring" (rows)...
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
bool fromGeneric(const mrpt::obs::CObservation &o)
Will convert from another observation if it&#39;s any of the supported source types (see fromVelodyne()...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:43
double startAzimuth
Azimuth of the first and last columns in ranges, with respect to the sensor forward direction...
mrpt::system::TTimeStamp originalReceivedTimestamp
The local computer-based timestamp based on the reception of the message in the computer.
void fromScan2D(const mrpt::obs::CObservation2DRangeScan &o)
std::map< std::string, mrpt::math::CMatrix_u16 > rangeOtherLayers
Optional additional layers, e.g.
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
A CObservation-derived class for raw range data from a 2D or 3D rotating scanner. ...
mrpt::system::TTimeStamp getOriginalReceivedTimeStamp() const override
By default, returns CObservation::timestamp but in sensors capable of satellite (or otherwise) accura...
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) override
A general method to change the sensor pose on the robot.
double sweepDuration
Time(in seconds) that passed since startAzimuth to* endAzimuth.
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
Definition: datetime.h:43



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020