00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2010 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 #ifndef CObservation2DRangeScan_H 00029 #define CObservation2DRangeScan_H 00030 00031 #include <mrpt/utils/CSerializable.h> 00032 #include <mrpt/slam/CObservation.h> 00033 #include <mrpt/poses/CPose3D.h> 00034 #include <mrpt/poses/CPose2D.h> 00035 00036 #include <mrpt/slam/CMetricMap.h> 00037 00038 #include <mrpt/math/CPolygon.h> 00039 00040 00041 namespace mrpt 00042 { 00043 namespace slam 00044 { 00045 00046 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CObservation2DRangeScan, CObservation, OBS_IMPEXP) 00047 00048 /** Declares a class derived from "CObservation" that 00049 encapsules a 2D range scan measurement (typically from a laser scanner). 00050 This is prepared for accepting 180deg,360deg or any other aperture scan, 00051 as well as resolutions of 0.5deg,0.25deg or any other. 00052 * 00053 * \sa CObservation 00054 */ 00055 class OBS_IMPEXP CObservation2DRangeScan : public CObservation 00056 { 00057 // This must be added to any CSerializable derived class: 00058 DEFINE_SERIALIZABLE( CObservation2DRangeScan ) 00059 00060 public: 00061 typedef std::vector<mrpt::math::CPolygon> TListExclusionAreas; //!< Used in filterByExclusionAreas 00062 typedef std::vector<std::pair<mrpt::math::CPolygon,std::pair<double,double> > > TListExclusionAreasWithRanges; //!< Used in filterByExclusionAreas 00063 00064 /** Default constructor */ 00065 CObservation2DRangeScan( ); 00066 00067 /** Destructor */ 00068 virtual ~CObservation2DRangeScan( ); 00069 00070 00071 /** @name Scan data 00072 @{ */ 00073 00074 /** The range values of the scan, in meters. 00075 */ 00076 vector_float scan; 00077 00078 /** It's false (=0) on no reflected rays, referenced to elements in "scan" 00079 * (Added in the streamming version #1 of the class) 00080 */ 00081 std::vector<char> validRange; 00082 00083 /** The aperture of the range finder, in radians (typically M_PI = 180 degrees). 00084 */ 00085 float aperture; 00086 00087 /** The scanning direction 00088 */ 00089 bool rightToLeft; 00090 00091 /** The maximum range allowed by the device, in meters (e.g. 80m, 50m,...) 00092 */ 00093 float maxRange; 00094 00095 /** The 6D pose of the sensor on the robot. 00096 */ 00097 CPose3D sensorPose; 00098 00099 /** The "sigma" error of the device in meters, used while inserting the scan in an occupancy grid. 00100 */ 00101 float stdError; 00102 00103 /** The aperture of each beam, in radians, used to insert "thick" rays in the occupancy grid. 00104 * (Added in the streamming version #4 of the class) 00105 */ 00106 float beamAperture; 00107 00108 /** If the laser gathers data by sweeping in the pitch/elevation angle, this holds the increment in "pitch" (=-"elevation") between the beginning and the end of the scan (the sensorPose member stands for the pose at the beginning of the scan). 00109 */ 00110 double deltaPitch; 00111 00112 /** @} */ 00113 00114 00115 /** @name Cached points map 00116 @{ */ 00117 00118 protected: 00119 /** A points map, build only under demand by the methods getAuxPointsMap() and buildAuxPointsMap(). 00120 * It's a generic smart pointer to avoid depending here in the library mrpt-obs on classes on other libraries. 00121 */ 00122 mutable mrpt::slam::CMetricMapPtr m_cachedMap; 00123 00124 void internal_buildAuxPointsMap( const void *options = NULL ) const; //!< Internal method, used from buildAuxPointsMap() 00125 00126 public: 00127 00128 /** Returns the cached points map representation of the scan, if already build with buildAuxPointsMap(), or NULL otherwise. 00129 * Usage: 00130 * \code 00131 * mrpt::slam::CPointsMap *map = obs->getAuxPointsMap<mrpt::slam::CPointsMap>(); 00132 * \endcode 00133 * \sa buildAuxPointsMap 00134 */ 00135 template <class POINTSMAP> 00136 inline const POINTSMAP* getAuxPointsMap() const { 00137 return static_cast<const POINTSMAP*>(m_cachedMap.pointer()); 00138 } 00139 00140 /** Returns a cached points map representing this laser scan, building it upon the first call. 00141 * \param options Can be NULL to use default point maps' insertion options, or a pointer to a "CPointsMap::TInsertionOptions" structure to override some params. 00142 * Usage: 00143 * \code 00144 * mrpt::slam::CPointsMap *map = obs->buildAuxPointsMap<mrpt::slam::CPointsMap>(&options or NULL); 00145 * \endcode 00146 * \sa getAuxPointsMap 00147 */ 00148 template <class POINTSMAP> 00149 inline const POINTSMAP *buildAuxPointsMap( const void *options = NULL ) const { 00150 if (!m_cachedMap.present()) internal_buildAuxPointsMap(options); 00151 return static_cast<const POINTSMAP*>(m_cachedMap.pointer()); 00152 } 00153 00154 /** @} */ 00155 00156 00157 00158 /** Return true if the laser scanner is "horizontal", so it has an absolute value of "pitch" and "roll" less or equal to the given tolerance (in rads, default=0) (with the normal vector either upwards or downwards). 00159 */ 00160 bool isPlanarScan(const double tolerance = 0) const; 00161 00162 /** A general method to retrieve the sensor pose on the robot. 00163 * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases. 00164 * \sa setSensorPose 00165 */ 00166 void getSensorPose( CPose3D &out_sensorPose ) const { out_sensorPose = sensorPose; } 00167 00168 00169 /** A general method to change the sensor pose on the robot. 00170 * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases. 00171 * \sa getSensorPose 00172 */ 00173 void setSensorPose( const CPose3D &newSensorPose ) { sensorPose = newSensorPose; } 00174 00175 /** A general method to truncate the scan by defining a minimum valid distance and a maximum valid angle as well as minimun and maximum heights 00176 (NOTE: the laser z-coordinate must be provided). 00177 */ 00178 void truncateByDistanceAndAngle(float min_distance, float max_angle, float min_height = 0, float max_height = 0, float h = 0 ); 00179 00180 /** Mark as invalid sensed points that fall within any of a set of "exclusion areas", given in coordinates relative to the vehicle (taking into account "sensorPose"). 00181 * \sa C2DRangeFinderAbstract::loadExclusionAreas 00182 */ 00183 void filterByExclusionAreas( const TListExclusionAreas &areas ); 00184 00185 /** Mark as invalid sensed points that fall within any of a set of "exclusion areas", given in coordinates relative to the vehicle (taking into account "sensorPose"). 00186 * \sa C2DRangeFinderAbstract::loadExclusionAreas 00187 */ 00188 void filterByExclusionAreas( const TListExclusionAreasWithRanges &areas ); 00189 00190 /** Mark as invalid the ranges in any of a given set of "forbiden angle ranges", given as pairs<min_angle,max_angle>. 00191 * \sa C2DRangeFinderAbstract::loadExclusionAreas 00192 */ 00193 void filterByExclusionAngles( const std::vector<std::pair<double,double> > &angles ); 00194 00195 }; // End of class def. 00196 00197 00198 } // End of namespace 00199 00200 namespace utils 00201 { 00202 using namespace ::mrpt::slam; 00203 // Specialization must occur in the same namespace 00204 MRPT_DECLARE_TTYPENAME_PTR(CObservation2DRangeScan) 00205 } 00206 00207 } // End of namespace 00208 00209 #endif
| Page generated by Doxygen 1.6.1 for MRPT 0.9.0 SVN: at Mon Jun 7 06:47:58 UTC 2010 |
