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



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST