Main MRPT website > C++ reference
MRPT logo
scan_matching.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-2014, 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 ScanMatching_H
10 #define ScanMatching_H
11 
12 #include <mrpt/utils/utils_defs.h>
13 #include <mrpt/math/math_frwds.h>
17 #include <mrpt/poses/poses_frwds.h>
18 
19 namespace mrpt
20 {
21  /** A set of scan matching-related static functions.
22  * \sa mrpt::slam::CICP
23  * \ingroup mrpt_scanmatching_grp
24  */
25  namespace scanmatching
26  {
27  using namespace mrpt::poses;
28  using namespace mrpt::math;
29  using namespace mrpt::utils;
30 
31  /** \addtogroup mrpt_scanmatching_grp
32  * @{ */
33 
34  /** This function implements the Horn method for computing the change in pose between two coordinate systems
35  * \param[in] inPoints A vector containing the coordinates of the input points in the format:
36  * [x11 y11 z11, x12 y12 z12, x21 y21 z21, x22 y22 z22, x31 y31 z31, x32 y32 z32, ... ]
37  * where [xi1 yi1 zi1] and [xi2 yi2 zi2] represent the i-th pair of corresponding 3D points in the two coordinate systems "1" and "2"
38  * \param[out] outQuat A 7D vector containing the traslation and rotation (in a quaternion form) which indicates the change in pose of system "2" wrt "1".
39  * \param[in] forceScaleToUnity Whether or not force the scale employed to rotate the coordinate systems to one (rigid transformation)
40  *
41  * \return The computed scale of the optimal transformation (will be 1.0 for a perfectly rigid translation + rotation).
42  * \sa THornMethodOpts
43  */
45  const std::vector<double> &inPoints,
46  std::vector<double> &outQuat,
47  bool forceScaleToUnity = false );
48 
49  //! \overload
51  const std::vector<double> &inPoints,
52  mrpt::poses::CPose3DQuat &outQuat,
53  bool forceScaleToUnity = false);
54 
55  /** This method provides the closed-form solution of absolute orientation using unit quaternions to a set of over-constrained correspondences for finding the 6D rigid transformation between two cloud of 3D points.
56  * The output 3D pose is computed using the method described in "Closed-form solution of absolute orientation using unit quaternions", BKP Horn, Journal of the Optical Society of America, 1987.
57  *
58  * \param in_correspondences The set of correspondences in TMatchingPairList form ("this" and "other").
59  * \param out_transformation The change in pose (CPose3DQuat) of the "other" reference system wrt "this" reference system which minimizes the mean-square-error between all the correspondences.
60  * \exception Raises a std::exception if the list "in_correspondences" has not a minimum of three correspondences.
61  * \return True if there are at least three correspondences, or false otherwise, thus we cannot establish any correspondence.
62  * Implemented by FAMD, 2007. Revised in 2010.
63  * \sa robustRigidTransformation
64  */
66  const TMatchingPairList &in_correspondences,
67  CPose3DQuat &out_transformation,
68  double &out_scale,
69  const bool forceScaleToUnity = false );
70 
71  /** This method provides the closed-form solution of absolute orientation using unit quaternions to a set of over-constrained correspondences for finding the 6D rigid transformation between two cloud of 3D points.
72  * The output 3D pose is computed using the method described in "Closed-form solution of absolute orientation using unit quaternions", BKP Horn, Journal of the Optical Society of America, 1987.
73  *
74  * \param in_correspondences The set of correspondences.
75  * \param out_transformation The change in pose (CPose3DQuat) of the "other" reference system wrt "this" reference system which minimizes the mean-square-error between all the correspondences.
76  * \exception Raises a std::exception if the list "in_correspondences" has not a minimum of two correspondences.
77  * \return True if there are at least two correspondences, or false if one or none, thus we cannot establish any correspondence.
78  * Implemented by FAMD, 2007. Revised in 2010
79  * \sa robustRigidTransformation
80  */
82  const TMatchingPairList &in_correspondences,
83  CPose3D &out_transformation,
84  double &out_scale,
85  const bool forceScaleToUnity = false );
86 
87  /** This method provides the closed-form solution of absolute orientation using unit quaternions to a set of over-constrained correspondences for finding the 6D rigid transformation between two cloud of 3D points using RANSAC.
88  * The output 3D pose is computed using the method described in "Closed-form solution of absolute orientation using unit quaternions", BKP Horn, Journal of the Optical Society of America, 1987.
89  * If supplied, the output covariance matrix is computed using... TODO
90  * \todo Explain covariance!!
91  *
92  * \param in_correspondences The set of correspondences.
93  * \param out_transformation The pose that minimizes the mean-square-error between all the correspondences.
94  * \param out_scale The estimated scale of the rigid transformation (should be very close to 1.0)
95  * \param out_inliers_idx Indexes within the "in_correspondences" list which corresponds with inliers
96  * \param ransac_minSetSize The minimum amount of points in the set
97  * \param ransac_nmaxSimulations The maximum number of iterations of the RANSAC algorithm
98  * \param ransac_maxSetSizePct The (minimum) assumed percent (0.0 - 1.0) of the input set to be considered as inliers
99  * \exception Raises a std::exception if the list "in_correspondences" has not a minimum of two correspondences.
100  * \return True if there are at least two correspondences, or false if one or none, thus we cannot establish any correspondence.
101  * Implemented by FAMD, 2008.
102  * \sa robustRigidTransformation
103  */
105  const TMatchingPairList &in_correspondences,
106  CPose3D &out_transformation,
107  double &out_scale,
108  vector_int &out_inliers_idx,
109  const unsigned int ransac_minSetSize = 5,
110  const unsigned int ransac_nmaxSimulations = 50,
111  const double ransac_maxSetSizePct = 0.7,
112  const bool forceScaleToUnity = false );
113 
114 
115  /** This method provides the basic least-square-error solution to a set of over-constrained correspondences for finding the (x,y,phi) rigid transformation between two planes.
116  * The optimal transformation q fulfills: \f$ point_this = q \oplus point_other \f$
117  * \param in_correspondences The set of correspondences.
118  * \param out_transformation The pose that minimizes the mean-square-error between all the correspondences.
119  * \param out_estimateCovariance If provided (!=NULL) this will contain on return a 3x3 covariance matrix with the NORMALIZED optimal estimate uncertainty. This matrix must be multiplied by \f$\sigma^2_p\f$, the variance of matched points in \f$x\f$ and \f$y\f$ (see paper http://www.mrpt.org/Paper:Occupancy_Grid_Matching)
120  * \exception Raises a std::exception if the list "in_correspondences" has not a minimum of two correspondences.
121  * \return True if there are at least two correspondences, or false if one or none, thus we cannot establish any correspondence.
122  * \sa robustRigidTransformation
123  */
125  TMatchingPairList &in_correspondences,
126  CPose2D &out_transformation,
127  CMatrixDouble33 *out_estimateCovariance = NULL );
128 
129  /** This method provides the basic least-square-error solution to a set of over-constrained correspondences for finding the (x,y,phi) rigid transformation between two planes.
130  * The optimal transformation q fulfills: \f$ point_this = q \oplus point_other \f$
131  * \param in_correspondences The set of correspondences.
132  * \param out_transformation The pose that minimizes the mean-square-error between all the correspondences.
133  * \param out_estimateCovariance If provided (!=NULL) this will contain on return a 3x3 covariance matrix with the NORMALIZED optimal estimate uncertainty. This matrix must be multiplied by \f$\sigma^2_p\f$, the variance of matched points in \f$x\f$ and \f$y\f$ (see paper http://www.mrpt.org/Paper:Occupancy_Grid_Matching)
134  * \exception Raises a std::exception if the list "in_correspondences" has not a minimum of two correspondences.
135  * \return True if there are at least two correspondences, or false if one or none, thus we cannot establish any correspondence.
136  * \sa robustRigidTransformation
137  */
139  TMatchingPairList &in_correspondences,
140  CPosePDFGaussian &out_transformation );
141 
142  /** This method implements a RANSAC-based robust estimation of the rigid transformation between two planar frames of references, returning a probability distribution over all the posibilities as a Sum of Gaussians.
143  *
144  * The technique was described in the paper:
145  * - J.L. Blanco, J. González-Jimenez and J.A. Fernandez-Madrigal. "A robust, multi-hypothesis approach to matching occupancy grid maps". Robotica, available on CJO2013. doi:10.1017/S0263574712000732. http://journals.cambridge.org/action/displayAbstract?aid=8815308
146  *
147  * This works are follows:
148  - Repeat "ransac_nSimulations" times:
149  - Randomly pick TWO correspondences from the set "in_correspondences".
150  - Compute the associated rigid transformation.
151  - For "ransac_maxSetSize" randomly selected correspondences, test for "consensus" with the current group:
152  - If if is compatible (ransac_mahalanobisDistanceThreshold), grow the "consensus set"
153  - If not, do not add it.
154  *
155  * For more details refer to the tutorial on <a href="http://www.mrpt.org/Scan_Matching_Algorithms">scan matching methods</a>.
156  * NOTE:
157  * - If a pointer is supplied to "out_largestSubSet", the largest consensus sub-set
158  * of correspondences will be returned there.
159  * - The parameter "normalizationStd" is the <b>standard deviation</b> (not variance) of landmarks
160  * being matched in X,Y. Used to normalize covariances returned as the SoG.
161  * - If ransac_nSimulations=0 then an adaptive algorithm is used to determine the number of iterations, such as
162  * a good model is found with a probability p=0.999, or that passed as the parameter probability_find_good_model
163  * - When using "probability_find_good_model", the minimum number of iterations can be set with "ransac_min_nSimulations".
164  * - "ransac_maxSetSize" should be set to "in_correspondences.size()" to make sure that every correspondence is tested for each random permutation.
165  *
166  * If ransac_fuseByCorrsMatch=true (the default), the weight of Gaussian modes will be increased when an exact match in the
167  * subset of correspondences for the modes is found. Otherwise, an approximate method is used as test by just looking at the
168  * resulting X,Y,PHI means (Threshold in this case are: ransac_fuseMaxDiffXY, ransac_fuseMaxDiffPhi).
169  *
170  * \param[in] max_rmse_to_end Stop searching for solutions when the RMSE of one solution is below this threshold. Special value "0" means "auto", which employs "2*normalizationStd".
171  *
172  * \exception Raises a std::exception if the list "in_correspondences" has not a minimum of two correspondences.
173  * \sa leastSquareErrorRigidTransformation
174  */
176  TMatchingPairList &in_correspondences,
177  poses::CPosePDFSOG &out_transformation,
178  float normalizationStd,
179  unsigned int ransac_minSetSize = 3,
180  unsigned int ransac_maxSetSize = 20,
181  float ransac_mahalanobisDistanceThreshold = 3.0f,
182  unsigned int ransac_nSimulations = 0,
183  TMatchingPairList *out_largestSubSet = NULL,
184  bool ransac_fuseByCorrsMatch = true,
185  float ransac_fuseMaxDiffXY = 0.01f,
186  float ransac_fuseMaxDiffPhi = mrpt::utils::DEG2RAD(0.1f),
187  bool ransac_algorithmForLandmarks = true,
188  double probability_find_good_model = 0.999,
189  unsigned int ransac_min_nSimulations = 1500,
190  const bool verbose = false,
191  double max_rmse_to_end = 0
192  );
193 
194 
195  /** @} */ // end of grouping
196 
197  }
198 
199 } // End of namespace
200 
201 #endif
bool SCANMATCHING_IMPEXP leastSquareErrorRigidTransformation6DRANSAC(const TMatchingPairList &in_correspondences, CPose3D &out_transformation, double &out_scale, vector_int &out_inliers_idx, const unsigned int ransac_minSetSize=5, const unsigned int ransac_nmaxSimulations=50, const double ransac_maxSetSizePct=0.7, const bool forceScaleToUnity=false)
This method provides the closed-form solution of absolute orientation using unit quaternions to a set...
std::vector< int32_t > vector_int
Definition: types_simple.h:20
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
double DEG2RAD(const double x)
Degrees to radians.
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
Definition: CPosePDFSOG.h:36
bool SCANMATCHING_IMPEXP leastSquareErrorRigidTransformation(TMatchingPairList &in_correspondences, CPose2D &out_transformation, CMatrixDouble33 *out_estimateCovariance=NULL)
This method provides the basic least-square-error solution to a set of over-constrained correspondenc...
bool SCANMATCHING_IMPEXP leastSquareErrorRigidTransformation6D(const TMatchingPairList &in_correspondences, CPose3DQuat &out_transformation, double &out_scale, const bool forceScaleToUnity=false)
This method provides the closed-form solution of absolute orientation using unit quaternions to a set...
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
Definition: CArray.h:18
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
double SCANMATCHING_IMPEXP HornMethod(const std::vector< double > &inPoints, std::vector< double > &outQuat, bool forceScaleToUnity=false)
This function implements the Horn method for computing the change in pose between two coordinate syst...
A list of TMatchingPair.
Definition: TMatchingPair.h:66
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:41
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose.
Definition: CPose2D.h:36
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:69
void SCANMATCHING_IMPEXP robustRigidTransformation(TMatchingPairList &in_correspondences, poses::CPosePDFSOG &out_transformation, float normalizationStd, unsigned int ransac_minSetSize=3, unsigned int ransac_maxSetSize=20, float ransac_mahalanobisDistanceThreshold=3.0f, unsigned int ransac_nSimulations=0, TMatchingPairList *out_largestSubSet=NULL, bool ransac_fuseByCorrsMatch=true, float ransac_fuseMaxDiffXY=0.01f, float ransac_fuseMaxDiffPhi=mrpt::utils::DEG2RAD(0.1f), bool ransac_algorithmForLandmarks=true, double probability_find_good_model=0.999, unsigned int ransac_min_nSimulations=1500, const bool verbose=false, double max_rmse_to_end=0)
This method implements a RANSAC-based robust estimation of the rigid transformation between two plana...



Page generated by Doxygen 1.8.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014