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 CObservation3DRangeScan_H 00029 #define CObservation3DRangeScan_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( CObservation3DRangeScan, CObservation ) 00046 00047 /** Declares a class derived from "CObservation" that 00048 encapsules a 3D range scan measurement (e.g. from a time of flight range camera). 00049 * 00050 * \sa CObservation 00051 */ 00052 class MRPTDLLIMPEXP CObservation3DRangeScan : public CObservation 00053 { 00054 // This must be added to any CSerializable derived class: 00055 DEFINE_SERIALIZABLE( CObservation3DRangeScan ) 00056 00057 public: 00058 class CAuxMapWrapper 00059 { 00060 CPointsMap *auxPointsMap; 00061 public: 00062 CAuxMapWrapper() :auxPointsMap(NULL) { } 00063 CAuxMapWrapper(const CAuxMapWrapper &o) : auxPointsMap(NULL) { } 00064 CAuxMapWrapper & operator =(const CAuxMapWrapper &o) { clear(); return *this; } 00065 00066 ~CAuxMapWrapper() { clear(); } 00067 00068 void clear() { if (auxPointsMap) delete auxPointsMap; auxPointsMap=NULL; } 00069 00070 CPointsMap *get() { return auxPointsMap; } 00071 const CPointsMap *get() const { return auxPointsMap; } 00072 00073 void set(CPointsMap *m) { if (auxPointsMap) delete auxPointsMap; auxPointsMap = m; } 00074 00075 }; 00076 00077 protected: 00078 mutable CAuxMapWrapper m_auxMap; 00079 00080 public: 00081 /** Default constructor 00082 */ 00083 CObservation3DRangeScan( ); 00084 00085 /** Destructor 00086 */ 00087 ~CObservation3DRangeScan( ); 00088 00089 /** The x y and z coordinates of the 3D range measurement, in meters. 00090 */ 00091 vector_float scan_x; 00092 vector_float scan_y; 00093 vector_float scan_z; 00094 00095 /** It's false (=0) for points outside of [min_distance, max_distance], referenced to elements in "scan_x" 00096 * \sa truncateByDistance 00097 */ 00098 std::vector<char> validRange; 00099 00100 /** The maximum range allowed by the device, in meters (e.g. 8.0m, 5.0m,...) 00101 */ 00102 float maxRange; 00103 00104 /** The 6D pose of the sensor on the robot. 00105 */ 00106 CPose3D sensorPose; 00107 00108 /** The "sigma" error of the device in meters, used while inserting the scan in an occupancy grid. 00109 */ 00110 float stdError; 00111 00112 /** Auxiliary members used to speed up some algorithms: it will be NULL normally. 00113 * \sa buildAuxPointsMap 00114 */ 00115 const CPointsMap *getAuxPointsMap() const { return m_auxMap.get(); } 00116 00117 /** Returns an auxiliary points map built from the scan; it is actually build at the first call to this method, and only once. 00118 * \param options Can be NULL to use default point maps' insertion options, or a valid pointer to override some params. 00119 * \sa auxPointsMap 00120 */ 00121 const CPointsMap *buildAuxPointsMap( CPointsMap::TInsertionOptions *options = NULL ) const; 00122 00123 /** Implements the virtual method in charge of finding the likelihood between this 00124 * and another observation, probably only of the same derived class. The operator 00125 * may be asymmetric. 00126 * 00127 * \param anotherObs The other observation to compute likelihood with. 00128 * \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. 00129 * 00130 * \return Returns a likelihood measurement, in the range [0,1]. 00131 * \exception std::exception On any error, as another observation being of an invalid class. 00132 */ 00133 float likelihoodWith( const CObservation *anotherObs, const CPosePDF *anotherObsPose = NULL ) const; 00134 00135 /** A general method to retrieve the sensor pose on the robot. 00136 * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases. 00137 * \sa setSensorPose 00138 */ 00139 void getSensorPose( CPose3D &out_sensorPose ) const { out_sensorPose = sensorPose; } 00140 00141 /** A general method to change the sensor pose on the robot. 00142 * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases. 00143 * \sa getSensorPose 00144 */ 00145 void setSensorPose( const CPose3D &newSensorPose ) { sensorPose = newSensorPose; } 00146 00147 /** A method to truncate the scan by defining a minimum and maximum valid distance 00148 */ 00149 void truncateByDistance(float min_distance, float max_distance); 00150 00151 /** 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"). 00152 * \sa C2DRangeFinderAbstract::loadExclusionAreas 00153 */ 00154 // void filterByExclusionAreas( const std::vector<mrpt::math::CPolygon> &areas ); 00155 00156 }; // End of class def. 00157 00158 00159 } // End of namespace 00160 00161 namespace utils 00162 { 00163 using namespace ::mrpt::slam; 00164 // Specialization must occur in the same namespace 00165 MRPT_DECLARE_TTYPENAME_PTR(CObservation3DRangeScan) 00166 } 00167 00168 } // End of namespace 00169 00170 #endif
Page generated by Doxygen 1.5.9 for MRPT 0.7.1 SVN: at Mon Aug 17 22:20:53 EDT 2009 |