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 #include <mrpt/slam/CPointsMap.h> 00036 00037 #include <mrpt/math/CPolygon.h> 00038 00039 00040 namespace mrpt 00041 { 00042 namespace slam 00043 { 00044 00045 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE( CObservation2DRangeScan, CObservation ) 00046 00047 /** Declares a class derived from "CObservation" that 00048 encapsules a 2D range scan measurement (typically from a laser scanner). 00049 This is prepared for accepting 180deg,360deg or any other aperture scan, 00050 as well as resolutions of 0.5deg,0.25deg or any other. 00051 * 00052 * \sa CObservation 00053 */ 00054 class MRPTDLLIMPEXP CObservation2DRangeScan : public CObservation 00055 { 00056 // This must be added to any CSerializable derived class: 00057 DEFINE_SERIALIZABLE( CObservation2DRangeScan ) 00058 00059 public: 00060 class CAuxMapWrapper 00061 { 00062 CPointsMap *auxPointsMap; 00063 public: 00064 CAuxMapWrapper() :auxPointsMap(NULL) { } 00065 CAuxMapWrapper(const CAuxMapWrapper &o) : auxPointsMap(NULL) { } 00066 CAuxMapWrapper & operator =(const CAuxMapWrapper &o) { clear(); return *this; } 00067 00068 ~CAuxMapWrapper() { clear(); } 00069 00070 void clear() { if (auxPointsMap) delete auxPointsMap; auxPointsMap=NULL; } 00071 00072 CPointsMap *get() { return auxPointsMap; } 00073 const CPointsMap *get() const { return auxPointsMap; } 00074 00075 void set(CPointsMap *m) { if (auxPointsMap) delete auxPointsMap; auxPointsMap = m; } 00076 00077 }; 00078 00079 protected: 00080 mutable CAuxMapWrapper m_auxMap; 00081 00082 public: 00083 typedef std::vector<mrpt::math::CPolygon> TListExclusionAreas; //!< Used in filterByExclusionAreas 00084 typedef std::vector<std::pair<mrpt::math::CPolygon,std::pair<double,double> > > TListExclusionAreasWithRanges; //!< Used in filterByExclusionAreas 00085 00086 /** Default constructor 00087 */ 00088 CObservation2DRangeScan( ); 00089 00090 /** Destructor 00091 */ 00092 ~CObservation2DRangeScan( ); 00093 00094 /** The range values of the scan, in meters. 00095 */ 00096 vector_float scan; 00097 00098 /** It's false (=0) on no reflected rays, referenced to elements in "scan" 00099 * (Added in the streamming version #1 of the class) 00100 */ 00101 std::vector<char> validRange; 00102 00103 /** The aperture of the range finder, in radians (typically M_PI = 180 degrees). 00104 */ 00105 float aperture; 00106 00107 /** The scanning direction 00108 */ 00109 bool rightToLeft; 00110 00111 /** The maximum range allowed by the device, in meters (e.g. 80m, 50m,...) 00112 */ 00113 float maxRange; 00114 00115 /** The 6D pose of the sensor on the robot. 00116 */ 00117 CPose3D sensorPose; 00118 00119 /** The "sigma" error of the device in meters, used while inserting the scan in an occupancy grid. 00120 */ 00121 float stdError; 00122 00123 /** The aperture of each beam, in radians, used to insert "thick" rays in the occupancy grid. 00124 * (Added in the streamming version #4 of the class) 00125 */ 00126 float beamAperture; 00127 00128 /** 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). 00129 */ 00130 double deltaPitch; 00131 00132 /** Auxiliary members used to speed up some algorithms: it will be NULL normally. 00133 * \sa buildAuxPointsMap 00134 */ 00135 const CPointsMap *getAuxPointsMap() const { return m_auxMap.get(); } 00136 00137 /** Returns an auxiliary points map built from the scan; it is actually build at the first call to this method, and only once. 00138 * \param options Can be NULL to use default point maps' insertion options, or a valid pointer to override some params. 00139 * \sa auxPointsMap 00140 */ 00141 const CPointsMap *buildAuxPointsMap( CPointsMap::TInsertionOptions *options = NULL ) const; 00142 00143 /** 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). 00144 */ 00145 bool isPlanarScan(const double tolerance = 0) const; 00146 00147 /** Implements the virtual method in charge of finding the likelihood between this 00148 * and another observation, probably only of the same derived class. The operator 00149 * may be asymmetric. 00150 * 00151 * \param anotherObs The other observation to compute likelihood with. 00152 * \param anotherObsPose If known, the belief about the robot pose when the other observation was taken can be supplied here, or NULL if it is unknown. 00153 * 00154 * \return Returns a likelihood measurement, in the range [0,1]. 00155 * \exception std::exception On any error, as another observation being of an invalid class. 00156 */ 00157 float likelihoodWith( const CObservation *anotherObs, const CPosePDF *anotherObsPose = NULL ) const; 00158 00159 /** A general method to retrieve the sensor pose on the robot. 00160 * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases. 00161 * \sa setSensorPose 00162 */ 00163 void getSensorPose( CPose3D &out_sensorPose ) const { out_sensorPose = sensorPose; } 00164 00165 00166 /** A general method to change the sensor pose on the robot. 00167 * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases. 00168 * \sa getSensorPose 00169 */ 00170 void setSensorPose( const CPose3D &newSensorPose ) { sensorPose = newSensorPose; } 00171 00172 /** 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 00173 (NOTE: the laser z-coordinate must be provided). 00174 */ 00175 void truncateByDistanceAndAngle(float min_distance, float max_angle, float min_height = 0, float max_height = 0, float h = 0 ); 00176 00177 /** 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"). 00178 * \sa C2DRangeFinderAbstract::loadExclusionAreas 00179 */ 00180 void filterByExclusionAreas( const TListExclusionAreas &areas ); 00181 00182 /** 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"). 00183 * \sa C2DRangeFinderAbstract::loadExclusionAreas 00184 */ 00185 void filterByExclusionAreas( const TListExclusionAreasWithRanges &areas ); 00186 00187 /** Mark as invalid the ranges in any of a given set of "forbiden angle ranges", given as pairs<min_angle,max_angle>. 00188 * \sa C2DRangeFinderAbstract::loadExclusionAreas 00189 */ 00190 void filterByExclusionAngles( const std::vector<std::pair<double,double> > &angles ); 00191 00192 }; // End of class def. 00193 00194 00195 } // End of namespace 00196 00197 namespace utils 00198 { 00199 using namespace ::mrpt::slam; 00200 // Specialization must occur in the same namespace 00201 MRPT_DECLARE_TTYPENAME_PTR(CObservation2DRangeScan) 00202 } 00203 00204 } // End of namespace 00205 00206 #endif
| Page generated by Doxygen 1.6.2 for MRPT 0.8.1 SVN:exported at Mon Feb 15 22:01:07 UTC 2010 |
