Main MRPT website > C++ reference
MRPT logo
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-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 CGridMapAligner_H
10 #define CGridMapAligner_H
11 
15 #include <mrpt/utils/TEnumType.h>
16 #include <mrpt/poses/CPosePDFSOG.h>
17 #include <mrpt/poses/poses_frwds.h>
20 
21 namespace mrpt
22 {
23  namespace slam
24  {
25  using namespace poses;
26  using namespace utils;
27 
28  /** A class for aligning two multi-metric maps (with an occupancy grid maps and a points map, at least) based on features extraction and matching.
29  * The matching pose is returned as a Sum of Gaussians (poses::CPosePDFSOG).
30  *
31  * This class can use three methods (see options.methodSelection):
32  * - amCorrelation: "Brute-force" correlation of the two maps over a 2D+orientation grid of possible 2D poses.
33  * - amRobustMatch: Detection of features + RANSAC matching
34  * - amModifiedRANSAC: Detection of features + modified multi-hypothesis RANSAC matching as described in was reported in the paper 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  */
46  CPosePDFPtr AlignPDF_correlation(
47  const CMetricMap *m1,
48  const CMetricMap *m2,
49  const CPosePDFGaussian &initialEstimationPDF,
50  float *runningTime = NULL,
51  void *info = NULL );
52 
53  /** Private member, implements both, the "robustMatch" and the newer "modifiedRANSAC" algorithms.
54  */
55  CPosePDFPtr AlignPDF_robustMatch(
56  const CMetricMap *m1,
57  const CMetricMap *m2,
58  const CPosePDFGaussian &initialEstimationPDF,
59  float *runningTime = NULL,
60  void *info = NULL );
61 
62  COccupancyGridMapFeatureExtractor m_grid_feat_extr; //!< Grid map features extractor
63  public:
64 
66  options()
67  {}
68 
69  /** The type for selecting the grid-map alignment algorithm.
70  */
72  {
73  amRobustMatch = 0,
75  amModifiedRANSAC
76  };
77 
78  /** The ICP algorithm configuration data
79  */
81  {
82  public:
83  /** Initializer for default values:
84  */
85  TConfigParams();
86 
87  /** See utils::CLoadableOptions
88  */
89  void loadFromConfigFile(
90  const mrpt::utils::CConfigFileBase &source,
91  const std::string &section);
92 
93  /** See utils::CLoadableOptions
94  */
95  void dumpToTextStream(CStream &out) const;
96 
97 
98  TAlignerMethod methodSelection; //!< The aligner method:
99 
100  /** The feature descriptor to use: 0=detector already has descriptor, 1= SIFT, 2=SURF, 4=Spin images, 8=Polar images, 16=log-polar images */
102 
103  /** All the parameters for the feature detector. */
105 
106  /** RANSAC-step options:
107  * \sa CICP::robustRigidTransformation
108  */
109  float ransac_minSetSizeRatio; //!< The ratio of landmarks that must be inliers to accepto an hypotheses (typ: 0.20)
110  float ransac_SOG_sigma_m; //!< The square root of the uncertainty normalization variance var_m (see papers...)
111 
112  /** [amRobustMatch method only] RANSAC-step options:
113  * \sa CICP::robustRigidTransformation
114  */
116 
117  double ransac_chi2_quantile; //!< [amModifiedRANSAC method only] The quantile used for chi-square thresholding (default=0.99)
118 
119  double ransac_prob_good_inliers; //!< Probability of having a good inliers (def:0,9999), used for automatic number of iterations
120  float featsPerSquareMeter; //!< Features extraction from grid map: How many features to extract
121  float threshold_max; //!< Correspondences are considered if their distances are below this threshold (in the range [0,1]) (default=0.15).
122  float threshold_delta; //!< Correspondences are considered if their distances to the best match are below this threshold (in the range [0,1]) (default=0.15).
123 
124  float min_ICP_goodness; //!< The minimum goodness (0-1) of the post-matching ICP to accept a hypothesis as good (default=0.25)
125  double max_ICP_mahadist; //!< The maximum Mahalanobis distance between the initial and final poses in the ICP not to discard the hypothesis (default=10)
126  double maxKLd_for_merge; //!< Maximum KL-divergence for merging modes of the SOG (default=0.9)
127 
128  bool save_feat_coors; //!< DEBUG - Dump all feature correspondences in a directory "grid_feats"
129  bool debug_show_corrs; //!< DEBUG - Show graphs with the details of each feature correspondences
130  bool debug_save_map_pairs; //!< DEBUG - Save the pair of maps with all the pairings.
131 
132  } options;
133 
134  /** The ICP algorithm return information.
135  */
137  {
138  /** Initialization
139  */
141  cbSize(sizeof(TReturnInfo)),
142  goodness(0),
143  noRobustEstimation()
144  {
145  }
146 
147  size_t cbSize; //!< Size of the structure, do not change, it's set automatically
148 
149  /** A goodness measure for the alignment, it is a [0,1] range indicator of percentage of correspondences.
150  */
151  float goodness;
152 
153  /** The "brute" estimation from using all the available correspondences, provided just for comparison purposes (it is not the robust estimation, available as the result of the Align method).
154  */
156 
157  /** The different SOG densities at different steps of the algorithm:
158  * - sog1 : Directly from the matching of features
159  * - sog2 : Merged of sog1
160  * - sog3 : sog2 refined with ICP
161  *
162  * - The final sog is the merge of sog3.
163  *
164  */
165  CPosePDFSOGPtr sog1,sog2,sog3;
166 
167  /** The landmarks of each map (the indices of these landmarks correspond to those in "correspondences") */
168  CLandmarksMapPtr landmarks_map1, landmarks_map2;
169 
170  /** All the found correspondences (not consistent) */
172 
174  {
175  TPairPlusDistance(size_t i1, size_t i2, float d) :
176  idx_this(i1), idx_other(i2), dist(d)
177  { }
178  size_t idx_this,idx_other;
179  float dist;
180  };
181 
182  std::vector<TPairPlusDistance> correspondences_dists_maha; //!< Mahalanobis distance for each potential correspondence
183 
184  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" ICP matches.
185  };
186 
187  /** The method for aligning a pair of 2D points map.
188  * The meaning of some parameters are implementation dependant,
189  * so look for derived classes for instructions.
190  * The target is to find a PDF for the pose displacement between
191  * maps, thus <b>the pose of m2 relative to m1</b>. This pose
192  * is returned as a PDF rather than a single value.
193  *
194  * NOTE: This method can be configurated with "options"
195  *
196  * \param m1 [IN] The first map (Must be a mrpt::slam::CMultiMetricMap class)
197  * \param m2 [IN] The second map (Must be a mrpt::slam::CMultiMetricMap class)
198  * \param initialEstimationPDF [IN] (IGNORED IN THIS ALGORITHM!)
199  * \param runningTime [OUT] A pointer to a container for obtaining the algorithm running time in seconds, or NULL if you don't need it.
200  * \param info [OUT] A pointer to a CAlignerFromMotionDraws::TReturnInfo struct, or NULL if result information are not required.
201  *
202  * \note The returned PDF depends on the selected alignment method:
203  * - "amRobustMatch" --> A "poses::CPosePDFSOG" object.
204  * - "amCorrelation" --> A "poses::CPosePDFGrid" object.
205  *
206  * \return A smart pointer to the output estimated pose PDF.
207  * \sa CPointsMapAlignmentAlgorithm, options
208  */
209  CPosePDFPtr AlignPDF(
210  const CMetricMap *m1,
211  const CMetricMap *m2,
212  const CPosePDFGaussian &initialEstimationPDF,
213  float *runningTime = NULL,
214 
215  void *info = NULL );
216 
217 
218  /** Not applicable in this class, will launch an exception. */
219  CPose3DPDFPtr Align3DPDF(
220  const CMetricMap *m1,
221  const CMetricMap *m2,
222  const CPose3DPDFGaussian &initialEstimationPDF,
223  float *runningTime = NULL,
224  void *info = NULL );
225 
226  };
227 
228  } // End of namespace
229 
230  // Specializations MUST occur at the same namespace:
231  namespace utils
232  {
233  template <>
235  {
237  static void fill(bimap<enum_t,std::string> &m_map)
238  {
239  m_map.insert(slam::CGridMapAligner::amRobustMatch, "amRobustMatch");
240  m_map.insert(slam::CGridMapAligner::amCorrelation, "amCorrelation");
241  m_map.insert(slam::CGridMapAligner::amModifiedRANSAC, "amModifiedRANSAC");
242  }
243  };
244  } // End of namespace
245 
246 } // End of namespace
247 
248 #endif
double ransac_chi2_quantile
[amModifiedRANSAC method only] The quantile used for chi-square thresholding (default=0.99)
std::vector< TPairPlusDistance > correspondences_dists_maha
Mahalanobis distance for each potential correspondence.
double maxKLd_for_merge
Maximum KL-divergence for merging modes of the SOG (default=0.9)
A class for aligning two multi-metric maps (with an occupancy grid maps and a points map...
bool debug_show_corrs
DEBUG - Show graphs with the details of each feature correspondences.
The ICP algorithm configuration data.
The set of parameters for all the detectors & descriptor algorithms.
Only specializations of this class are defined for each enum type of interest.
Definition: TEnumType.h:23
The ICP algorithm return information.
This class allows loading and storing values and vectors of different types from a configuration text...
Declares a virtual base class for all metric maps storage classes.
Definition: CMetricMap.h:83
size_t cbSize
Size of the structure, do not change, it's set automatically.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
mrpt::vision::TDescriptorType feature_descriptor
The feature descriptor to use: 0=detector already has descriptor, 1= SIFT, 2=SURF, 4=Spin images, 8=Polar images, 16=log-polar images.
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
bool debug_save_map_pairs
DEBUG - Save the pair of maps with all the pairings.
bool save_feat_coors
DEBUG - Dump all feature correspondences in a directory "grid_feats".
A list of TMatchingPair.
Definition: TMatchingPair.h:66
mrpt::vision::CFeatureExtraction::TOptions feature_detector_options
All the parameters for the feature detector.
COccupancyGridMapFeatureExtractor m_grid_feat_extr
Grid map features extractor.
A bidirectional version of std::map, declared as bimap and which actually contains two std...
Definition: bimap.h:27
mrpt::utils::TMatchingPairList correspondences
All the found correspondences (not consistent)
TAlignerMethod
The type for selecting the grid-map alignment algorithm.
float ransac_minSetSizeRatio
RANSAC-step options:
float ransac_SOG_sigma_m
The square root of the uncertainty normalization variance var_m (see papers...)
float threshold_delta
Correspondences are considered if their distances to the best match are below this threshold (in the ...
TDescriptorType
The bitwise OR combination of values of TDescriptorType are used in CFeatureExtraction::computeDescri...
float goodness
A goodness measure for the alignment, it is a [0,1] range indicator of percentage of correspondences...
float ransac_mahalanobisDistanceThreshold
[amRobustMatch method only] RANSAC-step options:
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...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double ransac_prob_good_inliers
Probability of having a good inliers (def:0,9999), used for automatic number of iterations.
A class used to store a 2D pose.
Definition: CPose2D.h:36
A base class for any algorithm able of maps alignment.
static void fill(bimap< enum_t, std::string > &m_map)
double max_ICP_mahadist
The maximum Mahalanobis distance between the initial and final poses in the ICP not to discard the hy...
float featsPerSquareMeter
Features extraction from grid map: How many features to extract.
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
TAlignerMethod methodSelection
The aligner method:
void insert(const KEY &k, const VALUE &v)
Insert a new pair KEY<->VALUE in the bi-map.
Definition: bimap.h:68
A class for detecting features from occupancy grid maps.
CPose2D noRobustEstimation
The "brute" estimation from using all the available correspondences, provided just for comparison pur...
float threshold_max
Correspondences are considered if their distances are below this threshold (in the range [0...
float min_ICP_goodness
The minimum goodness (0-1) of the post-matching ICP to accept a hypothesis as good (default=0...
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...



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