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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019