Main MRPT website > C++ reference for MRPT 1.5.9
CICP.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef CICP_H
10 #define CICP_H
11 
14 #include <mrpt/utils/TEnumType.h>
15 
16 namespace mrpt
17 {
18  namespace slam
19  {
20  /** The ICP algorithm selection, used in mrpt::slam::CICP::options \ingroup mrpt_slam_grp */
24  };
25 
26  /** ICP covariance estimation methods, used in mrpt::slam::CICP::options \ingroup mrpt_slam_grp */
28  icpCovLinealMSE = 0, //!< Use the covariance of the optimal registration, disregarding uncertainty in data association
29  icpCovFiniteDifferences //!< Covariance of a least-squares optimizer (includes data association uncertainty)
30  };
31 
32  /** Several implementations of ICP (Iterative closest point) algorithms for aligning two point maps or a point map wrt a grid map.
33  *
34  * CICP::AlignPDF() or CICP::Align() are the two main entry points of the algorithm.
35  *
36  * To choose among existing ICP algorithms or customizing their parameters, see CICP::TConfigParams and the member \a options.
37  *
38  * There exists an extension of the original ICP algorithm that provides multihypotheses-support for the correspondences, and which generates a Sum-of-Gaussians (SOG)
39  * PDF as output. See mrpt::tfest::se2_l2_robust()
40  *
41  * For further details on the implemented methods, check the web:
42  * http://www.mrpt.org/Iterative_Closest_Point_(ICP)_and_other_matching_algorithms
43  *
44  * For a paper explaining some of the basic equations, see for example:
45  * J. Martinez, J. Gonzalez, J. Morales, A. Mandow, A. Garcia-Cerezo,
46  * "Mobile robot motion estimation by 2D scan matching with genetic and iterative closest point algorithms",
47  * Journal of Field Robotics, vol. 23, no. 1, pp. 21-34, 2006. ( http://babel.isa.uma.es/~jlblanco/papers/martinez2006gil.pdf )
48  *
49  * \sa CMetricMapsAlignmentAlgorithm
50  * \ingroup mrpt_slam_grp
51  */
53  {
54  public:
55  /** The ICP algorithm configuration data
56  */
58  {
59  public:
60  TConfigParams(); //!< Initializer for default values:
61 
62  void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source,const std::string &section) MRPT_OVERRIDE; // See base docs
63  void dumpToTextStream(mrpt::utils::CStream &out) const MRPT_OVERRIDE; // See base docs
64 
65  /** @name Algorithms selection
66  @{ */
67  TICPAlgorithm ICP_algorithm; //!< The algorithm to use (default: icpClassic). See http://www.mrpt.org/tutorials/programming/scan-matching-and-icp/ for details
68  TICPCovarianceMethod ICP_covariance_method; //!< The method to use for covariance estimation (Default: icpCovFiniteDifferences)
69  /** @} */
70 
71  /** @name Correspondence-finding criteria
72  @{ */
73  bool onlyClosestCorrespondences; //!< The usual approach: to consider only the closest correspondence for each local point (Default to true)
74  bool onlyUniqueRobust; //! Apart of "onlyClosestCorrespondences=true", if this option is enabled only the closest correspondence for each reference point will be kept (default=false).
75  /** @} */
76 
77  /** @name Termination criteria
78  @{ */
79  unsigned int maxIterations; //!< Maximum number of iterations to run.
80  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)
81  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)
82  /** @} */
83 
84  float thresholdDist,thresholdAng; //!< Initial threshold distance for two points to become a correspondence.
85  float ALFA; //!< The scale factor for threshold everytime convergence is achieved.
86  float smallestThresholdDist; //!< The size for threshold such that iterations will stop, since it is considered precise enough.
87 
88  /** This is the normalization constant \f$ \sigma^2_p \f$ that is used to scale the whole 3x3 covariance.
89  * This has a default value of \f$ (0.02)^2 \f$, that is, a 2cm sigma.
90  * See paper: J.L. Blanco, J. Gonzalez-Jimenez, J.A. Fernandez-Madrigal, "A Robust, Multi-Hypothesis Approach to Matching Occupancy Grid Maps", Robotica, vol. 31, no. 5, pp. 687-701, 2013.
91  */
93 
94  bool doRANSAC; //!< Perform a RANSAC step, mrpt::tfest::se2_l2_robust(), after the ICP convergence, to obtain a better estimation of the pose PDF.
95 
96  /** @name RANSAC-step options for mrpt::tfest::se2_l2_robust() if \a doRANSAC=true
97  * @{ */
98  unsigned int ransac_minSetSize,ransac_maxSetSize,ransac_nSimulations;
100  float normalizationStd; //!< RANSAC-step option: The standard deviation in X,Y of landmarks/points which are being matched (used to compute covariances in the SoG)
102  float ransac_fuseMaxDiffXY, ransac_fuseMaxDiffPhi;
103  /** @} */
104 
105  float kernel_rho; //!< Cauchy kernel rho, for estimating the optimal transformation covariance, in meters (default = 0.07m)
106  bool use_kernel; //!< Whether to use kernel_rho to smooth distances, or use distances directly (default=true)
107  float Axy_aprox_derivatives; //!< [LM method only] The size of the perturbance in x & y used to estimate the Jacobians of the square error (default=0.05)
108  float LM_initial_lambda; //!< [LM method only] The initial value of the lambda parameter in the LM method (default=1e-4)
109 
110  bool skip_cov_calculation; //!< Skip the computation of the covariance (saves some time) (default=false)
111  bool skip_quality_calculation; //!< Skip the (sometimes) expensive evaluation of the term 'quality' at ICP output (Default=true)
112 
113  /** 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
114  * 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,
115  * the most expensive step in ICP */
117  };
118 
119  TConfigParams options; //!< The options employed by the ICP align.
120 
121  /** Constructor with the default options */
122  CICP() : options() { }
123  /** Constructor that directly set the ICP params from a given struct \sa options */
124  CICP(const TConfigParams &icpParams) : options(icpParams) { }
125  virtual ~CICP() { } //!< Destructor
126 
127  /** The ICP algorithm return information*/
129  {
131  nIterations(0),
132  goodness(0),
133  quality(0)
134  {
135  }
136  unsigned short nIterations; //!< The number of executed iterations until convergence
137  float goodness; //!< A goodness measure for the alignment, it is a [0,1] range indicator of percentage of correspondences.
138  float quality; //!< A measure of the 'quality' of the local minimum of the sqr. error found by the method. Higher values are better. Low values will be found in ill-conditioned situations (e.g. a corridor)
139  };
140 
141  /** An implementation of CMetricMapsAlignmentAlgorithm for the case of a point maps and a occupancy grid/point map.
142  *
143  * This method computes the PDF of the displacement (relative pose) between
144  * two maps: <b>the relative pose of m2 with respect to m1</b>. This pose
145  * is returned as a PDF rather than a single value.
146  *
147  * \note This method can be configurated with "CICP::options"
148  * \note The output PDF is a CPosePDFGaussian if "doRANSAC=false", or a CPosePDFSOG otherwise.
149  *
150  * \param m1 [IN] The first map (CAN BE A mrpt::poses::CPointsMap derived class or a mrpt::slam::COccupancyGrid2D class)
151  * \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.
152  * \param initialEstimationPDF [IN] An initial gross estimation for the displacement.
153  * \param runningTime [OUT] A pointer to a container for obtaining the algorithm running time in seconds, or NULL if you don't need it.
154  * \param info [OUT] A pointer to a CICP::TReturnInfo, or NULL if it isn't needed.
155  *
156  * \return A smart pointer to the output estimated pose PDF.
157  *
158  * \sa CMetricMapsAlignmentAlgorithm, CICP::options, CICP::TReturnInfo
159  */
160  mrpt::poses::CPosePDFPtr AlignPDF(
161  const mrpt::maps::CMetricMap *m1,
162  const mrpt::maps::CMetricMap *m2,
163  const mrpt::poses::CPosePDFGaussian &initialEstimationPDF,
164  float *runningTime = NULL,
165  void *info = NULL );
166 
167  // See base class for docs
168  mrpt::poses::CPose3DPDFPtr Align3DPDF(
169  const mrpt::maps::CMetricMap *m1,
170  const mrpt::maps::CMetricMap *m2,
171  const mrpt::poses::CPose3DPDFGaussian &initialEstimationPDF,
172  float *runningTime = NULL,
173  void *info = NULL );
174 
175 
176  protected:
177  /** Computes:
178  * \f[ K(x^2) = \frac{x^2}{x^2+\rho^2} \f]
179  * or just return the input if options.useKernel = false.
180  */
181  float kernel(const float &x2, const float &rho2);
182 
183  mrpt::poses::CPosePDFPtr ICP_Method_Classic(
184  const mrpt::maps::CMetricMap *m1,
185  const mrpt::maps::CMetricMap *m2,
186  const mrpt::poses::CPosePDFGaussian &initialEstimationPDF,
187  TReturnInfo &outInfo );
188  mrpt::poses::CPosePDFPtr ICP_Method_LM(
189  const mrpt::maps::CMetricMap *m1,
190  const mrpt::maps::CMetricMap *m2,
191  const mrpt::poses::CPosePDFGaussian &initialEstimationPDF,
192  TReturnInfo &outInfo );
193  mrpt::poses::CPose3DPDFPtr ICP3D_Method_Classic(
194  const mrpt::maps::CMetricMap *m1,
195  const mrpt::maps::CMetricMap *m2,
196  const mrpt::poses::CPose3DPDFGaussian &initialEstimationPDF,
197  TReturnInfo &outInfo );
198  };
199  } // End of namespace
200 
201  // Specializations MUST occur at the same namespace:
202  namespace utils
203  {
204  template <>
206  {
208  static void fill(bimap<enum_t,std::string> &m_map)
209  {
210  m_map.insert(slam::icpClassic, "icpClassic");
211  m_map.insert(slam::icpLevenbergMarquardt, "icpLevenbergMarquardt");
212  }
213  };
214  template <>
216  {
218  static void fill(bimap<enum_t,std::string> &m_map)
219  {
220  m_map.insert(slam::icpCovLinealMSE, "icpCovLinealMSE");
221  m_map.insert(slam::icpCovFiniteDifferences, "icpCovFiniteDifferences");
222  }
223  };
224  } // End of namespace
225 } // End of namespace
226 
227 #endif
Use the covariance of the optimal registration, disregarding uncertainty in data association.
Definition: CICP.h:28
float quality
A measure of the &#39;quality&#39; of the local minimum of the sqr. error found by the method. Higher values are better. Low values will be found in ill-conditioned situations (e.g. a corridor)
Definition: CICP.h:138
The ICP algorithm configuration data.
Definition: CICP.h:57
float ransac_mahalanobisDistanceThreshold
Definition: CICP.h:99
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
TICPAlgorithm ICP_algorithm
The algorithm to use (default: icpClassic). See http://www.mrpt.org/tutorials/programming/scan-matchi...
Definition: CICP.h:67
Several implementations of ICP (Iterative closest point) algorithms for aligning two point maps or a ...
Definition: CICP.h:52
static void fill(bimap< enum_t, std::string > &m_map)
Definition: CICP.h:208
bool skip_quality_calculation
Skip the (sometimes) expensive evaluation of the term &#39;quality&#39; at ICP output (Default=true) ...
Definition: CICP.h:111
Only specializations of this class are defined for each enum type of interest.
Definition: TEnumType.h:23
unsigned int ransac_nSimulations
Definition: CICP.h:98
float ALFA
The scale factor for threshold everytime convergence is achieved.
Definition: CICP.h:85
TConfigParams options
The options employed by the ICP align.
Definition: CICP.h:119
float kernel_rho
Cauchy kernel rho, for estimating the optimal transformation covariance, in meters (default = 0...
Definition: CICP.h:105
float minAbsStep_rot
If the correction in all rotation coordinates (yaw,pitch,roll) is below this threshold (in radians)...
Definition: CICP.h:81
uint32_t corresponding_points_decimation
Decimation of the point cloud being registered against the reference one (default=5) - set to 1 to ha...
Definition: CICP.h:116
This class allows loading and storing values and vectors of different types from a configuration text...
float goodness
A goodness measure for the alignment, it is a [0,1] range indicator of percentage of correspondences...
Definition: CICP.h:137
int quality
Definition: mrpt_jpeglib.h:916
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
static void fill(bimap< enum_t, std::string > &m_map)
Definition: CICP.h:218
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
unsigned int maxIterations
Maximum number of iterations to run.
Definition: CICP.h:79
A bidirectional version of std::map, declared as bimap<KEY,VALUE> and which actually contains two std...
Definition: bimap.h:28
float covariance_varPoints
This is the normalization constant that is used to scale the whole 3x3 covariance.
Definition: CICP.h:92
TICPCovarianceMethod ICP_covariance_method
The method to use for covariance estimation (Default: icpCovFiniteDifferences)
Definition: CICP.h:68
bool doRANSAC
Perform a RANSAC step, mrpt::tfest::se2_l2_robust(), after the ICP convergence, to obtain a better es...
Definition: CICP.h:94
CICP(const TConfigParams &icpParams)
Constructor that directly set the ICP params from a given struct.
Definition: CICP.h:124
TICPAlgorithm
The ICP algorithm selection, used in mrpt::slam::CICP::options.
Definition: CICP.h:21
bool onlyClosestCorrespondences
The usual approach: to consider only the closest correspondence for each local point (Default to true...
Definition: CICP.h:73
unsigned short nIterations
The number of executed iterations until convergence.
Definition: CICP.h:136
bool use_kernel
Whether to use kernel_rho to smooth distances, or use distances directly (default=true) ...
Definition: CICP.h:106
GLsizei const GLchar ** string
Definition: glext.h:3919
CICP()
Constructor with the default options.
Definition: CICP.h:122
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool skip_cov_calculation
Skip the computation of the covariance (saves some time) (default=false)
Definition: CICP.h:110
Declares a virtual base class for all metric maps storage classes.
A base class for any algorithm able of maps alignment.
float smallestThresholdDist
The size for threshold such that iterations will stop, since it is considered precise enough...
Definition: CICP.h:86
backing_store_ptr info
Definition: jmemsys.h:170
The ICP algorithm return information.
Definition: CICP.h:128
GLsizei GLsizei GLchar * source
Definition: glext.h:3908
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
virtual ~CICP()
Destructor.
Definition: CICP.h:125
float LM_initial_lambda
[LM method only] The initial value of the lambda parameter in the LM method (default=1e-4) ...
Definition: CICP.h:108
float normalizationStd
RANSAC-step option: The standard deviation in X,Y of landmarks/points which are being matched (used t...
Definition: CICP.h:100
float minAbsStep_trans
If the correction in all translation coordinates (X,Y,Z) is below this threshold (in meters)...
Definition: CICP.h:80
void insert(const KEY &k, const VALUE &v)
Insert a new pair KEY<->VALUE in the bi-map.
Definition: bimap.h:69
TICPCovarianceMethod
ICP covariance estimation methods, used in mrpt::slam::CICP::options.
Definition: CICP.h:27
unsigned __int32 uint32_t
Definition: rptypes.h:49
float Axy_aprox_derivatives
[LM method only] The size of the perturbance in x & y used to estimate the Jacobians of the square er...
Definition: CICP.h:107
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
Covariance of a least-squares optimizer (includes data association uncertainty)
Definition: CICP.h:29



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020