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 CPOINTSMAP_H 00029 #define CPOINTSMAP_H 00030 00031 #include <mrpt/slam/CMetricMap.h> 00032 #include <mrpt/utils/CSerializable.h> 00033 #include <mrpt/math/CMatrix.h> 00034 #include <mrpt/utils/CLoadableOptions.h> 00035 #include <mrpt/utils/safe_pointers.h> 00036 00037 #include <mrpt/math/KDTreeCapable.h> 00038 00039 #include <mrpt/poses/CPoint2D.h> 00040 #include <mrpt/math/lightweight_geom_data.h> 00041 00042 #include <mrpt/maps/link_pragmas.h> 00043 00044 namespace mrpt 00045 { 00046 namespace slam 00047 { 00048 using namespace mrpt::poses; 00049 using namespace mrpt::math; 00050 00051 class CObservation2DRangeScan; 00052 class CSimplePointsMap; 00053 class CMultiMetricMap; 00054 class CColouredPointsMap; 00055 class COccupancyGridMap2D; 00056 00057 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CPointsMap , CMetricMap, MAPS_IMPEXP ) 00058 00059 /** A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors. 00060 * This is a virtual class, thus only a derived class can be instantiated by the user. The user most usually wants to use CSimplePointsMap. 00061 * \sa CMetricMap, CPoint, mrpt::utils::CSerializable 00062 */ 00063 class MAPS_IMPEXP CPointsMap : public CMetricMap, public mrpt::utils::KDTreeCapable 00064 { 00065 friend class CMultiMetricMap; 00066 friend class CMultiMetricMapPDF; 00067 friend class CSimplePointsMap; 00068 friend class CColouredPointsMap; 00069 friend class COccupancyGridMap2D; 00070 00071 // This must be added to any CSerializable derived class: 00072 DEFINE_VIRTUAL_SERIALIZABLE( CPointsMap ) 00073 00074 protected: 00075 /** The points coordinates 00076 */ 00077 std::vector<float> x,y,z; 00078 00079 /** The points weights 00080 */ 00081 std::vector<uint32_t> pointWeight; 00082 00083 /** Auxiliary variables used in "getLargestDistanceFromOrigin" 00084 * \sa getLargestDistanceFromOrigin 00085 */ 00086 mutable float m_largestDistanceFromOrigin; 00087 00088 /** Auxiliary variables used in "getLargestDistanceFromOrigin" 00089 * \sa getLargestDistanceFromOrigin 00090 */ 00091 mutable bool m_largestDistanceFromOriginIsUpdated; 00092 00093 void mark_as_modified() const; //!< Called only by this class or children classes, set m_largestDistanceFromOriginIsUpdated=false and such. 00094 00095 00096 00097 /** @name Virtual methods that MUST be implemented by children classes of KDTreeCapable 00098 @{ */ 00099 /** Must return the number of data points */ 00100 virtual size_t kdtree_get_point_count() const; 00101 00102 /** Must fill out the data points in "data", such as the i'th point will be stored in (data[i][0],...,data[i][nDims-1]). */ 00103 virtual void kdtree_fill_point_data(ANNpointArray &data, const int nDims) const; 00104 00105 /** @} */ 00106 00107 public: 00108 /** Constructor 00109 */ 00110 CPointsMap(); 00111 00112 /** Virtual destructor. 00113 */ 00114 virtual ~CPointsMap(); 00115 00116 00117 00118 /** Returns the square distance from the 2D point (x0,y0) to the closest correspondence in the map. 00119 */ 00120 virtual float squareDistanceToClosestCorrespondence( 00121 float x0, 00122 float y0 ) const; 00123 00124 inline float squareDistanceToClosestCorrespondenceT(const TPoint2D &p0) const { 00125 return squareDistanceToClosestCorrespondence(static_cast<float>(p0.x),static_cast<float>(p0.y)); 00126 } 00127 00128 00129 /** With this struct options are provided to the observation insertion process. 00130 * \sa CObservation::insertIntoPointsMap 00131 */ 00132 struct MAPS_IMPEXP TInsertionOptions : public utils::CLoadableOptions 00133 { 00134 /** Initilization of default parameters 00135 */ 00136 TInsertionOptions( ); 00137 virtual ~TInsertionOptions() {} 00138 00139 /** See utils::CLoadableOptions 00140 */ 00141 void loadFromConfigFile( 00142 const mrpt::utils::CConfigFileBase &source, 00143 const std::string §ion); 00144 00145 /** See utils::CLoadableOptions 00146 */ 00147 void dumpToTextStream(CStream &out) const; 00148 00149 00150 /** The minimum distance between points (in 3D): If two points are too close, one of them is not inserted into the map. Default is 0.02 meters. 00151 */ 00152 float minDistBetweenLaserPoints; 00153 00154 /** Applicable to "loadFromRangeScan" only! If set to false, the points from the scan are loaded, clearing all previous content. Default is false. 00155 */ 00156 bool addToExistingPointsMap; 00157 00158 /** If set to true, far points (<1m) are interpolated with samples at "minDistSqrBetweenLaserPoints" intervals (Default is false). 00159 */ 00160 bool also_interpolate; 00161 00162 /** If set to false (default=true) points in the same plane as the inserted scan and inside the free space, are erased: i.e. they don't exist yet. 00163 */ 00164 bool disableDeletion; 00165 00166 /** If set to true (default=false), inserted points are "fused" with previously existent ones. This shrink the size of the points map, but its slower. 00167 */ 00168 bool fuseWithExisting; 00169 00170 /** If set to true, only HORIZONTAL (in the XY plane) measurements will be inserted in the map (Default value is false, thus 3D maps are generated). 00171 * \sa horizontalTolerance 00172 */ 00173 bool isPlanarMap; 00174 00175 /** The tolerance in rads in pitch & roll for a laser scan to be considered horizontal, considered only when isPlanarMap=true (default=0). 00176 */ 00177 float horizontalTolerance; 00178 00179 /** The maximum distance between two points to interpolate between them (ONLY when also_interpolate=true) 00180 */ 00181 float maxDistForInterpolatePoints; 00182 00183 }; 00184 00185 TInsertionOptions insertionOptions; //!< The options used when inserting observations in the map 00186 00187 /** Options used when evaluating "computeObservationLikelihood" in the derived classes. 00188 * \sa CObservation::computeObservationLikelihood 00189 */ 00190 struct MAPS_IMPEXP TLikelihoodOptions: public utils::CLoadableOptions 00191 { 00192 /** Initilization of default parameters 00193 */ 00194 TLikelihoodOptions( ); 00195 virtual ~TLikelihoodOptions() {} 00196 00197 /** See utils::CLoadableOptions */ 00198 void loadFromConfigFile( 00199 const mrpt::utils::CConfigFileBase &source, 00200 const std::string §ion); 00201 00202 /** See utils::CLoadableOptions */ 00203 void dumpToTextStream(CStream &out) const; 00204 00205 void writeToStream(CStream &out) const; //!< Binary dump to stream - for usage in derived classes' serialization 00206 void readFromStream(CStream &in); //!< Binary dump to stream - for usage in derived classes' serialization 00207 00208 double sigma_dist; //!< Sigma (standard deviation, in meters) of the exponential used to model the likelihood (default= 0.5meters) 00209 double max_corr_distance; //!< Maximum distance in meters to consider for the numerator divided by "sigma_dist", so that each point has a minimum (but very small) likelihood to avoid underflows (default=1.0 meters) 00210 uint32_t decimation; //!< Speed up the likelihood computation by considering only one out of N rays (default=10) 00211 }; 00212 00213 TLikelihoodOptions likelihoodOptions; 00214 00215 /** Virtual assignment operator, to be implemented in derived classes. 00216 */ 00217 virtual void copyFrom(const CPointsMap &obj) = 0; 00218 00219 /** Insert the contents of another map into this one, fusing the previous content with the new one. 00220 * This means that points very close to existing ones will be "fused", rather than "added". This prevents 00221 * the unbounded increase in size of these class of maps. 00222 * NOTICE that "otherMap" is neither translated nor rotated here, so if this is desired it must done 00223 * before calling this method. 00224 * \param otherMap The other map whose points are to be inserted into this one. 00225 * \param minDistForFuse Minimum distance (in meters) between two points, each one in a map, to be considered the same one and be fused rather than added. 00226 * \param notFusedPoints If a pointer is supplied, this list will contain at output a list with a "bool" value per point in "this" map. This will be false/true according to that point having been fused or not. 00227 */ 00228 virtual void fuseWith( 00229 CPointsMap *otherMap, 00230 float minDistForFuse = 0.02f, 00231 std::vector<bool> *notFusedPoints = NULL) = 0; 00232 00233 /** Transform the range scan into a set of cartessian coordinated 00234 * points. The options in "insertionOptions" are considered in this method. 00235 * \param rangeScan The scan to be inserted into this map 00236 * \param robotPose The robot 3D pose, default to (0,0,0|0deg,0deg,0deg). It is used to compute the sensor pose relative to the robot actual pose. Recall sensor pose is embeded in the observation class. 00237 * 00238 * NOTE: Only ranges marked as "valid=true" in the observation will be inserted 00239 * 00240 * \sa CObservation2DRangeScan 00241 */ 00242 virtual void loadFromRangeScan( 00243 const CObservation2DRangeScan &rangeScan, 00244 const CPose3D *robotPose = NULL ) = 0; 00245 00246 /** Load from a text file. In each line there are a point coordinates. 00247 * Returns false if any error occured, true elsewere. 00248 */ 00249 virtual bool load2D_from_text_file(std::string file) = 0; 00250 00251 /** Load from a text file. In each line there are a point coordinates. 00252 * Returns false if any error occured, true elsewere. 00253 */ 00254 virtual bool load3D_from_text_file(std::string file) = 0; 00255 00256 /** Save to a text file. In each line there are a point coordinates. 00257 * Returns false if any error occured, true elsewere. 00258 */ 00259 bool save2D_to_text_file(const std::string &file) const; 00260 00261 /** Save to a text file. In each line there are a point coordinates. 00262 * Returns false if any error occured, true elsewere. 00263 */ 00264 bool save3D_to_text_file(const std::string &file)const; 00265 00266 /** This virtual method saves the map to a file "filNamePrefix"+< some_file_extension >, as an image or in any other applicable way (Notice that other methods to save the map may be implemented in classes implementing this virtual interface). 00267 */ 00268 void saveMetricMapRepresentationToFile( 00269 const std::string &filNamePrefix 00270 )const 00271 { 00272 std::string fil( filNamePrefix + std::string(".txt") ); 00273 save3D_to_text_file( fil ); 00274 } 00275 00276 00277 /** Returns the number of stored points in the map. 00278 */ 00279 size_t size() const; 00280 00281 /** Returns the number of stored points in the map (DEPRECATED, use "size()" instead better) 00282 */ 00283 size_t getPointsCount() const; 00284 00285 /** Access to a given point from map, as a 2D point. First index is 0. 00286 * \return The return value is the weight of the point (the times it has been fused) 00287 * \exception Throws std::exception on index out of bound. 00288 */ 00289 unsigned long getPoint(size_t index,CPoint2D &p) const; 00290 00291 /** Access to a given point from map, as a 3D point. First index is 0. 00292 * \return The return value is the weight of the point (the times it has been fused) 00293 * \exception Throws std::exception on index out of bound. 00294 */ 00295 unsigned long getPoint(size_t index,CPoint3D &p) const; 00296 00297 /** Access to a given point from map, as a 3D point. First index is 0. 00298 * \return The return value is the weight of the point (the times it has been fused) 00299 * \exception Throws std::exception on index out of bound. 00300 */ 00301 unsigned long getPoint(size_t index,mrpt::math::TPoint3D &p) const; 00302 00303 /** Access to a given point from map, as a 2D point. First index is 0. 00304 * \return The return value is the weight of the point (the times it has been fused) 00305 * \exception Throws std::exception on index out of bound. 00306 */ 00307 unsigned long getPoint(size_t index,mrpt::math::TPoint2D &p) const; 00308 00309 /** Access to a given point from map. First index is 0. 00310 * \return The return value is the weight of the point (the times it has been fused) 00311 * \exception Throws std::exception on index out of bound. 00312 */ 00313 unsigned long getPoint(size_t index,float &x,float &y) const; 00314 00315 /** Access to a given point from map. First index is 0. 00316 * \return The return value is the weight of the point (the times it has been fused) 00317 * \exception Throws std::exception on index out of bound. 00318 */ 00319 unsigned long getPoint(size_t index,float &x,float &y,float &z) const; 00320 00321 00322 /** Access to a given point from map, and its colors, if the map defines them (othersise, R=G=B=1.0). First index is 0. 00323 * \return The return value is the weight of the point (the times it has been fused) 00324 * \exception Throws std::exception on index out of bound. 00325 */ 00326 virtual void getPoint( size_t index, float &x, float &y, float &z, float &R, float &G, float &B ) const 00327 { 00328 getPoint(index,x,y,z); 00329 R=G=B=1; 00330 } 00331 00332 /** Returns true if the point map has a color field for each point */ 00333 virtual bool hasColorPoints() const { return false; } 00334 00335 /** Changes a given point from map, as a 2D point. First index is 0. 00336 * \exception Throws std::exception on index out of bound. 00337 */ 00338 virtual void setPoint(size_t index,CPoint2D &p)=0; 00339 00340 /** Changes a given point from map, as a 3D point. First index is 0. 00341 * \exception Throws std::exception on index out of bound. 00342 */ 00343 virtual void setPoint(size_t index,CPoint3D &p)=0; 00344 00345 /** Changes a given point from map. First index is 0. 00346 * \exception Throws std::exception on index out of bound. 00347 */ 00348 virtual void setPoint(size_t index,float x, float y)=0; 00349 00350 /** Changes a given point from map. First index is 0. 00351 * \exception Throws std::exception on index out of bound. 00352 */ 00353 virtual void setPoint(size_t index,float x, float y, float z)=0; 00354 00355 /** Provides a direct access to points buffer, or NULL if there is no points in the map. 00356 */ 00357 void getPointsBuffer( size_t &outPointsCount, const float *&xs, const float *&ys, const float *&zs ) const; 00358 00359 /** Provides a direct access to a read-only reference of the internal point buffer. \sa getAllPoints */ 00360 inline const std::vector<float> & getPointsBufferRef_x() const { return x; } 00361 /** Provides a direct access to a read-only reference of the internal point buffer. \sa getAllPoints */ 00362 inline const std::vector<float> & getPointsBufferRef_y() const { return y; } 00363 /** Provides a direct access to a read-only reference of the internal point buffer. \sa getAllPoints */ 00364 inline const std::vector<float> & getPointsBufferRef_z() const { return z; } 00365 00366 /** Returns a copy of the 2D/3D points as a std::vector of float coordinates. 00367 * If decimation is greater than 1, only 1 point out of that number will be saved in the output, effectively performing a subsampling of the points. 00368 * \sa getPointsBufferRef_x, getPointsBufferRef_y, getPointsBufferRef_z 00369 */ 00370 void getAllPoints( std::vector<float> &xs, std::vector<float> &ys,std::vector<float> &zs, size_t decimation = 1 ) const; 00371 00372 inline void getAllPoints(std::vector<TPoint3D> &ps,size_t decimation=1) const { 00373 std::vector<float> dmy1,dmy2,dmy3; 00374 getAllPoints(dmy1,dmy2,dmy3,decimation); 00375 ps.resize(dmy1.size()); 00376 for (size_t i=0;i<dmy1.size();i++) { 00377 ps[i].x=static_cast<double>(dmy1[i]); 00378 ps[i].y=static_cast<double>(dmy2[i]); 00379 ps[i].z=static_cast<double>(dmy3[i]); 00380 } 00381 } 00382 00383 /** Returns a copy of the 2D/3D points as a std::vector of float coordinates. 00384 * If decimation is greater than 1, only 1 point out of that number will be saved in the output, effectively performing a subsampling of the points. 00385 * \sa setAllPoints 00386 */ 00387 void getAllPoints( std::vector<float> &xs, std::vector<float> &ys, size_t decimation = 1 ) const; 00388 00389 inline void getAllPoints(std::vector<TPoint2D> &ps,size_t decimation=1) const { 00390 std::vector<float> dmy1,dmy2; 00391 getAllPoints(dmy1,dmy2,decimation); 00392 ps.resize(dmy1.size()); 00393 for (size_t i=0;i<dmy1.size();i++) { 00394 ps[i].x=static_cast<double>(dmy1[i]); 00395 ps[i].y=static_cast<double>(dmy2[i]); 00396 } 00397 } 00398 00399 /** Provides a way to insert individual points into the map */ 00400 virtual void insertPoint( float x, float y, float z = 0 ) = 0; 00401 00402 /** Provides a way to insert individual points into the map */ 00403 inline void insertPoint( const CPoint3D &p ) { 00404 insertPoint(p.x(),p.y(),p.z()); 00405 } 00406 00407 /** Provides a way to insert individual points into the map */ 00408 inline void insertPoint( const mrpt::math::TPoint3D &p ) { 00409 insertPoint(p.x,p.y,p.z); 00410 } 00411 00412 /** Reserves memory for a given number of points: the size of the map does not change, it only reserves the memory. 00413 * This is useful for situations where it is approximately known the final size of the map. This method is more 00414 * efficient than constantly increasing the size of the buffers. Refer to the STL C++ library's "reserve" methods. 00415 */ 00416 virtual void reserve(size_t newLength) = 0; 00417 00418 /** Set all the points at once from vectors with X,Y and Z coordinates. \sa getAllPoints */ 00419 virtual void setAllPoints(const vector_float &X,const vector_float &Y,const vector_float &Z) = 0; 00420 00421 /** Set all the points at once from vectors with X and Y coordinates (Z=0). \sa getAllPoints */ 00422 virtual void setAllPoints(const vector_float &X,const vector_float &Y) = 0; 00423 00424 /** Delete points out of the given "z" axis range have been removed. 00425 */ 00426 void clipOutOfRangeInZ(float zMin, float zMax); 00427 00428 /** Delete points which are more far than "maxRange" away from the given "point". 00429 */ 00430 void clipOutOfRange(const CPoint2D &point, float maxRange); 00431 00432 /** Remove from the map the points marked in a bool's array as "true". 00433 * 00434 * \exception std::exception If mask size is not equal to points count. 00435 */ 00436 virtual void applyDeletionMask( std::vector<bool> &mask ) = 0; 00437 00438 /** Computes the matchings between this and another 2D/3D points map. 00439 This includes finding: 00440 - The set of points pairs in each map 00441 - The mean squared distance between corresponding pairs. 00442 This method is the most time critical one into the ICP algorithm. 00443 00444 * \param otherMap [IN] The other map to compute the matching with. 00445 * \param otherMapPose [IN] The pose of the other map as seen from "this". 00446 * \param maxDistForCorrespondence [IN] Maximum 2D distance between two points to be matched. 00447 * \param maxAngularDistForCorrespondence [IN] Maximum angular distance in radians to allow far points to be matched. 00448 * \param angularDistPivotPoint [IN] The point from which to measure the "angular distances" 00449 * \param correspondences [OUT] The detected matchings pairs. 00450 * \param correspondencesRatio [OUT] The number of correct correspondences. 00451 * \param sumSqrDist [OUT] The sum of all matched points squared distances.If undesired, set to NULL, as default. 00452 * \param covariance [OUT] The resulting matching covariance 3x3 matrix, or NULL if undesired. 00453 * \param onlyKeepTheClosest [OUT] Returns only the closest correspondence (default=false) 00454 * 00455 * \sa computeMatching3DWith 00456 */ 00457 void computeMatchingWith2D( 00458 const CMetricMap *otherMap, 00459 const CPose2D &otherMapPose, 00460 float maxDistForCorrespondence, 00461 float maxAngularDistForCorrespondence, 00462 const CPose2D &angularDistPivotPoint, 00463 TMatchingPairList &correspondences, 00464 float &correspondencesRatio, 00465 float *sumSqrDist = NULL, 00466 bool onlyKeepTheClosest = false, 00467 bool onlyUniqueRobust = false ) const; 00468 00469 /** Computes the matchings between this and another 3D points map - method used in 3D-ICP. 00470 This method finds the set of point pairs in each map. 00471 00472 The method is the most time critical one into the ICP algorithm. 00473 00474 * \param otherMap [IN] The other map to compute the matching with. 00475 * \param otherMapPose [IN] The pose of the other map as seen from "this". 00476 * \param maxDistForCorrespondence [IN] Maximum 2D linear distance between two points to be matched. 00477 * \param maxAngularDistForCorrespondence [IN] In radians: The aim is to allow larger distances to more distant correspondences. 00478 * \param angularDistPivotPoint [IN] The point used to calculate distances from in both maps. 00479 * \param correspondences [OUT] The detected matchings pairs. 00480 * \param correspondencesRatio [OUT] The ratio [0,1] of points in otherMap with at least one correspondence. 00481 * \param sumSqrDist [OUT] The sum of all matched points squared distances.If undesired, set to NULL, as default. 00482 * \param onlyKeepTheClosest [IN] If set to true, only the closest correspondence will be returned. If false (default) all are returned. 00483 * 00484 * \sa compute3DMatchingRatio 00485 */ 00486 void computeMatchingWith3D( 00487 const CMetricMap *otherMap, 00488 const CPose3D &otherMapPose, 00489 float maxDistForCorrespondence, 00490 float maxAngularDistForCorrespondence, 00491 const CPoint3D &angularDistPivotPoint, 00492 TMatchingPairList &correspondences, 00493 float &correspondencesRatio, 00494 float *sumSqrDist = NULL, 00495 bool onlyKeepTheClosest = true, 00496 bool onlyUniqueRobust = false ) const; 00497 00498 00499 /** Replace each point \f$ p_i \f$ by \f$ p'_i = b \oplus p_i \f$ (pose compounding operator). 00500 */ 00501 void changeCoordinatesReference(const CPose2D &b); 00502 00503 /** Replace each point \f$ p_i \f$ by \f$ p'_i = b \oplus p_i \f$ (pose compounding operator). 00504 */ 00505 void changeCoordinatesReference(const CPose3D &b); 00506 00507 /** Copy all the points from "other" map to "this", replacing each point \f$ p_i \f$ by \f$ p'_i = b \oplus p_i \f$ (pose compounding operator). 00508 */ 00509 void changeCoordinatesReference(const CPointsMap &other, const CPose3D &b); 00510 00511 /** Returns true if the map is empty/no observation has been inserted. 00512 */ 00513 virtual bool isEmpty() const; 00514 00515 /** STL-like method to check whether the map is empty: */ 00516 inline bool empty() const { return isEmpty(); } 00517 00518 /** Returns a 3D object representing the map. 00519 * The color of the points is given by the static variables: COLOR_3DSCENE_R,COLOR_3DSCENE_G,COLOR_3DSCENE_B 00520 * \sa mrpt::global_settings::POINTSMAPS_3DOBJECT_POINTSIZE 00521 */ 00522 virtual void getAs3DObject ( mrpt::opengl::CSetOfObjectsPtr &outObj ) const; 00523 00524 00525 /** Computes the ratio in [0,1] of correspondences between "this" and the "otherMap" map, whose 6D pose relative to "this" is "otherMapPose" 00526 * In the case of a multi-metric map, this returns the average between the maps. This method always return 0 for grid maps. 00527 * \param otherMap [IN] The other map to compute the matching with. 00528 * \param otherMapPose [IN] The 6D pose of the other map as seen from "this". 00529 * \param minDistForCorr [IN] The minimum distance between 2 non-probabilistic map elements for counting them as a correspondence. 00530 * \param minMahaDistForCorr [IN] The minimum Mahalanobis distance between 2 probabilistic map elements for counting them as a correspondence. 00531 * 00532 * \return The matching ratio [0,1] 00533 * \sa computeMatchingWith2D 00534 */ 00535 float compute3DMatchingRatio( 00536 const CMetricMap *otherMap, 00537 const CPose3D &otherMapPose, 00538 float minDistForCorr = 0.10f, 00539 float minMahaDistForCorr = 2.0f 00540 ) const; 00541 00542 /** This method returns the largest distance from the origin to any of the points, such as a sphere centered at the origin with this radius cover ALL the points in the map (the results are buffered, such as, if the map is not modified, the second call will be much faster than the first one). 00543 */ 00544 float getLargestDistanceFromOrigin() const; 00545 00546 /** Computes the bounding box of all the points, or (0,0 ,0,0, 0,0) if there are no points. */ 00547 void boundingBox( float &min_x,float &max_x,float &min_y,float &max_y,float &min_z,float &max_z ) const; 00548 00549 inline void boundingBox(TPoint3D &pMin,TPoint3D &pMax) const { 00550 float dmy1,dmy2,dmy3,dmy4,dmy5,dmy6; 00551 boundingBox(dmy1,dmy2,dmy3,dmy4,dmy5,dmy6); 00552 pMin.x=dmy1; 00553 pMin.y=dmy2; 00554 pMin.z=dmy3; 00555 pMax.x=dmy4; 00556 pMax.y=dmy5; 00557 pMax.z=dmy6; 00558 } 00559 00560 void extractCylinder( const CPoint2D ¢er, const double radius, const double zmin, const double zmax, CPointsMap *outMap ); 00561 00562 00563 /** The color [0,1] of points when extracted from getAs3DObject (default=blue) */ 00564 static float COLOR_3DSCENE_R; 00565 static float COLOR_3DSCENE_G; 00566 static float COLOR_3DSCENE_B; 00567 00568 00569 /** Computes the likelihood of taking a given observation from a given pose in the world being modeled with this map. 00570 * \param takenFrom The robot's pose the observation is supposed to be taken from. 00571 * \param obs The observation. 00572 * \return This method returns a likelihood in the range [0,1]. 00573 * 00574 * \sa Used in particle filter algorithms, see: CMultiMetricMapPDF 00575 * \note In CPointsMap this method is virtual so it can be redefined in derived classes, if desired. 00576 */ 00577 virtual double computeObservationLikelihood( const CObservation *obs, const CPose3D &takenFrom ); 00578 00579 }; // End of class def. 00580 00581 } // End of namespace 00582 00583 namespace global_settings 00584 { 00585 /** The size of points when exporting with getAs3DObject() (default=3.0) 00586 * Affects to: 00587 * - mrpt::slam::CPointsMap and all its children classes. 00588 */ 00589 extern MAPS_IMPEXP float POINTSMAPS_3DOBJECT_POINTSIZE; 00590 } 00591 } // End of namespace 00592 00593 #endif
| Page generated by Doxygen 1.7.1 for MRPT 0.9.1 SVN:exported at Fri Aug 6 10:31:35 UTC 2010 |
