ScanPoint.hpp
Go to the documentation of this file.
00001 //
00002 // ScanPoint.hpp
00003 //
00004 // Stores one ScanPoint
00005 //
00006 
00007 
00008 #ifndef SCANPOINT_HPP
00009 #define SCANPOINT_HPP
00010 
00011 
00012 #include <cassert>
00013 #include "../BasicDatatypes.hpp"
00014 
00015 namespace datatypes
00016 {
00017 
00018 class Point2D;
00019 class Point3D;
00020 
00021 // Class for a single scan point
00022 //
00023 // This class stores data of a single scan point:
00024 // - Cartesian coordinates
00025 // - polar coordinates (redundant information, for run-time efficiency only)
00026 // - echo pulse width / RSSI Werte
00027 // - flags (properties)
00028 // - ID, channel, and subchannel of the laserscanner
00029 // * - time offset relative to the scan start
00030 //
00031 // The public access methods ensure consistency
00032 // - of the Cartesian with the polar coordinates and
00033 // - of the original data with the decompressed data
00034 //   (i.e. of the live data with the replay data)
00035 //
00036 class ScanPoint
00037 {
00038 public:
00039 
00040         // Property flags
00041         //
00042         // (The "marker" flag is a flag that can be used locally by
00043         // modules to mark scanpoints. The initial state of this flag
00044         // should be considered unknown and it should *not* be used to
00045         // transport information between modules as other configurations
00046         // may then corrupt the flags.)
00047         //
00048         enum Flags
00049         {
00050                 FlagGround                          = 0x0001,                            
00051                 FlagDirt                            = 0x0002,                            
00052                 FlagRain                                = 0x0004,                            
00053                 FlagThresholdSwitching  = 0x0010,                                                        
00054 
00055                 FlagReflector                   = 0x0020,                                                        
00056                 FlagLeftCovered                 = 0x0100,                            
00057                 FlagRightCovered                = 0x0200,                            
00058                 FlagBackground                  = 0x0400,                            
00059                 FlagMarker                              = 0x0800,                                                        
00060                 FlagTransparent                 = 0x1000,                                                        
00061                 MaskInvalid                             = FlagGround | FlagDirt | FlagRain | FlagBackground,  
00062                 MaskCovered                             = FlagLeftCovered | FlagRightCovered 
00063         };
00064 
00065 protected:
00066         // Cartesian coordinates
00067         double m_x;
00068         double m_y;
00069         double m_z;
00070 
00071         // Polar coordinates
00072         double m_dist;
00073         double m_hAngle;        // Polar azimuth (horizontal) angle
00074         double m_vAngle;        // Polar elevation (vertical) angle
00075 
00076         // Echo pulse width
00077         double m_echoWidth;
00078 
00079         
00080         UINT16 m_flags;         // Property flags
00081         UINT8 m_sourceId;       // ID of the source device
00082         UINT8 m_channel;        // Measurement channel (= "Layer")
00083         UINT8 m_subchannel;     // Measurement subchannel (=Echo-Nummer im Schuss)
00084 
00085 public:
00086         ScanPoint();            // Default constructor
00087         void clear();           // Clears this scan point. Sets all data to zero.
00088 
00089         double getX() const { return m_x; }     // Returns the Cartesian x-coordinate, in [m]
00090         double getY() const { return m_y; }
00091         double getZ() const { return m_z; }
00092 
00093         double getDist() const { return m_dist; }       // Returns the polar distance coordinate, in [m]
00094         double getHAngle() const { return m_hAngle; } // Returns the polar azimuth (horizontal) angle, in [rad]
00095         double getVAngle() const { return m_vAngle; }   // Returns the polar elevation (vertical) angle, in [rad]
00096 
00097         double getEchoWidth() const { return m_echoWidth; }     // Returns the echo pulse width
00098         UINT16 getFlags() const { return m_flags; }     // Returns the point properties
00099         UINT8 getSourceId() const { return m_sourceId; }        // Returns the source device ID
00100         UINT8 getLayer() const { return m_channel; }    // Returns the channel ("Layer", "Scan-Ebene")
00101         UINT8 getEchoNum() const { return m_subchannel; }       // Returns the recording subchannel ("Echo-Nummer")
00102 
00104         bool isValid() const { return (m_flags & MaskInvalid) == 0; }
00106         bool isMarked() const { return (m_flags & FlagMarker); }
00108         bool isGround() const { return m_flags & FlagGround; }
00110         bool isBackground() const { return m_flags & FlagBackground; }
00112         bool isDirt() const { return m_flags & FlagDirt; }
00114         bool isRain() const { return m_flags & FlagRain; }
00116         bool isLeftCovered() const { return m_flags & FlagLeftCovered; }
00118         bool isRightCovered() const { return m_flags & FlagRightCovered; }
00120         bool isReflector() const { return m_flags & FlagReflector; }
00122         bool isThresholdSwitching() const { return m_flags & FlagThresholdSwitching; }
00124         bool isTransparent() const { return m_flags & FlagTransparent; }
00125 
00131         double getDist(const ScanPoint& other) const;
00132 
00140         double getDist2D(const ScanPoint& other) const;
00141 
00143         Point3D toPoint3D() const;
00144 
00146         Point2D toPoint2D() const;
00147 
00148 
00149         // Returns the distance between the two scanpoint coordinates, in [m]
00150         static double getDistanceBetweenScanpoints(const ScanPoint& pt1, const ScanPoint& pt2);
00151 
00152 
00153         void setPoint3D (const Point3D& pt);    // Set the Cartesian point coordinates
00154         void setCartesian (double x, double y, double z);
00155         void setPolar (double dist, double hAngle, double vAngle);      // Set the polar point coordinates
00156 
00157         // Adds offsets to the Cartesian coordinates
00158         void addCartesianOffset (double xOffset, double yOffset, double zOffset);
00159 
00160         // Adds offsets to the polar coordinates
00161         void addPolarOffset (double distOffset, double hAngleOffset, double vAngleOffset);
00162 
00164         void setEchoWidth (double echoWidth);
00165 
00166         void setSourceId (UINT8 id) { m_sourceId = id; }        // Set the device ID of the source scanner
00167 
00168         void setLayer (UINT8 ch) { m_channel = ch; }    // Set the recording layer / channel
00169         void setEchoNum (UINT8 sub) { m_subchannel = sub; }     // Nummer des Echos
00170 
00172         void setFlags (UINT16 flags)
00173         {
00174                 m_flags = flags;
00175         }
00177         void setMarker (bool isMarked = true)
00178         {
00179                 if (isMarked)
00180                         m_flags |=  FlagMarker;
00181                 else
00182                         m_flags &= ~FlagMarker;
00183         }
00185         void setBackground (bool isBackground = true)
00186         {
00187                 if (isBackground)
00188                         m_flags |=  FlagBackground;
00189                 else
00190                         m_flags &= ~FlagBackground;
00191         }
00193         void setGround (bool isGround = true)
00194         {
00195                 if (isGround)
00196                         m_flags |=  FlagGround;
00197                 else
00198                         m_flags &= ~FlagGround;
00199         }
00201         void setDirt (bool isDirt = true)
00202         {
00203                 if (isDirt)
00204                         m_flags |=  FlagDirt;
00205                 else
00206                         m_flags &= ~FlagDirt;
00207         }
00209         void setRain (bool isRain = true)
00210         {
00211                 if (isRain)
00212                         m_flags |=  FlagRain;
00213                 else
00214                         m_flags &= ~FlagRain;
00215         }
00217         void setLeftCovered (bool isLeftCovered = true)
00218         {
00219                 if (isLeftCovered)
00220                         m_flags |=  FlagLeftCovered;
00221                 else
00222                         m_flags &= ~FlagLeftCovered;
00223         }
00225         void setRightCovered (bool isRightCovered = true)
00226         {
00227                 if (isRightCovered)
00228                         m_flags |=  FlagRightCovered;
00229                 else
00230                         m_flags &= ~FlagRightCovered;
00231         }
00233         void setNotCovered () { m_flags &= ~MaskCovered; }
00234 
00236         void setReflector (bool isReflector = true)
00237         {
00238                 if (isReflector)
00239                         m_flags |= FlagReflector;
00240                 else
00241                         m_flags &= ~FlagReflector;
00242         }
00243 
00245         void setValid() { m_flags &= ~MaskInvalid; }
00246 
00247         friend bool operator==(const ScanPoint &, const ScanPoint &);
00248         
00249         std::string toString() const;   // Text output
00250 
00251 private:
00253         void updatePolar();
00254 
00256         void updateCartesian();
00257 
00258 };
00259 
00261 std::ostream& operator<<(std::ostream& os, const ScanPoint& point);
00262 
00264 bool operator==(const ScanPoint &p1, const ScanPoint &p2);
00265 
00267 bool operator!=(const ScanPoint &p1, const ScanPoint &p2);
00268 
00269 }       // namespace datatypes
00270 
00271 #endif //  SCANPOINT_HPP


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Thu Jun 6 2019 21:02:36