Main MRPT website > C++ reference for MRPT 1.9.9
se2.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 #pragma once
10 
11 #include <mrpt/utils/utils_defs.h>
12 #include <mrpt/math/math_frwds.h>
14 #include <mrpt/poses/CPosePDFSOG.h>
16 #include <mrpt/poses/poses_frwds.h>
18 
19 namespace mrpt
20 {
21 /** Functions for estimating the optimal transformation between two frames of
22  * references given measurements of corresponding points.
23  * \sa mrpt::slam::CICP
24  * \ingroup mrpt_tfest_grp
25  */
26 namespace tfest
27 {
28 /** \addtogroup mrpt_tfest_grp
29  * @{ */
30 
31 /** Least-squares (L2 norm) solution to finding the optimal SE(2) (x,y,yaw)
32  * between two reference frames.
33  * The optimal transformation `q` fulfills \f$ p_{this} = q \oplus p_{other}
34  * \f$, that is, the
35  * transformation of frame `other` with respect to `this`.
36  *
37  * \image html tfest_frames.png
38  *
39  * \param[in] in_correspondences The set of correspondences.
40  * \param[out] out_transformation The pose that minimizes the mean-square-error
41  * between all the correspondences.
42  * \param[out] out_estimateCovariance If provided (!=nullptr) this will contain
43  * on return a 3x3 covariance matrix with the NORMALIZED optimal estimate
44  * uncertainty. This matrix must be multiplied by \f$\sigma^2_p\f$, the variance
45  * of matched points in \f$x\f$ and \f$y\f$ (see paper
46  * http://www.mrpt.org/Paper:Occupancy_Grid_Matching)
47  * \return True if there are at least two correspondences, or false if one or
48  * none, thus we cannot establish any correspondence.
49  * \sa robustRigidTransformation
50  *
51  * \note Reference for covariance calculation: J.L. Blanco, J.
52  * Gonzalez-Jimenez, J.A. Fernandez-Madrigal, "A Robust, Multi-Hypothesis
53  * Approach to Matching Occupancy Grid Maps", Robotica, 2013.
54  * http://dx.doi.org/10.1017/S0263574712000732
55  * \note [New in MRPT 1.3.0] This function replaces
56  * mrpt::scanmatching::leastSquareErrorRigidTransformation()
57  * \note This function is hand-optimized for SSE2 architectures (if SSE2 is
58  * enabled from CMake)
59  * \sa se3_l2, se2_l2_robust
60  * \ingroup sse_optimizations
61  * \ingroup mrpt_tfest_grp
62  */
63 bool se2_l2(
64  const mrpt::utils::TMatchingPairList& in_correspondences,
65  mrpt::math::TPose2D& out_transformation,
66  mrpt::math::CMatrixDouble33* out_estimateCovariance = nullptr);
67 
68 /** \overload */
69 bool se2_l2(
70  const mrpt::utils::TMatchingPairList& in_correspondences,
71  mrpt::poses::CPosePDFGaussian& out_transformation);
72 
73 /** Parameters for se2_l2_robust(). See function for more details */
75 {
76  /** (Default=3) */
77  unsigned int ransac_minSetSize;
78  /** (Default = 20) */
79  unsigned int ransac_maxSetSize;
80  /** (Default = 3.0) */
82  /** (Default = 0) If set to 0, an adaptive algorithm is used to determine
83  * the number of iterations, such as a good model is found with a
84  * probability p=0.999, or that passed as the parameter
85  * probability_find_good_model */
86  unsigned int ransac_nSimulations;
87  /** (Default = true) If true, the weight of Gaussian modes will be
88  * increased when an exact match in the
89  * subset of correspondences for the modes is found. Otherwise, an
90  * approximate method is used as test by just looking at the
91  * resulting X,Y,PHI means. Threshold in this case are:
92  * ransac_fuseMaxDiffXY, ransac_fuseMaxDiffPhi */
94  /** (Default = 0.01) */
96  /** (Default=0.1degree) (In radians) */
98  /** (Default = true) Use Mahalanobis distance (true) or Euclidean dist
99  * (false) */
101  /** (Default = 0.999) See parameter ransac_nSimulations. When using
102  * `probability_find_good_model`, the minimum number of iterations can be
103  * set with `ransac_min_nSimulations` */
105  /** (Default = 1500) See parameter probability_find_good_model */
107  /** Stop searching for solutions when the RMSE of one solution is below this
108  * threshold. Special value "0" means "auto", which employs
109  * "2*normalizationStd". */
111  /** (Default=false) */
112  bool verbose;
113 
114  /** If provided, this user callback will be invoked to determine the
115  * individual compatibility between each potential pair
116  * of elements. Can check image descriptors, geometrical properties, etc.
117  * \return Must return true if the pair is a potential match, false
118  * otherwise.
119  */
120  // std::function<bool(TPotentialMatch)> user_individual_compat_callback; //
121  // This could be used in the future when we enforce C++11 to users...
123  /** User data to be passed to user_individual_compat_callback() */
125 
126  /** Default values */
128  : ransac_minSetSize(3),
129  ransac_maxSetSize(20),
133  ransac_fuseMaxDiffXY(0.01),
134  ransac_fuseMaxDiffPhi(mrpt::utils::DEG2RAD(0.1)),
138  max_rmse_to_end(0),
139  verbose(false)
140  {
141  }
142 };
143 
144 /** Output placeholder for se2_l2_robust() */
146 {
147  /** The output as a set of transformations (sum of Gaussians) */
149  /** the largest consensus sub-set */
151  /** Number of actual iterations executed */
152  unsigned int ransac_iters;
153 
155 };
156 
157 /** Robust least-squares (L2 norm) solution to finding the optimal SE(2)
158  * (x,y,yaw) between two reference frames.
159  * This method implements a RANSAC-based robust estimation, returning a
160  * probability distribution over all the posibilities as a Sum of Gaussians.
161  *
162  * The optimal transformation `q` fulfills \f$ p_{this} = q \oplus p_{other}
163  * \f$, that is, the
164  * transformation of frame `other` with respect to `this`.
165  *
166  * \image html tfest_frames.png
167  *
168  * The technique was described in the paper:
169  * - J.L. Blanco, J. Gonzalez-Jimenez, J.A. Fernandez-Madrigal, "A Robust,
170  * Multi-Hypothesis Approach to Matching Occupancy Grid Maps", Robotica, 2013.
171  * http://dx.doi.org/10.1017/S0263574712000732
172  *
173  * This works as follows:
174  * - Repeat "ransac_nSimulations" times:
175  * - Randomly pick TWO correspondences from the set "in_correspondences".
176  * - Compute the associated rigid transformation.
177  * - For "ransac_maxSetSize" randomly selected correspondences, test for
178  * "consensus" with the current group:
179  * - If if is compatible (ransac_mahalanobisDistanceThreshold), grow
180  * the "consensus set"
181  * - If not, do not add it.
182  *
183  * For more details refer to the tutorial on <a
184  * href="http://www.mrpt.org/Scan_Matching_Algorithms">scan matching
185  * methods</a>.
186  * \param[in] in_normalizationStd The <b>standard deviation</b> (not variance)
187  * of landmarks/points/features being matched in X,Y. Used to normalize
188  * covariances returned as the SoG. (Refer to paper)
189  *
190  * <b>NOTE</b>: Parameter `ransac_maxSetSize` should be set to
191  * `in_correspondences.size()` to make sure that every correspondence is tested
192  * for each random permutation.
193  *
194  * \return True upon success, false if no subset was found with the minimum
195  * number of correspondences.
196  * \note [New in MRPT 1.3.0] This function replaces
197  * mrpt::scanmatching::robustRigidTransformation()
198  * \sa se3_l2, se2_l2_robust
199  */
200 bool se2_l2_robust(
201  const mrpt::utils::TMatchingPairList& in_correspondences,
202  const double in_normalizationStd, const TSE2RobustParams& in_ransac_params,
203  TSE2RobustResult& out_results);
204 
205 /** @} */ // end of grouping
206 }
207 } // End of namespace
void * user_individual_compat_callback_userdata
User data to be passed to user_individual_compat_callback()
Definition: se2.h:124
TSE2RobustParams()
Default values.
Definition: se2.h:127
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
Definition: CPosePDFSOG.h:36
double max_rmse_to_end
Stop searching for solutions when the RMSE of one solution is below this threshold.
Definition: se2.h:110
std::function< bool(const TPotentialMatch &)> TFunctorCheckPotentialMatch
Parameters for se2_l2_robust().
Definition: se2.h:74
mrpt::utils::TMatchingPairList largestSubSet
the largest consensus sub-set
Definition: se2.h:150
bool ransac_fuseByCorrsMatch
(Default = true) If true, the weight of Gaussian modes will be increased when an exact match in the s...
Definition: se2.h:93
unsigned int ransac_nSimulations
(Default = 0) If set to 0, an adaptive algorithm is used to determine the number of iterations...
Definition: se2.h:86
unsigned int ransac_minSetSize
(Default=3)
Definition: se2.h:77
bool se2_l2(const mrpt::utils::TMatchingPairList &in_correspondences, mrpt::math::TPose2D &out_transformation, mrpt::math::CMatrixDouble33 *out_estimateCovariance=nullptr)
Least-squares (L2 norm) solution to finding the optimal SE(2) (x,y,yaw) between two reference frames...
Definition: se2_l2.cpp:46
bool se2_l2_robust(const mrpt::utils::TMatchingPairList &in_correspondences, const double in_normalizationStd, const TSE2RobustParams &in_ransac_params, TSE2RobustResult &out_results)
Robust least-squares (L2 norm) solution to finding the optimal SE(2) (x,y,yaw) between two reference ...
bool verbose
(Default=false)
Definition: se2.h:112
unsigned int ransac_maxSetSize
(Default = 20)
Definition: se2.h:79
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
A list of TMatchingPair.
Definition: TMatchingPair.h:93
bool ransac_algorithmForLandmarks
(Default = true) Use Mahalanobis distance (true) or Euclidean dist (false)
Definition: se2.h:100
#define DEG2RAD
double ransac_mahalanobisDistanceThreshold
(Default = 3.0)
Definition: se2.h:81
double ransac_fuseMaxDiffPhi
(Default=0.1degree) (In radians)
Definition: se2.h:97
unsigned int ransac_min_nSimulations
(Default = 1500) See parameter probability_find_good_model
Definition: se2.h:106
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
TFunctorCheckPotentialMatch user_individual_compat_callback
If provided, this user callback will be invoked to determine the individual compatibility between eac...
Definition: se2.h:122
unsigned int ransac_iters
Number of actual iterations executed.
Definition: se2.h:152
Lightweight 2D pose.
mrpt::poses::CPosePDFSOG transformation
The output as a set of transformations (sum of Gaussians)
Definition: se2.h:148
Output placeholder for se2_l2_robust()
Definition: se2.h:145
double ransac_fuseMaxDiffXY
(Default = 0.01)
Definition: se2.h:95
double probability_find_good_model
(Default = 0.999) See parameter ransac_nSimulations.
Definition: se2.h:104



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