Main MRPT website > C++ reference for MRPT 1.9.9
data_association.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 data_association_H
10 #define data_association_H
11 
12 #include <mrpt/utils/utils_defs.h>
15 #include <mrpt/math/CMatrixTemplate.h> // mrpt::math::CMatrixBool
16 #include <mrpt/utils/TEnumType.h>
17 
18 namespace mrpt
19 {
20 namespace slam
21 {
22 /** \addtogroup data_assoc_grp Data association
23  * \ingroup mrpt_slam_grp
24  * @{ */
25 
26 /** @name Data association
27  @{
28  */
29 
30 /** Different algorithms for data association, used in
31  * mrpt::slam::data_association
32  */
34 {
35  /** Nearest-neighbor. */
36  assocNN = 0,
37  /** JCBB: Joint Compatibility Branch & Bound [Neira, Tardos 2001]. */
39 };
40 
41 /** Different metrics for data association, used in mrpt::slam::data_association
42  * For a comparison of both methods see paper:
43  * * J.L. Blanco, J. Gonzalez-Jimenez, J.A. Fernandez-Madrigal, "An
44  * alternative to the Mahalanobis distance for determining optimal
45  * correspondences in data association", IEEE Transactions on Robotics (T-RO),
46  * (2012) DOI: 10.1109/TRO.2012.2193706 Draft:
47  * http://ingmec.ual.es/~jlblanco/papers/blanco2012amd.pdf
48  */
50 {
51  /** Mahalanobis distance */
53  /** Matching likelihood (See TDataAssociationMetric for a paper explaining
54  this metric) */
56 };
57 
58 /** Used in mrpt::slam::TDataAssociationResults */
59 typedef size_t observation_index_t;
60 /** Used in mrpt::slam::TDataAssociationResults */
61 typedef size_t prediction_index_t;
62 
63 /** The results from mrpt::slam::data_association
64  */
66 {
68  : associations(),
69  distance(0),
70  indiv_distances(0, 0),
71  indiv_compatibility(0, 0),
74  {
75  }
76 
77  void clear()
78  {
79  associations.clear();
80  distance = 0;
81  indiv_distances.setSize(0, 0);
85  }
86 
87  /** For each observation (with row index IDX_obs in the input
88  * "Z_observations"), its association in the predictions, as the row index
89  * in the "Y_predictions_mean" input (or it's mapping to a custom ID, if it
90  * was provided).
91  * Note that not all observations may have an associated prediction.
92  * An observation with index "IDX_obs" corresponds to the prediction number
93  * "associations[IDX_obs]", or it may not correspond to anyone if it's not
94  * present
95  * in the std::map (Tip: Use
96  * associations.find(IDX_obs)!=associations.end() )
97  * \note The types observation_index_t and prediction_index_t are just used
98  * for clarity, use normal size_t's.
99  */
100  std::map<observation_index_t, prediction_index_t> associations;
101  /** The Joint Mahalanobis distance or matching likelihood of the best
102  * associations found. */
103  double distance;
104 
105  /** Individual mahalanobis distances (or matching likelihood, depending on
106  * the selected metric) between predictions (row indices) & observations
107  * (column indices).
108  * Indices are for the appearing order in the arguments
109  * "Y_predictions_mean" & "Z_observations", they are NOT landmark IDs.
110  */
112  /** The result of a chi2 test for compatibility using mahalanobis distance -
113  * Indices are like in "indiv_distances". */
115  /** The sum of each column of indiv_compatibility, that is, the number of
116  * compatible pairings for each observation. */
118 
119  /** Only for the JCBB method,the number of recursive calls expent in the
120  * algorithm. */
122 };
123 
124 /** Computes the data-association between the prediction of a set of landmarks
125  *and their observations, all of them with covariance matrices - Generic
126  *version with prediction full cross-covariances.
127  * Implemented methods include (see TDataAssociation)
128  * - NN: Nearest-neighbor
129  * - JCBB: Joint Compatibility Branch & Bound [Neira, Tardos 2001]
130  *
131  * With both a Mahalanobis-distance or Matching-likelihood metric. For a
132  *comparison of both methods, see paper:
133  * * J.L. Blanco, J. Gonzalez-Jimenez, J.A. Fernandez-Madrigal, "An
134  *alternative to the Mahalanobis distance for determining optimal
135  *correspondences in data association", IEEE Transactions on Robotics (T-RO),
136  *(2012) DOI: 10.1109/TRO.2012.2193706 Draft:
137  *http://ingmec.ual.es/~jlblanco/papers/blanco2012amd.pdf
138  *
139  * \param Z_observations_mean [IN] An MxO matrix with the M observations, each
140  *row containing the observation "mean".
141  * \param Y_predictions_mean [IN] An NxO matrix with the N predictions, each
142  *row containing the mean of one prediction.
143  * \param Y_predictions_cov [IN] An N*OxN*O matrix with the full covariance
144  *matrix of all the N predictions.
145  * \param results [OUT] The output data association hypothesis, and other
146  *useful information.
147  * \param method [IN, optional] The selected method to make the associations.
148  * \param chi2quantile [IN, optional] The threshold for considering a match
149  *between two close Gaussians for two landmarks, in the range [0,1]. It is used
150  *to call mrpt::math::chi2inv
151  * \param use_kd_tree [IN, optional] Build a KD-tree to speed-up the evaluation
152  *of individual compatibility (IC). It's perhaps more efficient to disable it
153  *for a small number of features. (default=true).
154  * \param predictions_IDs [IN, optional] (default:none) An N-vector. If
155  *provided, the resulting associations in "results.associations" will not
156  *contain prediction indices "i", but "predictions_IDs[i]".
157  *
158  * \sa data_association_independent_predictions,
159  *data_association_independent_2d_points,
160  *data_association_independent_3d_points
161  */
163  const mrpt::math::CMatrixDouble& Z_observations_mean,
164  const mrpt::math::CMatrixDouble& Y_predictions_mean,
165  const mrpt::math::CMatrixDouble& Y_predictions_cov,
166  TDataAssociationResults& results,
167  const TDataAssociationMethod method = assocJCBB,
168  const TDataAssociationMetric metric = metricMaha,
169  const double chi2quantile = 0.99, const bool DAT_ASOC_USE_KDTREE = true,
170  const std::vector<prediction_index_t>& predictions_IDs =
171  std::vector<prediction_index_t>(),
172  const TDataAssociationMetric compatibilityTestMetric = metricMaha,
173  const double log_ML_compat_test_threshold = 0.0);
174 
175 /** Computes the data-association between the prediction of a set of landmarks
176  *and their observations, all of them with covariance matrices - Generic
177  *version with NO prediction cross-covariances.
178  * Implemented methods include (see TDataAssociation)
179  * - NN: Nearest-neighbor
180  * - JCBB: Joint Compatibility Branch & Bound [Neira, Tardos 2001]
181  *
182  * With both a Mahalanobis-distance or Matching-likelihood metric. For a
183  *comparison of both methods, see paper:
184  * * J.L. Blanco, J. Gonzalez-Jimenez, J.A. Fernandez-Madrigal, "An
185  *alternative to the Mahalanobis distance for determining optimal
186  *correspondences in data association", IEEE Transactions on Robotics (T-RO),
187  *(2012) DOI: 10.1109/TRO.2012.2193706 Draft:
188  *http://ingmec.ual.es/~jlblanco/papers/blanco2012amd.pdf
189  *
190  * \param Z_observations_mean [IN] An MxO matrix with the M observations, each
191  *row containing the observation "mean".
192  * \param Y_predictions_mean [IN] An NxO matrix with the N predictions, each
193  *row containing the mean of one prediction.
194  * \param Y_predictions_cov [IN] An N*OxO matrix: A vertical stack of N
195  *covariance matrix, one for each of the N prediction.
196  * \param results [OUT] The output data association hypothesis, and other
197  *useful information.
198  * \param method [IN, optional] The selected method to make the associations.
199  * \param chi2quantile [IN, optional] The threshold for considering a match
200  *between two close Gaussians for two landmarks, in the range [0,1]. It is used
201  *to call mrpt::math::chi2inv
202  * \param use_kd_tree [IN, optional] Build a KD-tree to speed-up the evaluation
203  *of individual compatibility (IC). It's perhaps more efficient to disable it
204  *for a small number of features. (default=true).
205  * \param predictions_IDs [IN, optional] (default:none) An N-vector. If
206  *provided, the resulting associations in "results.associations" will not
207  *contain prediction indices "i", but "predictions_IDs[i]".
208  *
209  * \sa data_association_full_covariance,
210  *data_association_independent_2d_points,
211  *data_association_independent_3d_points
212  */
214  const mrpt::math::CMatrixDouble& Z_observations_mean,
215  const mrpt::math::CMatrixDouble& Y_predictions_mean,
216  const mrpt::math::CMatrixDouble& Y_predictions_cov,
217  TDataAssociationResults& results,
218  const TDataAssociationMethod method = assocJCBB,
219  const TDataAssociationMetric metric = metricMaha,
220  const double chi2quantile = 0.99, const bool DAT_ASOC_USE_KDTREE = true,
221  const std::vector<prediction_index_t>& predictions_IDs =
222  std::vector<prediction_index_t>(),
223  const TDataAssociationMetric compatibilityTestMetric = metricMaha,
224  const double log_ML_compat_test_threshold = 0.0);
225 
226 /** @} */
227 
228 /** @} */ // end of grouping
229 
230 } // end namespace
231 
232 // Specializations MUST occur at the same namespace:
233 namespace utils
234 {
235 template <>
237 {
239  static void fill(bimap<enum_t, std::string>& m_map)
240  {
241  m_map.insert(slam::assocNN, "assocNN");
242  m_map.insert(slam::assocJCBB, "assocJCBB");
243  }
244 };
245 
246 template <>
248 {
250  static void fill(bimap<enum_t, std::string>& m_map)
251  {
252  m_map.insert(slam::metricMaha, "metricMaha");
253  m_map.insert(slam::metricML, "metricML");
254  }
255 };
256 
257 } // End of namespace
258 
259 } // End of namespace
260 
261 #endif
Nearest-neighbor.
Declares a matrix of booleans (non serializable).
std::vector< uint32_t > vector_uint
Definition: types_simple.h:29
Mahalanobis distance.
size_t observation_index_t
Used in mrpt::slam::TDataAssociationResults.
vector_uint indiv_compatibility_counts
The sum of each column of indiv_compatibility, that is, the number of compatible pairings for each ob...
mrpt::math::CMatrixDouble indiv_distances
Individual mahalanobis distances (or matching likelihood, depending on the selected metric) between p...
static void fill(bimap< enum_t, std::string > &m_map)
Only specializations of this class are defined for each enum type of interest.
Definition: TEnumType.h:24
JCBB: Joint Compatibility Branch & Bound [Neira, Tardos 2001].
double distance
The Joint Mahalanobis distance or matching likelihood of the best associations found.
TDataAssociationMetric
Different metrics for data association, used in mrpt::slam::data_association For a comparison of both...
A bidirectional version of std::map, declared as bimap<KEY,VALUE> and which actually contains two std...
Definition: bimap.h:34
mrpt::math::CMatrixBool indiv_compatibility
The result of a chi2 test for compatibility using mahalanobis distance - Indices are like in "indiv_d...
void data_association_independent_predictions(const mrpt::math::CMatrixDouble &Z_observations_mean, const mrpt::math::CMatrixDouble &Y_predictions_mean, const mrpt::math::CMatrixDouble &Y_predictions_cov, TDataAssociationResults &results, const TDataAssociationMethod method=assocJCBB, const TDataAssociationMetric metric=metricMaha, const double chi2quantile=0.99, const bool DAT_ASOC_USE_KDTREE=true, const std::vector< prediction_index_t > &predictions_IDs=std::vector< prediction_index_t >(), const TDataAssociationMetric compatibilityTestMetric=metricMaha, const double log_ML_compat_test_threshold=0.0)
Computes the data-association between the prediction of a set of landmarks and their observations...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
static void fill(bimap< enum_t, std::string > &m_map)
std::map< observation_index_t, prediction_index_t > associations
For each observation (with row index IDX_obs in the input "Z_observations"), its association in the p...
size_t prediction_index_t
Used in mrpt::slam::TDataAssociationResults.
void setSize(size_t row, size_t col, bool zeroNewElements=false)
Changes the size of matrix, maintaining the previous contents.
size_t nNodesExploredInJCBB
Only for the JCBB method,the number of recursive calls expent in the algorithm.
The results from mrpt::slam::data_association.
void insert(const KEY &k, const VALUE &v)
Insert a new pair KEY<->VALUE in the bi-map.
Definition: bimap.h:75
Matching likelihood (See TDataAssociationMetric for a paper explaining this metric) ...
TDataAssociationMethod
Different algorithms for data association, used in mrpt::slam::data_association.
void data_association_full_covariance(const mrpt::math::CMatrixDouble &Z_observations_mean, const mrpt::math::CMatrixDouble &Y_predictions_mean, const mrpt::math::CMatrixDouble &Y_predictions_cov, TDataAssociationResults &results, const TDataAssociationMethod method=assocJCBB, const TDataAssociationMetric metric=metricMaha, const double chi2quantile=0.99, const bool DAT_ASOC_USE_KDTREE=true, const std::vector< prediction_index_t > &predictions_IDs=std::vector< prediction_index_t >(), const TDataAssociationMetric compatibilityTestMetric=metricMaha, const double log_ML_compat_test_threshold=0.0)
Computes the data-association between the prediction of a set of landmarks and their observations...



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