Main MRPT website > C++ reference for MRPT 1.5.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-2017, 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 
20 
21 namespace mrpt
22 {
23  /** \ingroup mrpt_maps_grp */
24  namespace opengl
25  {
26  class CPlanarLaserScan;
27 
28  // This must be added to any CSerializable derived class:
29  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CPlanarLaserScan, CRenderizableDisplayList, MAPS_IMPEXP )
30 
31  /** This object renders a 2D laser scan by means of three elements: the points, the line along end-points and the 2D scanned surface.
32  *
33  * By default, all those three elements are drawn, but you can individually switch them on/off with:
34  * - CPlanarLaserScan::enablePoints()
35  * - CPlanarLaserScan::enableLine()
36  * - CPlanarLaserScan::enableSurface()
37  *
38  * To change the final result, more methods allow further customization of the 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; border-style: solid;">
44  * <tr> <td> mrpt::opengl::CPlanarLaserScan </td> <td> \image html preview_CPlanarLaserScan.png </td> </tr>
45  * </table>
46  * </div>
47  *
48  * \note The laser points are projected at the sensor pose as given in the "scan" object, so this CPlanarLaserScan object should be placed at the exact pose of the robot coordinates origin.
49  *
50  * \sa mrpt::opengl::CPointCloud, opengl::COpenGLScene
51  * \ingroup mrpt_maps_grp
52  */
54  {
56  protected:
59  mutable bool m_cache_valid;
60 
61 
62  float m_line_width;
63  float m_line_R,m_line_G,m_line_B,m_line_A;
64 
66  float m_points_R,m_points_G,m_points_B,m_points_A;
67 
68  float m_plane_R,m_plane_G,m_plane_B,m_plane_A;
69 
73 
74  public:
75  void clear(); //!<< Clear the scan
76 
77  /** Show or hides the scanned points \sa sePointsWidth, setPointsColor*/
78  inline void enablePoints(bool enable=true) { m_enable_points=enable; CRenderizableDisplayList::notifyChange(); }
79 
80  /** Show or hides lines along all scanned points \sa setLineWidth, setLineColor*/
81  inline void enableLine(bool enable=true) { m_enable_line=enable; CRenderizableDisplayList::notifyChange(); }
82 
83  /** Show or hides the scanned area as a 2D surface \sa setSurfaceColor */
84  inline void enableSurface(bool enable=true) { m_enable_surface=enable; CRenderizableDisplayList::notifyChange(); }
85 
86  void setLineWidth(float w) { m_line_width=w; }
87  float getLineWidth() const { return m_line_width;}
88 
89  void setPointsWidth(float w) { m_points_width=w; }
90 
91  void setLineColor(float R,float G, float B, float A=1.0f)
92  {
93  m_line_R=R;
94  m_line_G=G;
95  m_line_B=B;
96  m_line_A=A;
97  }
98  void setPointsColor(float R,float G, float B, float A=1.0f)
99  {
100  m_points_R=R;
101  m_points_G=G;
102  m_points_B=B;
103  m_points_A=A;
104  }
105  void setSurfaceColor(float R,float G, float B, float A=1.0f)
106  {
107  m_plane_R=R;
108  m_plane_G=G;
109  m_plane_B=B;
110  m_plane_A=A;
111  }
112 
114  {
116  m_cache_valid = false;
117  m_scan = scan;
118  }
119 
120  /** Render
121  */
122  void render_dl() const MRPT_OVERRIDE;
123 
124  void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE;
125 
126  private:
127  /** Constructor
128  */
129  CPlanarLaserScan( );
130 
131  /** Private, virtual destructor: only can be deleted from smart pointers */
132  virtual ~CPlanarLaserScan() { }
133  };
134  DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE( CPlanarLaserScan, CRenderizableDisplayList, MAPS_IMPEXP )
135 
136  } // end namespace
137 
138 } // End of namespace
139 
140 
141 #endif
mrpt::maps::CSimplePointsMap m_cache_points
void setSurfaceColor(float R, float G, float B, float A=1.0f)
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
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 clear()
Clear the contents of this container.
Definition: ts_hash_map.h:113
void enableLine(bool enable=true)
Show or hides lines along all scanned points.
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:3962
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.
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
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.
#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)
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
void setScan(const mrpt::obs::CObservation2DRangeScan &scan)



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020