Main MRPT website > C++ reference
MRPT logo
CPlanarLaserScan.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 
29 #ifndef opengl_CPlanarLaserScan_H
30 #define opengl_CPlanarLaserScan_H
31 
33 
34 #include <mrpt/slam/CMetricMap.h>
35 #include <mrpt/slam/CObservation.h>
38 
39 
40 namespace mrpt
41 {
42  /** \ingroup mrpt_maps_grp */
43  namespace opengl
44  {
45  class CPlanarLaserScan;
46 
47  // This must be added to any CSerializable derived class:
49 
50  /** This object renders a 2D laser scan by means of three elements: the points, the line along end-points and the 2D scanned surface.
51  *
52  * By default, all those three elements are drawn, but you can individually switch them on/off with:
53  * - CPlanarLaserScan::enablePoints()
54  * - CPlanarLaserScan::enableLine()
55  * - CPlanarLaserScan::enableSurface()
56  *
57  * To change the final result, more methods allow further customization of the 3D object (color of each element, etc.).
58  *
59  * The scan is passed or updated through CPlanarLaserScan::setScan()
60  *
61  * \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.
62  *
63  * \sa mrpt::opengl::CPointCloud, opengl::COpenGLScene
64  * \ingroup mrpt_maps_grp
65  */
67  {
69  protected:
70  mrpt::slam::CObservation2DRangeScan m_scan;
71  mutable mrpt::slam::CSimplePointsMap m_cache_points;
72  mutable bool m_cache_valid;
73 
74 
75  float m_line_width;
76  float m_line_R,m_line_G,m_line_B,m_line_A;
77 
78  float m_points_width;
79  float m_points_R,m_points_G,m_points_B,m_points_A;
80 
81  float m_plane_R,m_plane_G,m_plane_B,m_plane_A;
82 
83  bool m_enable_points;
84  bool m_enable_line;
85  bool m_enable_surface;
86 
87  public:
88  void clear(); //!<< Clear the scan
89 
90  /** Show or hides the scanned points \sa sePointsWidth, setPointsColor*/
91  inline void enablePoints(bool enable=true) { m_enable_points=enable; CRenderizableDisplayList::notifyChange(); }
92 
93  /** Show or hides lines along all scanned points \sa setLineWidth, setLineColor*/
94  inline void enableLine(bool enable=true) { m_enable_line=enable; CRenderizableDisplayList::notifyChange(); }
95 
96  /** Show or hides the scanned area as a 2D surface \sa setSurfaceColor */
97  inline void enableSurface(bool enable=true) { m_enable_surface=enable; CRenderizableDisplayList::notifyChange(); }
98 
99  void setLineWidth(float w) { m_line_width=w; }
100  float getLineWidth() const { return m_line_width;}
101 
102  void sePointsWidth(float w) { m_points_width=w; }
103 
104  void setLineColor(float R,float G, float B, float A=1.0f)
105  {
106  m_line_R=R;
107  m_line_G=G;
108  m_line_B=B;
109  m_line_A=A;
110  }
111  void setPointsColor(float R,float G, float B, float A=1.0f)
112  {
113  m_points_R=R;
114  m_points_G=G;
115  m_points_B=B;
116  m_points_A=A;
117  }
118  void setSurfaceColor(float R,float G, float B, float A=1.0f)
119  {
120  m_plane_R=R;
121  m_plane_G=G;
122  m_plane_B=B;
123  m_plane_A=A;
124  }
125 
126  void setScan( const mrpt::slam::CObservation2DRangeScan &scan)
127  {
129  m_cache_valid = false;
130  m_scan = scan;
131  }
132 
133  /** Render
134  */
135  void render_dl() const;
136 
137  private:
138  /** Constructor
139  */
140  CPlanarLaserScan( );
141 
142  /** Private, virtual destructor: only can be deleted from smart pointers */
143  virtual ~CPlanarLaserScan() { }
144  };
145 
146  } // end namespace
147 
148 } // End of namespace
149 
150 
151 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013