00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2009 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 /** Default constructor 00084 */ 00085 CObservation2DRangeScan( ); 00086 00087 /** Destructor 00088 */ 00089 ~CObservation2DRangeScan( ); 00090 00091 /** The range values of the scan, in meters. 00092 */ 00093 vector_float scan; 00094 00095 /** It's false (=0) on no reflected rays, referenced to elements in "scan" 00096 * (Added in the streamming version #1 of the class) 00097 */ 00098 std::vector<char> validRange; 00099 00100 /** The aperture of the range finder, in radians (typically M_PI = 180 degrees). 00101 */ 00102 float aperture; 00103 00104 /** The scanning direction 00105 */ 00106 bool rightToLeft; 00107 00108 /** The maximum range allowed by the device, in meters (e.g. 80m, 50m,...) 00109 */ 00110 float maxRange; 00111 00112 /** The 6D pose of the sensor on the robot. 00113 */ 00114 CPose3D sensorPose; 00115 00116 /** The "sigma" error of the device in meters, used while inserting the scan in an occupancy grid. 00117 */ 00118 float stdError; 00119 00120 /** The aperture of each beam, in radians, used to insert "thick" rays in the occupancy grid. 00121 * (Added in the streamming version #4 of the class) 00122 */ 00123 float beamAperture; 00124 00125 /** 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). 00126 */ 00127 double deltaPitch; 00128 00129 /** Auxiliary members used to speed up some algorithms: it will be NULL normally. 00130 * \sa buildAuxPointsMap 00131 */ 00132 const CPointsMap *getAuxPointsMap() const { return m_auxMap.get(); } 00133 00134 /** Returns an auxiliary points map built from the scan; it is actually build at the first call to this method, and only once. 00135 * \param options Can be NULL to use default point maps' insertion options, or a valid pointer to override some params. 00136 * \sa auxPointsMap 00137 */ 00138 const CPointsMap *buildAuxPointsMap( CPointsMap::TInsertionOptions *options = NULL ) const; 00139 00140 /** Return true if the laser scanner 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). 00141 */ 00142 bool isPlanarScan(const double &tolerance = 0) const; 00143 00144 /** Implements the virtual method in charge of finding the likelihood between this 00145 * and another observation, probably only of the same derived class. The operator 00146 * may be asymmetric. 00147 * 00148 * \param anotherObs The other observation to compute likelihood with. 00149 * \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. 00150 * 00151 * \return Returns a likelihood measurement, in the range [0,1]. 00152 * \exception std::exception On any error, as another observation being of an invalid class. 00153 */ 00154 float likelihoodWith( const CObservation *anotherObs, const CPosePDF *anotherObsPose = NULL ) const; 00155 00156 /** A general method to retrieve the sensor pose on the robot. 00157 * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases. 00158 * \sa setSensorPose 00159 */ 00160 void getSensorPose( CPose3D &out_sensorPose ) const { out_sensorPose = sensorPose; } 00161 00162 00163 /** A general method to change the sensor pose on the robot. 00164 * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases. 00165 * \sa getSensorPose 00166 */ 00167 void setSensorPose( const CPose3D &newSensorPose ) { sensorPose = newSensorPose; } 00168 00169 /** 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 00170 (NOTE: the laser z-coordinate must be provided). 00171 */ 00172 void truncateByDistanceAndAngle(float min_distance, float max_angle, float min_height = 0, float max_height = 0, float h = 0 ); 00173 00174 /** 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"). 00175 * \sa C2DRangeFinderAbstract::loadExclusionAreas 00176 */ 00177 void filterByExclusionAreas( const std::vector<mrpt::math::CPolygon> &areas ); 00178 00179 /** Mark as invalid the ranges in any of a given set of "forbiden angle ranges", given as pairs<min_angle,max_angle>. 00180 * \sa C2DRangeFinderAbstract::loadExclusionAreas 00181 */ 00182 void filterByExclusionAngles( const std::vector<std::pair<double,double> > &angles ); 00183 00184 }; // End of class def. 00185 00186 00187 } // End of namespace 00188 00189 namespace utils 00190 { 00191 using namespace ::mrpt::slam; 00192 // Specialization must occur in the same namespace 00193 MRPT_DECLARE_TTYPENAME_PTR(CObservation2DRangeScan) 00194 } 00195 00196 } // End of namespace 00197 00198 #endif
Page generated by Doxygen 1.5.7.1 for MRPT 0.7.1 SVN: at Mon Aug 17 23:10:56 EDT 2009 |