MRPT  1.9.9
CGridMapAligner.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-2018, 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 CGridMapAligner_H
10 #define CGridMapAligner_H
11 
17 #include <mrpt/poses/CPosePDFSOG.h>
18 #include <mrpt/poses/poses_frwds.h>
21 
22 namespace mrpt::slam
23 {
24 /** A class for aligning two multi-metric maps (with an occupancy grid maps and
25  * a points map, at least) based on features extraction and matching.
26  * The matching pose is returned as a Sum of Gaussians (poses::CPosePDFSOG).
27  *
28  * This class can use three methods (see options.methodSelection):
29  * - amCorrelation: "Brute-force" correlation of the two maps over a
30  * 2D+orientation grid of possible 2D poses.
31  * - amRobustMatch: Detection of features + RANSAC matching
32  * - amModifiedRANSAC: Detection of features + modified multi-hypothesis
33  * RANSAC matching as described in was reported in the paper
34  * http://www.mrpt.org/Paper%3AOccupancy_Grid_Matching
35  *
36  * See CGridMapAligner::Align for more instructions.
37  *
38  * \sa CMetricMapsAlignmentAlgorithm
39  * \ingroup mrpt_slam_grp
40  */
42 {
43  private:
44  /** Private member, implements one the algorithms.
45  */
48  const mrpt::poses::CPosePDFGaussian& initialEstimationPDF,
49  float* runningTime = nullptr, void* info = nullptr);
50 
51  /** Private member, implements both, the "robustMatch" and the newer
52  * "modifiedRANSAC" algorithms.
53  */
56  const mrpt::poses::CPosePDFGaussian& initialEstimationPDF,
57  float* runningTime = nullptr, void* info = nullptr);
58 
59  /** Grid map features extractor */
61 
62  public:
64  /** The type for selecting the grid-map alignment algorithm.
65  */
67  {
71  };
72 
73  /** The ICP algorithm configuration data
74  */
76  {
77  public:
78  /** Initializer for default values:
79  */
80  TConfigParams();
81 
82  void loadFromConfigFile(
84  const std::string& section) override; // See base docs
85  void dumpToTextStream(
86  std::ostream& out) const override; // See base docs
87 
88  /** The aligner method: */
90 
91  /** The feature descriptor to use: 0=detector already has descriptor, 1=
92  * SIFT, 2=SURF, 4=Spin images, 8=Polar images, 16=log-polar images */
94 
95  /** All the parameters for the feature detector. */
97 
98  /** RANSAC-step options:
99  * \sa CICP::robustRigidTransformation
100  */
101  /** The ratio of landmarks that must be inliers to accepto an hypotheses
102  * (typ: 0.20) */
104  /** The square root of the uncertainty normalization variance var_m (see
105  * papers...) */
107 
108  /** [amRobustMatch method only] RANSAC-step options:
109  * \sa CICP::robustRigidTransformation
110  */
112 
113  /** [amModifiedRANSAC method only] The quantile used for chi-square
114  * thresholding (default=0.99) */
116 
117  /** Probability of having a good inliers (def:0,9999), used for
118  * automatic number of iterations */
120  /** Features extraction from grid map: How many features to extract */
122  /** Correspondences are considered if their distances are below this
123  * threshold (in the range [0,1]) (default=0.15). */
125  /** Correspondences are considered if their distances to the best match
126  * are below this threshold (in the range [0,1]) (default=0.15). */
128 
129  /** The minimum goodness (0-1) of the post-matching ICP to accept a
130  * hypothesis as good (default=0.30) */
132  /** The maximum Mahalanobis distance between the initial and final poses
133  * in the ICP not to discard the hypothesis (default=10) */
135  /** Maximum KL-divergence for merging modes of the SOG (default=0.9) */
137 
138  /** DEBUG - Dump all feature correspondences in a directory "grid_feats"
139  */
141  /** DEBUG - Show graphs with the details of each feature correspondences
142  */
144  /** DEBUG - Save the pair of maps with all the pairings. */
146 
148 
149  /** The ICP algorithm return information.
150  */
151  struct TReturnInfo
152  {
154  /** A goodness measure for the alignment, it is a [0,1] range indicator
155  * of percentage of correspondences.
156  */
157  float goodness;
158 
159  /** The "brute" estimation from using all the available correspondences,
160  * provided just for comparison purposes (it is not the robust
161  * estimation, available as the result of the Align method).
162  */
164 
165  /** The different SOG densities at different steps of the algorithm:
166  * - sog1 : Directly from the matching of features
167  * - sog2 : Merged of sog1
168  * - sog3 : sog2 refined with ICP
169  *
170  * - The final sog is the merge of sog3.
171  *
172  */
175 
176  /** The landmarks of each map (the indices of these landmarks correspond
177  * to those in "correspondences") */
179 
180  /** All the found correspondences (not consistent) */
182 
184  {
185  TPairPlusDistance(size_t i1, size_t i2, float d)
186  : idx_this(i1), idx_other(i2), dist(d)
187  {
188  }
190  float dist;
191  };
192 
193  /** Mahalanobis distance for each potential correspondence */
194  std::vector<TPairPlusDistance> correspondences_dists_maha;
195 
196  /** The ICP goodness of all potential SOG modes at the stage "sog2",
197  * thus before the removing of "bad" ICP matches. */
198  std::vector<double> icp_goodness_all_sog_modes;
199  };
200 
201  /** The method for aligning a pair of 2D points map.
202  * The meaning of some parameters are implementation dependant,
203  * so look for derived classes for instructions.
204  * The target is to find a PDF for the pose displacement between
205  * maps, thus <b>the pose of m2 relative to m1</b>. This pose
206  * is returned as a PDF rather than a single value.
207  *
208  * NOTE: This method can be configurated with "options"
209  *
210  * \param m1 [IN] The first map (Must be a
211  *mrpt::maps::CMultiMetricMap
212  *class)
213  * \param m2 [IN] The second map (Must be a
214  *mrpt::maps::CMultiMetricMap
215  *class)
216  * \param initialEstimationPDF [IN] (IGNORED IN THIS ALGORITHM!)
217  * \param runningTime [OUT] A pointer to a container for obtaining the
218  *algorithm running time in seconds, or NULL if you don't need it.
219  * \param info [OUT] A pointer to a TReturnInfo struct, or NULL if
220  *result information are not required.
221  *
222  * \note The returned PDF depends on the selected alignment method:
223  * - "amRobustMatch" --> A "poses::CPosePDFSOG" object.
224  * - "amCorrelation" --> A "poses::CPosePDFGrid" object.
225  *
226  * \return A smart pointer to the output estimated pose PDF.
227  * \sa CPointsMapAlignmentAlgorithm, options
228  */
230  const mrpt::maps::CMetricMap* m1, const mrpt::maps::CMetricMap* m2,
231  const mrpt::poses::CPosePDFGaussian& initialEstimationPDF,
232  float* runningTime = nullptr,
233 
234  void* info = nullptr);
235 
236  /** Not applicable in this class, will launch an exception. */
238  const mrpt::maps::CMetricMap* m1, const mrpt::maps::CMetricMap* m2,
239  const mrpt::poses::CPose3DPDFGaussian& initialEstimationPDF,
240  float* runningTime = nullptr, void* info = nullptr);
241 };
242 
243 }
245 using namespace mrpt::slam;
250 
251 #endif
252 
253 
MRPT_FILL_ENUM_MEMBER(CGridMapAligner, amRobustMatch)
#define MRPT_ENUM_TYPE_END()
Definition: TEnumType.h:78
#define MRPT_ENUM_TYPE_BEGIN(_ENUM_TYPE_WITH_NS)
Definition: TEnumType.h:62
This class allows loading and storing values and vectors of different types from a configuration text...
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
std::shared_ptr< CLandmarksMap > Ptr
Definition: CLandmarksMap.h:77
Declares a virtual base class for all metric maps storage classes.
Definition: CMetricMap.h:56
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
Definition: CPose2D.h:39
Declares a class that represents a Probability Density function (PDF) of a 3D pose .
std::shared_ptr< CPose3DPDF > Ptr
Definition: CPose3DPDF.h:43
Declares a class that represents a Probability Density function (PDF) of a 2D pose .
std::shared_ptr< CPosePDF > Ptr
Definition: CPosePDF.h:42
The ICP algorithm configuration data.
float threshold_delta
Correspondences are considered if their distances to the best match are below this threshold (in the ...
float ransac_minSetSizeRatio
RANSAC-step options:
mrpt::vision::TDescriptorType feature_descriptor
The feature descriptor to use: 0=detector already has descriptor, 1= SIFT, 2=SURF,...
void dumpToTextStream(std::ostream &out) const override
This method should clearly display all the contents of the structure in textual form,...
bool save_feat_coors
DEBUG - Dump all feature correspondences in a directory "grid_feats".
double max_ICP_mahadist
The maximum Mahalanobis distance between the initial and final poses in the ICP not to discard the hy...
void loadFromConfigFile(const mrpt::config::CConfigFileBase &source, const std::string &section) override
This method load the options from a ".ini"-like file or memory-stored string list.
bool debug_save_map_pairs
DEBUG - Save the pair of maps with all the pairings.
float featsPerSquareMeter
Features extraction from grid map: How many features to extract.
double maxKLd_for_merge
Maximum KL-divergence for merging modes of the SOG (default=0.9)
double ransac_chi2_quantile
[amModifiedRANSAC method only] The quantile used for chi-square thresholding (default=0....
bool debug_show_corrs
DEBUG - Show graphs with the details of each feature correspondences.
mrpt::vision::CFeatureExtraction::TOptions feature_detector_options
All the parameters for the feature detector.
float ransac_mahalanobisDistanceThreshold
[amRobustMatch method only] RANSAC-step options:
float min_ICP_goodness
The minimum goodness (0-1) of the post-matching ICP to accept a hypothesis as good (default=0....
TAlignerMethod methodSelection
The aligner method:
float threshold_max
Correspondences are considered if their distances are below this threshold (in the range [0,...
TConfigParams()
Initializer for default values:
double ransac_prob_good_inliers
Probability of having a good inliers (def:0,9999), used for automatic number of iterations.
float ransac_SOG_sigma_m
The square root of the uncertainty normalization variance var_m (see papers...)
A class for aligning two multi-metric maps (with an occupancy grid maps and a points map,...
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)
The method for aligning a pair of 2D points map.
mrpt::poses::CPosePDF::Ptr AlignPDF_correlation(const mrpt::maps::CMetricMap *m1, const mrpt::maps::CMetricMap *m2, const mrpt::poses::CPosePDFGaussian &initialEstimationPDF, float *runningTime=nullptr, void *info=nullptr)
Private member, implements one the algorithms.
COccupancyGridMapFeatureExtractor m_grid_feat_extr
Grid map features extractor.
mrpt::slam::CGridMapAligner::TConfigParams options
mrpt::poses::CPosePDF::Ptr AlignPDF_robustMatch(const mrpt::maps::CMetricMap *m1, const mrpt::maps::CMetricMap *m2, const mrpt::poses::CPosePDFGaussian &initialEstimationPDF, float *runningTime=nullptr, void *info=nullptr)
Private member, implements both, the "robustMatch" and the newer "modifiedRANSAC" algorithms.
TAlignerMethod
The type for selecting the grid-map alignment algorithm.
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)
Not applicable in this class, will launch an exception.
A base class for any algorithm able of maps alignment.
A class for detecting features from occupancy grid maps.
A list of TMatchingPair.
Definition: TMatchingPair.h:82
GLsizei const GLchar ** string
Definition: glext.h:4101
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
TDescriptorType
The bitwise OR combination of values of TDescriptorType are used in CFeatureExtraction::computeDescri...
The ICP algorithm return information.
std::vector< TPairPlusDistance > correspondences_dists_maha
Mahalanobis distance for each potential correspondence.
mrpt::containers::deepcopy_poly_ptr< mrpt::poses::CPosePDFSOG::Ptr > sog2
std::vector< double > icp_goodness_all_sog_modes
The ICP goodness of all potential SOG modes at the stage "sog2", thus before the removing of "bad" IC...
mrpt::maps::CLandmarksMap::Ptr landmarks_map2
float goodness
A goodness measure for the alignment, it is a [0,1] range indicator of percentage of correspondences.
mrpt::tfest::TMatchingPairList correspondences
All the found correspondences (not consistent)
mrpt::containers::deepcopy_poly_ptr< mrpt::poses::CPosePDFSOG::Ptr > sog1
The different SOG densities at different steps of the algorithm:
mrpt::containers::deepcopy_poly_ptr< mrpt::poses::CPosePDFSOG::Ptr > sog3
mrpt::poses::CPose2D noRobustEstimation
The "brute" estimation from using all the available correspondences, provided just for comparison pur...
mrpt::maps::CLandmarksMap::Ptr landmarks_map1
The landmarks of each map (the indices of these landmarks correspond to those in "correspondences")
The set of parameters for all the detectors & descriptor algorithms.



Page generated by Doxygen 1.9.1 for MRPT 1.9.9 Git: 814d80880 Fri Aug 24 01:51:28 2018 +0200 at mar 26 may 2026 12:30:59 CEST