MRPT  1.9.9
CPlanarLaserScan.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-2018, 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 
10 #ifndef opengl_CPlanarLaserScan_H
11 #define opengl_CPlanarLaserScan_H
12 
14 
15 #include <mrpt/maps/CMetricMap.h>
16 #include <mrpt/obs/CObservation.h>
19 #include <mrpt/img/TColor.h>
20 
21 namespace mrpt
22 {
23 /** \ingroup mrpt_maps_grp */
24 namespace opengl
25 {
26 class CPlanarLaserScan;
27 
28 /** This object renders a 2D laser scan by means of three elements: the points,
29  * the line along end-points and the 2D scanned surface.
30  *
31  * By default, all those three elements are drawn, but you can individually
32  * switch them on/off with:
33  * - CPlanarLaserScan::enablePoints()
34  * - CPlanarLaserScan::enableLine()
35  * - CPlanarLaserScan::enableSurface()
36  *
37  * To change the final result, more methods allow further customization of the
38  * 3D object (color of each element, etc.).
39  *
40  * The scan is passed or updated through CPlanarLaserScan::setScan()
41  *
42  * <div align="center">
43  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px;
44  * border-style: solid;">
45  * <tr> <td> mrpt::opengl::CPlanarLaserScan </td> <td> \image html
46  * preview_CPlanarLaserScan.png </td> </tr>
47  * </table>
48  * </div>
49  *
50  * \note The laser points are projected at the sensor pose as given in the
51  * "scan" object, so this CPlanarLaserScan object should be placed at the exact
52  * pose of the robot coordinates origin.
53  *
54  * \sa mrpt::opengl::CPointCloud, opengl::COpenGLScene
55  * \ingroup mrpt_maps_grp
56  */
58 {
60  protected:
63  mutable bool m_cache_valid;
64 
65  float m_line_width;
67 
70 
72 
76 
77  public:
78  /**< Clear the scan */
79  void clear();
80 
81  /** Show or hides the scanned points \sa sePointsWidth, setPointsColor*/
82  inline void enablePoints(bool enable = true)
83  {
84  m_enable_points = enable;
86  }
87 
88  /** Show or hides lines along all scanned points \sa setLineWidth,
89  * setLineColor*/
90  inline void enableLine(bool enable = true)
91  {
92  m_enable_line = enable;
94  }
95 
96  /** Show or hides the scanned area as a 2D surface \sa setSurfaceColor */
97  inline void enableSurface(bool enable = true)
98  {
99  m_enable_surface = enable;
101  }
102 
103  void setLineWidth(float w) { m_line_width = w; }
104  float getLineWidth() const { return m_line_width; }
105  void setPointsWidth(float w) { m_points_width = w; }
106  void setLineColor(float R, float G, float B, float A = 1.0f)
107  {
108  m_line_R = R;
109  m_line_G = G;
110  m_line_B = B;
111  m_line_A = A;
112  }
113  void setPointsColor(float R, float G, float B, float A = 1.0f)
114  {
115  m_points_R = R;
116  m_points_G = G;
117  m_points_B = B;
118  m_points_A = A;
119  }
120  void setSurfaceColor(float R, float G, float B, float A = 1.0f)
121  {
122  m_plane_R = R;
123  m_plane_G = G;
124  m_plane_B = B;
125  m_plane_A = A;
126  }
127 
129  {
131  m_cache_valid = false;
132  m_scan = scan;
133  }
134 
135  /** Render
136  */
137  void render_dl() const override;
138 
139  void getBoundingBox(
140  mrpt::math::TPoint3D& bb_min,
141  mrpt::math::TPoint3D& bb_max) const override;
142 
143  /** Constructor
144  */
146 
147  /** Private, virtual destructor: only can be deleted from smart pointers */
148  virtual ~CPlanarLaserScan() {}
149 };
150 
151 } // end namespace
152 } // End of namespace
153 #endif
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
mrpt::maps::CSimplePointsMap m_cache_points
void setSurfaceColor(float R, float G, float B, float A=1.0f)
const double G
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans. ...
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
void enableLine(bool enable=true)
Show or hides lines along all scanned points.
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4178
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
void enableSurface(bool enable=true)
Show or hides the scanned area as a 2D surface.
void render_dl() const override
Render.
This object renders a 2D laser scan by means of three elements: the points, the line along end-points...
void enablePoints(bool enable=true)
Show or hides the scanned points.
mrpt::obs::CObservation2DRangeScan m_scan
virtual ~CPlanarLaserScan()
Private, virtual destructor: only can be deleted from smart pointers.
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 "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
const float R
void setLineColor(float R, float G, float B, float A=1.0f)
void setPointsColor(float R, float G, float B, float A=1.0f)
Lightweight 3D point.
void clear()
< Clear the scan
void setScan(const mrpt::obs::CObservation2DRangeScan &scan)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020