MRPT  1.9.9
CPlanarLaserScan.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-2019, 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 
10 #pragma once
11 
13 
14 #include <mrpt/img/TColor.h>
15 #include <mrpt/maps/CMetricMap.h>
17 #include <mrpt/obs/CObservation.h>
19 
20 namespace mrpt
21 {
22 /** \ingroup mrpt_maps_grp */
23 namespace opengl
24 {
25 class CPlanarLaserScan;
26 
27 /** This object renders a 2D laser scan by means of three elements: the points,
28  * the line along end-points and the 2D scanned surface.
29  *
30  * By default, all those three elements are drawn, but you can individually
31  * switch them on/off with:
32  * - CPlanarLaserScan::enablePoints()
33  * - CPlanarLaserScan::enableLine()
34  * - CPlanarLaserScan::enableSurface()
35  *
36  * To change the final result, more methods allow further customization of the
37  * 3D object (color of each element, etc.).
38  *
39  * The scan is passed or updated through CPlanarLaserScan::setScan()
40  *
41  * <div align="center">
42  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px;
43  * border-style: solid;">
44  * <tr> <td> mrpt::opengl::CPlanarLaserScan </td> <td> \image html
45  * preview_CPlanarLaserScan.png </td> </tr>
46  * </table>
47  * </div>
48  *
49  * \note The laser points are projected at the sensor pose as given in the
50  * "scan" object, so this CPlanarLaserScan object should be placed at the exact
51  * pose of the robot coordinates origin.
52  *
53  * \sa mrpt::opengl::CPointCloud, opengl::COpenGLScene
54  * \ingroup mrpt_maps_grp
55  */
57 {
59  protected:
62  mutable bool m_cache_valid{false};
63 
64  float m_line_width{1};
65  float m_line_R{1.f}, m_line_G{0.f}, m_line_B{0.f}, m_line_A{0.5f};
66 
67  float m_points_width{3};
68  float m_points_R{1.0f}, m_points_G{0.0f}, m_points_B{0.0f},
69  m_points_A{1.0f};
70 
71  float m_plane_R{0.01f}, m_plane_G{0.01f}, m_plane_B{0.6f}, m_plane_A{0.6f};
72 
73  bool m_enable_points{true};
74  bool m_enable_line{true};
75  bool m_enable_surface{true};
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(
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  ~CPlanarLaserScan() override = default;
149 };
150 
151 } // namespace opengl
152 } // namespace mrpt
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...
void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
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. ...
void enableLine(bool enable=true)
Show or hides lines along all scanned points.
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4199
~CPlanarLaserScan() override=default
Private, virtual destructor: only can be deleted from smart pointers.
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
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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)
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
const auto bb_max
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
const auto bb_min
void setPointsColor(float R, float G, float B, float A=1.0f)
Lightweight 3D point.
Definition: TPoint3D.h:90
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: 45d659fbb Tue Dec 10 18:21:14 2019 +0100 at mar dic 10 18:30:09 CET 2019