00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://www.mrpt.org/ | 00005 | | 00006 | Copyright (C) 2005-2011 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 CICP_H 00029 #define CICP_H 00030 00031 #include <mrpt/slam/CMetricMapsAlignmentAlgorithm.h> 00032 #include <mrpt/utils/CLoadableOptions.h> 00033 00034 namespace mrpt 00035 { 00036 namespace slam 00037 { 00038 using namespace poses; 00039 00040 /** The ICP algorithm selection, used in mrpt::slam::CICP::options. 00041 * For details on the algorithms refer to http://www.mrpt.org/Scan_Matching_Algorithms 00042 * \ingroup mrpt_slam_grp 00043 */ 00044 enum TICPAlgorithm 00045 { 00046 icpClassic = 0, 00047 icpLevenbergMarquardt, 00048 icpIKF 00049 }; 00050 00051 /** Several implementations of ICP (Iterative closest point) algorithms for aligning two point maps. 00052 * 00053 * See CICP::AlignPDF for the entry point of the algorithm, and CICP::TConfigParams for all the parameters to the method. 00054 * The algorithm has been exteneded with multihypotheses-support for the correspondences, which generates a Sum-of-Gaussians (SOG) 00055 * PDF as output. See scanmatching::robustRigidTransformation. 00056 * 00057 * For further details on the method, check the wiki: 00058 * http://www.mrpt.org/Scan_Matching_Algorithms 00059 * 00060 * For a paper explaining the used equations, see for example: 00061 * J. Martinez, J. Gonzalez, J. Morales, A. Mandow, A. Garcia-Cerezo, 00062 * "Genetic and ICP Laser Point Matching for 2D Mobile Robot Motion Estimation", 00063 * Journal of Field Robotics, vol. 23, no. 1, 2006. ( http://babel.isa.uma.es/~jlblanco/papers/martinez2006gil.pdf ) 00064 * 00065 * \sa CMetricMapsAlignmentAlgorithm 00066 * \ingroup mrpt_slam_grp 00067 */ 00068 class SLAM_IMPEXP CICP : public CMetricMapsAlignmentAlgorithm 00069 { 00070 public: 00071 /** The ICP algorithm configuration data 00072 */ 00073 class SLAM_IMPEXP TConfigParams : public utils::CLoadableOptions 00074 { 00075 public: 00076 TConfigParams(); //!< Initializer for default values: 00077 00078 void loadFromConfigFile( 00079 const mrpt::utils::CConfigFileBase &source, 00080 const std::string §ion); //!< See utils::CLoadableOptions 00081 00082 void dumpToTextStream(CStream &out) const; //!<See utils::CLoadableOptions 00083 00084 00085 /** The algorithm to use (default: icpClassic) 00086 * See http://www.mrpt.org/Scan_Matching_Algorithms for details. 00087 */ 00088 TICPAlgorithm ICP_algorithm; 00089 00090 bool onlyClosestCorrespondences; //!< The usual approach: to consider only the closest correspondence for each local point (Default to true) 00091 bool onlyUniqueRobust; //! Apart of "onlyClosestCorrespondences=true", if this option is enabled only the closest correspondence for each reference point will be kept (default=false). 00092 00093 /** @name Termination criteria 00094 @{ */ 00095 unsigned int maxIterations; //!< Maximum number of iterations to run. 00096 float minAbsStep_trans; //!< If the correction in all translation coordinates (X,Y,Z) is below this threshold (in meters), iterations are terminated (Default:1e-6) 00097 float minAbsStep_rot; //!< If the correction in all rotation coordinates (yaw,pitch,roll) is below this threshold (in radians), iterations are terminated (Default:1e-6) 00098 /** @} */ 00099 00100 float thresholdDist,thresholdAng; //!< Initial threshold distance for two points to become a correspondence. 00101 float ALFA; //!< The scale factor for threshold everytime convergence is achieved. 00102 float smallestThresholdDist; //!< The size for threshold such that iterations will stop, since it is considered precise enough. 00103 00104 /** This is the normalization constant \f$ \sigma^2_p \f$ that is used to scale the whole 3x3 covariance. 00105 * This has a default value of \f$ (0.02)^2 \f$, that is, a 2cm sigma. 00106 * See the paper: .... 00107 */ 00108 float covariance_varPoints; 00109 00110 bool doRANSAC; //!< Perform a RANSAC step after the ICP convergence, to obtain a better estimation of the pose PDF. 00111 00112 /** RANSAC-step options: 00113 * \sa CICP::robustRigidTransformation 00114 */ 00115 unsigned int ransac_minSetSize,ransac_maxSetSize,ransac_nSimulations; 00116 00117 /** RANSAC-step options: 00118 * \sa CICP::robustRigidTransformation 00119 */ 00120 float ransac_mahalanobisDistanceThreshold; 00121 00122 /** RANSAC-step option: The standard deviation in X,Y of landmarks/points which are being matched (used to compute covariances in the SoG) 00123 * \sa CICP::robustRigidTransformation 00124 */ 00125 float normalizationStd; 00126 00127 /** RANSAC-step options: 00128 * \sa CICP::robustRigidTransformation 00129 */ 00130 bool ransac_fuseByCorrsMatch; 00131 00132 /** RANSAC-step options: 00133 * \sa CICP::robustRigidTransformation 00134 */ 00135 float ransac_fuseMaxDiffXY, ransac_fuseMaxDiffPhi; 00136 00137 /** Cauchy kernel rho, for estimating the optimal transformation covariance, in meters (default = 0.07m). */ 00138 float kernel_rho; 00139 00140 /** Whether to use kernel_rho to smooth distances, or use distances directly (default=true) */ 00141 bool use_kernel; 00142 00143 /** The size of the perturbance in x & y used to estimate the Jacobians of the square error (in LM & IKF methods, default=0.05).*/ 00144 float Axy_aprox_derivatives; 00145 00146 /** The initial value of the lambda parameter in the LM method (default=1e-4). */ 00147 float LM_initial_lambda; 00148 00149 /** Skip the computation of the covariance (saves some time) (default=false) */ 00150 bool skip_cov_calculation; 00151 00152 /** Decimation of the point cloud being registered against the reference one (default=5) - set to 1 to have the older (MRPT <0.9.5) behavior 00153 * of not approximating ICP by ignoring the correspondence of some points. The speed-up comes from a decimation of the number of KD-tree queries, 00154 * the most expensive step in ICP. 00155 */ 00156 uint32_t corresponding_points_decimation; 00157 00158 }; 00159 00160 TConfigParams options; //!< The options employed by the ICP align. 00161 00162 00163 /** Constructor with the default options */ 00164 CICP() : options() { } 00165 /** Constructor that directly set the ICP params from a given struct \sa options */ 00166 CICP(const TConfigParams &icpParams) : options(icpParams) { } 00167 00168 virtual ~CICP() { } //!< Destructor 00169 00170 00171 /** The ICP algorithm return information. 00172 */ 00173 struct SLAM_IMPEXP TReturnInfo 00174 { 00175 TReturnInfo() : 00176 cbSize(sizeof(TReturnInfo)), 00177 nIterations(0), 00178 goodness(0), 00179 quality(0) 00180 { 00181 } 00182 00183 /** Size in bytes of this struct: Must be set correctly before using it */ 00184 unsigned int cbSize; 00185 00186 /** The number of executed iterations until convergence. 00187 */ 00188 unsigned short nIterations; 00189 00190 /** A goodness measure for the alignment, it is a [0,1] range indicator of percentage of correspondences. 00191 */ 00192 float goodness; 00193 00194 /** A measure of the 'quality' of the local minimum of the sqr. error found by the method. 00195 * Higher values are better. Low values will be found in ill-conditioned situations (e.g. a corridor). 00196 */ 00197 float quality; 00198 }; 00199 00200 /** An implementation of CMetricMapsAlignmentAlgorithm for the case of a point maps and a occupancy grid/point map. 00201 * 00202 * This method computes the PDF of the displacement (relative pose) between 00203 * two maps: <b>the relative pose of m2 with respect to m1</b>. This pose 00204 * is returned as a PDF rather than a single value. 00205 * 00206 * \note This method can be configurated with "CICP::options" 00207 * \note The output PDF is a CPosePDFGaussian if "doRANSAC=false", or a CPosePDFSOG otherwise. 00208 * 00209 * \param m1 [IN] The first map (CAN BE A mrpt::poses::CPointsMap derived class or a mrpt::slam::COccupancyGrid2D class) 00210 * \param m2 [IN] The second map. (MUST BE A mrpt::poses::CPointsMap derived class)The pose of this map respect to m1 is to be estimated. 00211 * \param initialEstimationPDF [IN] An initial gross estimation for the displacement. 00212 * \param runningTime [OUT] A pointer to a container for obtaining the algorithm running time in seconds, or NULL if you don't need it. 00213 * \param info [OUT] A pointer to a CICP::TReturnInfo, or NULL if it isn't needed. 00214 * 00215 * \return A smart pointer to the output estimated pose PDF. 00216 * 00217 * \sa CMetricMapsAlignmentAlgorithm, CICP::options, CICP::TReturnInfo 00218 */ 00219 CPosePDFPtr AlignPDF( 00220 const CMetricMap *m1, 00221 const CMetricMap *m2, 00222 const CPosePDFGaussian &initialEstimationPDF, 00223 float *runningTime = NULL, 00224 void *info = NULL ); 00225 00226 /** Align a pair of metric maps, aligning the full 6D pose. 00227 * The meaning of some parameters are implementation dependant, 00228 * so look at the derived classes for more details. 00229 * The goal is to find a PDF for the pose displacement between 00230 * maps, that is, <b>the pose of m2 relative to m1</b>. This pose 00231 * is returned as a PDF rather than a single value. 00232 * 00233 * \note This method can be configurated with a "options" structure in the implementation classes. 00234 * 00235 * \param m1 [IN] The first map (MUST BE A COccupancyGridMap2D derived class) 00236 * \param m2 [IN] The second map. (MUST BE A CPointsMap derived class) The pose of this map respect to m1 is to be estimated. 00237 * \param initialEstimationPDF [IN] An initial gross estimation for the displacement. 00238 * \param runningTime [OUT] A pointer to a container for obtaining the algorithm running time in seconds, or NULL if you don't need it. 00239 * \param info [OUT] See derived classes for details, or NULL if it isn't needed. 00240 * 00241 * \return A smart pointer to the output estimated pose PDF. 00242 * \sa CICP 00243 */ 00244 CPose3DPDFPtr Align3DPDF( 00245 const CMetricMap *m1, 00246 const CMetricMap *m2, 00247 const CPose3DPDFGaussian &initialEstimationPDF, 00248 float *runningTime = NULL, 00249 void *info = NULL ); 00250 00251 00252 protected: 00253 /** Computes: 00254 * \f[ K(x^2) = \frac{x^2}{x^2+\rho^2} \f] 00255 * or just return the input if options.useKernel = false. 00256 */ 00257 float kernel(const float &x2, const float &rho2); 00258 00259 /** The internal method implementing CICP::AlignPDF when options.ICP_algorithm is icpClassic. 00260 */ 00261 CPosePDFPtr ICP_Method_Classic( 00262 const CMetricMap *m1, 00263 const CMetricMap *m2, 00264 const CPosePDFGaussian &initialEstimationPDF, 00265 TReturnInfo &outInfo ); 00266 00267 /** The internal method implementing CICP::AlignPDF when options.ICP_algorithm is icpLevenbergMarquardt. 00268 */ 00269 CPosePDFPtr ICP_Method_LM( 00270 const CMetricMap *m1, 00271 const CMetricMap *m2, 00272 const CPosePDFGaussian &initialEstimationPDF, 00273 TReturnInfo &outInfo ); 00274 00275 /** The internal method implementing CICP::AlignPDF when options.ICP_algorithm is icpIKF. 00276 */ 00277 CPosePDFPtr ICP_Method_IKF( 00278 const CMetricMap *m1, 00279 const CMetricMap *m2, 00280 const CPosePDFGaussian &initialEstimationPDF, 00281 TReturnInfo &outInfo ); 00282 00283 /** The internal method implementing CICP::Align3DPDF when options.ICP_algorithm is icpClassic. 00284 */ 00285 CPose3DPDFPtr ICP3D_Method_Classic( 00286 const CMetricMap *m1, 00287 const CMetricMap *m2, 00288 const CPose3DPDFGaussian &initialEstimationPDF, 00289 TReturnInfo &outInfo ); 00290 00291 00292 }; 00293 00294 } // End of namespace 00295 } // End of namespace 00296 00297 #endif
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Sun Oct 16 12:16:33 UTC 2011 |