ScanPoint.hpp
Go to the documentation of this file.
1 //
2 // ScanPoint.hpp
3 //
4 // Stores one ScanPoint
5 //
6 
7 
8 #ifndef SCANPOINT_HPP
9 #define SCANPOINT_HPP
10 
11 
12 #include <cassert>
13 #include "../BasicDatatypes.hpp"
14 
15 namespace datatypes
16 {
17 
18 class Point2D;
19 class Point3D;
20 
21 // Class for a single scan point
22 //
23 // This class stores data of a single scan point:
24 // - Cartesian coordinates
25 // - polar coordinates (redundant information, for run-time efficiency only)
26 // - echo pulse width / RSSI Werte
27 // - flags (properties)
28 // - ID, channel, and subchannel of the laserscanner
29 // * - time offset relative to the scan start
30 //
31 // The public access methods ensure consistency
32 // - of the Cartesian with the polar coordinates and
33 // - of the original data with the decompressed data
34 // (i.e. of the live data with the replay data)
35 //
36 class ScanPoint
37 {
38 public:
39 
40  // Property flags
41  //
42  // (The "marker" flag is a flag that can be used locally by
43  // modules to mark scanpoints. The initial state of this flag
44  // should be considered unknown and it should *not* be used to
45  // transport information between modules as other configurations
46  // may then corrupt the flags.)
47  //
48  enum Flags
49  {
50  FlagGround = 0x0001,
51  FlagDirt = 0x0002,
52  FlagRain = 0x0004,
54  FlagReflector = 0x0020,
56  FlagLeftCovered = 0x0100,
57  FlagRightCovered = 0x0200,
58  FlagBackground = 0x0400,
59  FlagMarker = 0x0800,
60  FlagTransparent = 0x1000,
63  };
64 
65 protected:
66  // Cartesian coordinates
67  double m_x;
68  double m_y;
69  double m_z;
70 
71  // Polar coordinates
72  double m_dist;
73  double m_hAngle; // Polar azimuth (horizontal) angle
74  double m_vAngle; // Polar elevation (vertical) angle
75 
76  // Echo pulse width
77  double m_echoWidth;
78 
79 
80  UINT16 m_flags; // Property flags
81  UINT8 m_sourceId; // ID of the source device
82  UINT8 m_channel; // Measurement channel (= "Layer")
83  UINT8 m_subchannel; // Measurement subchannel (=Echo-Nummer im Schuss)
84 
85 public:
86  ScanPoint(); // Default constructor
87  void clear(); // Clears this scan point. Sets all data to zero.
88 
89  double getX() const { return m_x; } // Returns the Cartesian x-coordinate, in [m]
90  double getY() const { return m_y; }
91  double getZ() const { return m_z; }
92 
93  double getDist() const { return m_dist; } // Returns the polar distance coordinate, in [m]
94  double getHAngle() const { return m_hAngle; } // Returns the polar azimuth (horizontal) angle, in [rad]
95  double getVAngle() const { return m_vAngle; } // Returns the polar elevation (vertical) angle, in [rad]
96 
97  double getEchoWidth() const { return m_echoWidth; } // Returns the echo pulse width
98  UINT16 getFlags() const { return m_flags; } // Returns the point properties
99  UINT8 getSourceId() const { return m_sourceId; } // Returns the source device ID
100  UINT8 getLayer() const { return m_channel; } // Returns the channel ("Layer", "Scan-Ebene")
101  UINT8 getEchoNum() const { return m_subchannel; } // Returns the recording subchannel ("Echo-Nummer")
102 
104  bool isValid() const { return (m_flags & MaskInvalid) == 0; }
106  bool isMarked() const { return (m_flags & FlagMarker); }
108  bool isGround() const { return m_flags & FlagGround; }
110  bool isBackground() const { return m_flags & FlagBackground; }
112  bool isDirt() const { return m_flags & FlagDirt; }
114  bool isRain() const { return m_flags & FlagRain; }
116  bool isLeftCovered() const { return m_flags & FlagLeftCovered; }
118  bool isRightCovered() const { return m_flags & FlagRightCovered; }
120  bool isReflector() const { return m_flags & FlagReflector; }
122  bool isThresholdSwitching() const { return m_flags & FlagThresholdSwitching; }
124  bool isTransparent() const { return m_flags & FlagTransparent; }
125 
131  double getDist(const ScanPoint& other) const;
132 
140  double getDist2D(const ScanPoint& other) const;
141 
143  Point3D toPoint3D() const;
144 
146  Point2D toPoint2D() const;
147 
148 
149  // Returns the distance between the two scanpoint coordinates, in [m]
150  static double getDistanceBetweenScanpoints(const ScanPoint& pt1, const ScanPoint& pt2);
151 
152 
153  void setPoint3D (const Point3D& pt); // Set the Cartesian point coordinates
154  void setCartesian (double x, double y, double z);
155  void setPolar (double dist, double hAngle, double vAngle); // Set the polar point coordinates
156 
157  // Adds offsets to the Cartesian coordinates
158  void addCartesianOffset (double xOffset, double yOffset, double zOffset);
159 
160  // Adds offsets to the polar coordinates
161  void addPolarOffset (double distOffset, double hAngleOffset, double vAngleOffset);
162 
164  void setEchoWidth (double echoWidth);
165 
166  void setSourceId (UINT8 id) { m_sourceId = id; } // Set the device ID of the source scanner
167 
168  void setLayer (UINT8 ch) { m_channel = ch; } // Set the recording layer / channel
169  void setEchoNum (UINT8 sub) { m_subchannel = sub; } // Nummer des Echos
170 
172  void setFlags (UINT16 flags)
173  {
174  m_flags = flags;
175  }
177  void setMarker (bool isMarked = true)
178  {
179  if (isMarked)
180  m_flags |= FlagMarker;
181  else
182  m_flags &= ~FlagMarker;
183  }
185  void setBackground (bool isBackground = true)
186  {
187  if (isBackground)
188  m_flags |= FlagBackground;
189  else
190  m_flags &= ~FlagBackground;
191  }
193  void setGround (bool isGround = true)
194  {
195  if (isGround)
196  m_flags |= FlagGround;
197  else
198  m_flags &= ~FlagGround;
199  }
201  void setDirt (bool isDirt = true)
202  {
203  if (isDirt)
204  m_flags |= FlagDirt;
205  else
206  m_flags &= ~FlagDirt;
207  }
209  void setRain (bool isRain = true)
210  {
211  if (isRain)
212  m_flags |= FlagRain;
213  else
214  m_flags &= ~FlagRain;
215  }
217  void setLeftCovered (bool isLeftCovered = true)
218  {
219  if (isLeftCovered)
220  m_flags |= FlagLeftCovered;
221  else
222  m_flags &= ~FlagLeftCovered;
223  }
225  void setRightCovered (bool isRightCovered = true)
226  {
227  if (isRightCovered)
228  m_flags |= FlagRightCovered;
229  else
230  m_flags &= ~FlagRightCovered;
231  }
233  void setNotCovered () { m_flags &= ~MaskCovered; }
234 
236  void setReflector (bool isReflector = true)
237  {
238  if (isReflector)
239  m_flags |= FlagReflector;
240  else
241  m_flags &= ~FlagReflector;
242  }
243 
245  void setValid() { m_flags &= ~MaskInvalid; }
246 
247  friend bool operator==(const ScanPoint &, const ScanPoint &);
248 
249  std::string toString() const; // Text output
250 
251 private:
253  void updatePolar();
254 
256  void updateCartesian();
257 
258 };
259 
261 std::ostream& operator<<(std::ostream& os, const ScanPoint& point);
262 
264 bool operator==(const ScanPoint &p1, const ScanPoint &p2);
265 
267 bool operator!=(const ScanPoint &p1, const ScanPoint &p2);
268 
269 } // namespace datatypes
270 
271 #endif // SCANPOINT_HPP
double getDist() const
Definition: ScanPoint.hpp:93
void setSourceId(UINT8 id)
Definition: ScanPoint.hpp:166
void setDirt(bool isDirt=true)
Labels the scan point as invalid because its an echo from dirt.
Definition: ScanPoint.hpp:201
This class defines a point in the three-dimensional plane.
Definition: Point3D.hpp:25
friend bool operator==(const ScanPoint &, const ScanPoint &)
Equality predicate.
Definition: ScanPoint.cpp:262
double getHAngle() const
Definition: ScanPoint.hpp:94
void setRightCovered(bool isRightCovered=true)
Labels the scan point: Right neighbour point may be covered.
Definition: ScanPoint.hpp:225
bool isBackground() const
Checks if the scan point is labeled as background.
Definition: ScanPoint.hpp:110
bool isDirt() const
Checks if the scan point is labeled as dirt.
Definition: ScanPoint.hpp:112
uint16_t UINT16
void setNotCovered()
Remove cover status.
Definition: ScanPoint.hpp:233
double getEchoWidth() const
Definition: ScanPoint.hpp:97
EPW of scan point is high enough to be a reflector.
Definition: ScanPoint.hpp:55
void setEchoNum(UINT8 sub)
Definition: ScanPoint.hpp:169
void setGround(bool isGround=true)
Labels the scan point as invalid because it is an echo from the ground.
Definition: ScanPoint.hpp:193
bool isLeftCovered() const
Checks if the "left covered" flag is set.
Definition: ScanPoint.hpp:116
std::string toString() const
Definition: ScanPoint.cpp:243
double getY() const
Definition: ScanPoint.hpp:90
bool isThresholdSwitching() const
Checks if the threshold switching flag is set.
Definition: ScanPoint.hpp:122
void setRain(bool isRain=true)
Labels the scan point as invalid because its an echo from rain.
Definition: ScanPoint.hpp:209
bool isTransparent() const
Checks if there is at least one more echo behind this scan point (B or C echo)
Definition: ScanPoint.hpp:124
double getVAngle() const
Definition: ScanPoint.hpp:95
void setPolar(double dist, double hAngle, double vAngle)
Definition: ScanPoint.cpp:106
Invalid scan point, echo from ground.
Definition: ScanPoint.hpp:50
Left neighbour point may be covered.
Definition: ScanPoint.hpp:56
void setEchoWidth(double echoWidth)
Set the echo pulse width, typically in [m].
Definition: ScanPoint.cpp:237
void addPolarOffset(double distOffset, double hAngleOffset, double vAngleOffset)
Definition: ScanPoint.cpp:158
void setFlags(UINT16 flags)
Sets the scan point flags directly.
Definition: ScanPoint.hpp:172
void setMarker(bool isMarked=true)
Set or clear the "Marker" flag.
Definition: ScanPoint.hpp:177
static double getDistanceBetweenScanpoints(const ScanPoint &pt1, const ScanPoint &pt2)
Definition: ScanPoint.cpp:68
void setPoint3D(const Point3D &pt)
Definition: ScanPoint.cpp:59
All flags of invalid scan points.
Definition: ScanPoint.hpp:61
void setValid()
Removes all scan status information.
Definition: ScanPoint.hpp:245
void setCartesian(double x, double y, double z)
Definition: ScanPoint.cpp:45
void setLeftCovered(bool isLeftCovered=true)
Labels the scan point: Left neighbour point may be covered.
Definition: ScanPoint.hpp:217
Point is "marked" (see above)
Definition: ScanPoint.hpp:59
Point2D toPoint2D() const
Returns the x and y coordinates as a Point2D structure.
Definition: ScanPoint.cpp:123
Old: Scan point was measured in a shot with threshold switching (earlier FPGA versions) ...
Definition: ScanPoint.hpp:53
void addCartesianOffset(double xOffset, double yOffset, double zOffset)
Definition: ScanPoint.cpp:137
There is at least one more echo behind this scan point (B or C echo)
Definition: ScanPoint.hpp:60
Invalid scan point, echo from dirt.
Definition: ScanPoint.hpp:51
Right neighbour point may be covered.
Definition: ScanPoint.hpp:57
void setBackground(bool isBackground=true)
Labels the scan point as invalid because it is in the background area.
Definition: ScanPoint.hpp:185
Point3D toPoint3D() const
Returns the x,y,z coordinates as a Point3D structure.
Definition: ScanPoint.cpp:116
Point has been recognized as background and should not be used in the tracking anymore.
Definition: ScanPoint.hpp:58
bool isRightCovered() const
Checks if the "right covered" flag is set.
Definition: ScanPoint.hpp:118
UINT8 getSourceId() const
Definition: ScanPoint.hpp:99
void setLayer(UINT8 ch)
Definition: ScanPoint.hpp:168
Invalid scan point, echo from rain drop.
Definition: ScanPoint.hpp:52
double getZ() const
Definition: ScanPoint.hpp:91
void setReflector(bool isReflector=true)
Labels the scan point: EPW is high enough to be a reflector.
Definition: ScanPoint.hpp:236
bool isMarked() const
Checks if the marker is set.
Definition: ScanPoint.hpp:106
void updateCartesian()
Compute Cartesian coordinates from the current polar coordinates.
Definition: ScanPoint.cpp:217
UINT8 getLayer() const
Definition: ScanPoint.hpp:100
void updatePolar()
Compute polar coordinates from the current Cartesian coordinates.
Definition: ScanPoint.cpp:180
double getX() const
Definition: ScanPoint.hpp:89
bool isReflector() const
Checks if the reflector flag is set.
Definition: ScanPoint.hpp:120
double getDist2D(const ScanPoint &other) const
Returns the two-dimensional distance between this and the given other scanpoint, in [m]...
Definition: ScanPoint.cpp:83
bool operator!=(const Box2D &b1, const Box2D &b2)
Definition: Box2D.hpp:277
UINT8 getEchoNum() const
Definition: ScanPoint.hpp:101
UINT16 getFlags() const
Definition: ScanPoint.hpp:98
bool isGround() const
Checks if the scan point is labeled as ground.
Definition: ScanPoint.hpp:108
std::ostream & operator<<(std::ostream &os, const EvalCaseResult &result)
bool isRain() const
Checks if the scan point is labeled as rain.
Definition: ScanPoint.hpp:114
bool isValid() const
Checks if the scan point is valid (no ground, dirt, or rain)
Definition: ScanPoint.hpp:104
uint8_t UINT8


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Mon Oct 26 2020 03:27:30