Main MRPT website > C++ reference
MRPT logo
CPlanarLaserScan.h
Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                       http://www.mrpt.org/                                |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 
00029 #ifndef opengl_CPlanarLaserScan_H
00030 #define opengl_CPlanarLaserScan_H
00031 
00032 #include <mrpt/opengl/CRenderizableDisplayList.h>
00033 
00034 #include <mrpt/slam/CMetricMap.h>
00035 #include <mrpt/slam/CObservation.h>
00036 #include <mrpt/slam/CObservation2DRangeScan.h>
00037 #include <mrpt/slam/CSimplePointsMap.h>
00038 
00039 
00040 namespace mrpt
00041 {
00042         /** \ingroup mrpt_maps_grp */
00043         namespace opengl
00044         {
00045                 class CPlanarLaserScan;
00046 
00047                 // This must be added to any CSerializable derived class:
00048                 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CPlanarLaserScan, CRenderizableDisplayList, MAPS_IMPEXP )
00049 
00050                 /** This object renders a 2D laser scan by means of three elements: the points, the line along end-points and the 2D scanned surface.
00051                   *
00052                   *  By default, all those three elements are drawn, but you can individually switch them on/off with:
00053                   *    - CPlanarLaserScan::enablePoints()
00054                   *    - CPlanarLaserScan::enableLine()
00055                   *    - CPlanarLaserScan::enableSurface()
00056                   *
00057                   *  To change the final result, more methods allow further customization of the 3D object (color of each element, etc.).
00058                   *
00059                   *  The scan is passed or updated through CPlanarLaserScan::setScan()
00060                   *
00061                   *  \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.
00062                   *
00063                   *  \sa mrpt::opengl::CPointCloud, opengl::COpenGLScene
00064                   * \ingroup mrpt_maps_grp
00065                   */
00066                 class MAPS_IMPEXP CPlanarLaserScan : public CRenderizableDisplayList
00067                 {
00068                         DEFINE_SERIALIZABLE( CPlanarLaserScan )
00069                 protected:
00070                         mrpt::slam::CObservation2DRangeScan     m_scan;
00071                         mutable mrpt::slam::CSimplePointsMap            m_cache_points;
00072                         mutable bool    m_cache_valid;
00073 
00074 
00075             float       m_line_width;
00076             float       m_line_R,m_line_G,m_line_B,m_line_A;
00077 
00078             float       m_points_width;
00079             float       m_points_R,m_points_G,m_points_B,m_points_A;
00080 
00081             float       m_plane_R,m_plane_G,m_plane_B,m_plane_A;
00082 
00083                         bool    m_enable_points;
00084                         bool    m_enable_line;
00085                         bool    m_enable_surface;
00086 
00087                 public:
00088                         void clear();   //!<< Clear the scan
00089 
00090                         /** Show or hides the scanned points \sa sePointsWidth, setPointsColor*/
00091                         inline void enablePoints(bool enable=true) { m_enable_points=enable; CRenderizableDisplayList::notifyChange(); }
00092 
00093                         /** Show or hides lines along all scanned points \sa setLineWidth, setLineColor*/
00094                         inline void enableLine(bool enable=true) { m_enable_line=enable; CRenderizableDisplayList::notifyChange(); }
00095 
00096                         /** Show or hides the scanned area as a 2D surface \sa setSurfaceColor */
00097                         inline void enableSurface(bool enable=true) { m_enable_surface=enable; CRenderizableDisplayList::notifyChange(); }
00098 
00099                         void setLineWidth(float w) { m_line_width=w; }
00100                         float getLineWidth() const { return  m_line_width;}
00101 
00102                         void sePointsWidth(float w) { m_points_width=w; }
00103 
00104                         void setLineColor(float R,float G, float B, float A=1.0f)
00105                         {
00106                                 m_line_R=R;
00107                                 m_line_G=G;
00108                                 m_line_B=B;
00109                                 m_line_A=A;
00110                         }
00111                         void setPointsColor(float R,float G, float B, float A=1.0f)
00112                         {
00113                                 m_points_R=R;
00114                                 m_points_G=G;
00115                                 m_points_B=B;
00116                                 m_points_A=A;
00117                         }
00118                         void setSurfaceColor(float R,float G, float B, float A=1.0f)
00119                         {
00120                                 m_plane_R=R;
00121                                 m_plane_G=G;
00122                                 m_plane_B=B;
00123                                 m_plane_A=A;
00124                         }
00125 
00126                         void setScan( const mrpt::slam::CObservation2DRangeScan &scan)
00127                         {
00128                                 CRenderizableDisplayList::notifyChange();
00129                                 m_cache_valid = false;
00130                                 m_scan = scan;
00131                         }
00132 
00133                         /** Render
00134                           */
00135                         void  render_dl() const;
00136 
00137                 private:
00138                         /** Constructor
00139                           */
00140                         CPlanarLaserScan( );
00141 
00142                         /** Private, virtual destructor: only can be deleted from smart pointers */
00143                         virtual ~CPlanarLaserScan() { }
00144                 };
00145 
00146         } // end namespace
00147 
00148 } // End of namespace
00149 
00150 
00151 #endif



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011