Statistics.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef STATISTICS_H_
29 #define STATISTICS_H_
30 
31 #include "rtabmap/core/RtabmapExp.h" // DLL export/import defines
32 
33 #include <opencv2/core/core.hpp>
34 #include <opencv2/features2d/features2d.hpp>
35 #include <opencv2/imgproc/imgproc.hpp>
36 #include <list>
37 #include <vector>
38 #include <rtabmap/core/Signature.h>
39 #include <rtabmap/core/Link.h>
40 
41 namespace rtabmap {
42 
43 #define RTABMAP_STATS(PREFIX, NAME, UNIT) \
44  public: \
45  static std::string k##PREFIX##NAME() {return #PREFIX "/" #NAME "/" #UNIT;} \
46  private: \
47  class Dummy##PREFIX##NAME { \
48  public: \
49  Dummy##PREFIX##NAME() {if(!_defaultDataInitialized)_defaultData.insert(std::pair<std::string, float>(#PREFIX "/" #NAME "/" #UNIT, 0.0f));} \
50  }; \
51  Dummy##PREFIX##NAME dummy##PREFIX##NAME
52 
54 {
55  RTABMAP_STATS(Loop, Id,); // Combined loop or proximity detection
56  RTABMAP_STATS(Loop, RejectedHypothesis,);
57  RTABMAP_STATS(Loop, Accepted_hypothesis_id,);
58  RTABMAP_STATS(Loop, Suppressed_hypothesis_id,);
59  RTABMAP_STATS(Loop, Highest_hypothesis_id,);
60  RTABMAP_STATS(Loop, Highest_hypothesis_value,);
61  RTABMAP_STATS(Loop, Vp_hypothesis,);
62  RTABMAP_STATS(Loop, Reactivate_id,);
63  RTABMAP_STATS(Loop, Hypothesis_ratio,);
64  RTABMAP_STATS(Loop, Hypothesis_reactivated,);
65  RTABMAP_STATS(Loop, Map_id,);
66  RTABMAP_STATS(Loop, Visual_words,);
67  RTABMAP_STATS(Loop, Visual_inliers,);
68  RTABMAP_STATS(Loop, Visual_inliers_ratio,);
69  RTABMAP_STATS(Loop, Visual_matches,);
70  RTABMAP_STATS(Loop, Distance_since_last_loc,);
71  RTABMAP_STATS(Loop, Last_id,);
72  RTABMAP_STATS(Loop, Optimization_max_error, m);
73  RTABMAP_STATS(Loop, Optimization_max_error_ratio, );
74  RTABMAP_STATS(Loop, Optimization_error, );
75  RTABMAP_STATS(Loop, Optimization_iterations, );
76  RTABMAP_STATS(Loop, Linear_variance,);
77  RTABMAP_STATS(Loop, Angular_variance,);
78  RTABMAP_STATS(Loop, Landmark_detected,);
79  RTABMAP_STATS(Loop, Landmark_detected_node_ref,);
80  RTABMAP_STATS(Loop, Visual_inliers_mean_dist,m);
81  RTABMAP_STATS(Loop, Visual_inliers_distribution,);
82  //Odom correction
83  RTABMAP_STATS(Loop, Odom_correction_norm, m);
84  RTABMAP_STATS(Loop, Odom_correction_angle, deg);
85  RTABMAP_STATS(Loop, Odom_correction_x, m);
86  RTABMAP_STATS(Loop, Odom_correction_y, m);
87  RTABMAP_STATS(Loop, Odom_correction_z, m);
88  RTABMAP_STATS(Loop, Odom_correction_roll, deg);
89  RTABMAP_STATS(Loop, Odom_correction_pitch, deg);
90  RTABMAP_STATS(Loop, Odom_correction_yaw, deg);
91  //Odom correction
92  RTABMAP_STATS(Loop, Odom_correction_acc_norm, m);
93  RTABMAP_STATS(Loop, Odom_correction_acc_angle, deg);
94  RTABMAP_STATS(Loop, Odom_correction_acc_x, m);
95  RTABMAP_STATS(Loop, Odom_correction_acc_y, m);
96  RTABMAP_STATS(Loop, Odom_correction_acc_z, m);
97  RTABMAP_STATS(Loop, Odom_correction_acc_roll, deg);
98  RTABMAP_STATS(Loop, Odom_correction_acc_pitch, deg);
99  RTABMAP_STATS(Loop, Odom_correction_acc_yaw, deg);
100  // Map to Odom
101  RTABMAP_STATS(Loop, MapToOdom_norm, m);
102  RTABMAP_STATS(Loop, MapToOdom_angle, deg);
103  RTABMAP_STATS(Loop, MapToOdom_x, m);
104  RTABMAP_STATS(Loop, MapToOdom_y, m);
105  RTABMAP_STATS(Loop, MapToOdom_z, m);
106  RTABMAP_STATS(Loop, MapToOdom_roll, deg);
107  RTABMAP_STATS(Loop, MapToOdom_pitch, deg);
108  RTABMAP_STATS(Loop, MapToOdom_yaw, deg);
109  // Map to Base
110  RTABMAP_STATS(Loop, MapToBase_x, m);
111  RTABMAP_STATS(Loop, MapToBase_y, m);
112  RTABMAP_STATS(Loop, MapToBase_z, m);
113  RTABMAP_STATS(Loop, MapToBase_roll, deg);
114  RTABMAP_STATS(Loop, MapToBase_pitch, deg);
115  RTABMAP_STATS(Loop, MapToBase_yaw, deg);
116 
117  RTABMAP_STATS(Proximity, Time_detections,);
118  RTABMAP_STATS(Proximity, Space_last_detection_id,);
119  RTABMAP_STATS(Proximity, Space_paths,);
120  RTABMAP_STATS(Proximity, Space_visual_paths_checked,);
121  RTABMAP_STATS(Proximity, Space_scan_paths_checked,);
122  RTABMAP_STATS(Proximity, Space_detections_added_visually,);
123  RTABMAP_STATS(Proximity, Space_detections_added_icp_only,);
124 
125  RTABMAP_STATS(NeighborLinkRefining, Accepted,);
126  RTABMAP_STATS(NeighborLinkRefining, Inliers,);
127  RTABMAP_STATS(NeighborLinkRefining, ICP_inliers_ratio,);
128  RTABMAP_STATS(NeighborLinkRefining, ICP_rotation, rad);
129  RTABMAP_STATS(NeighborLinkRefining, ICP_translation, m);
130  RTABMAP_STATS(NeighborLinkRefining, ICP_complexity,);
131  RTABMAP_STATS(NeighborLinkRefining, Variance,);
132  RTABMAP_STATS(NeighborLinkRefining, Pts,);
133 
134  RTABMAP_STATS(Memory, Working_memory_size,);
135  RTABMAP_STATS(Memory, Short_time_memory_size,);
136  RTABMAP_STATS(Memory, Database_memory_used, MB);
137  RTABMAP_STATS(Memory, Signatures_removed,);
138  RTABMAP_STATS(Memory, Immunized_globally,);
139  RTABMAP_STATS(Memory, Immunized_locally,);
140  RTABMAP_STATS(Memory, Immunized_locally_max,);
141  RTABMAP_STATS(Memory, Signatures_retrieved,);
142  RTABMAP_STATS(Memory, Images_buffered,);
143  RTABMAP_STATS(Memory, Rehearsal_sim,);
144  RTABMAP_STATS(Memory, Rehearsal_id,);
145  RTABMAP_STATS(Memory, Rehearsal_merged,);
146  RTABMAP_STATS(Memory, Local_graph_size,);
147  RTABMAP_STATS(Memory, Small_movement,);
148  RTABMAP_STATS(Memory, Fast_movement,);
149  RTABMAP_STATS(Memory, Odometry_variance_ang,);
150  RTABMAP_STATS(Memory, Odometry_variance_lin,);
151  RTABMAP_STATS(Memory, Distance_travelled, m);
152  RTABMAP_STATS(Memory, RAM_usage, MB);
153  RTABMAP_STATS(Memory, RAM_estimated, MB);
154  RTABMAP_STATS(Memory, Triangulated_points, );
155 
156  RTABMAP_STATS(Timing, Memory_update, ms);
157  RTABMAP_STATS(Timing, Neighbor_link_refining, ms);
158  RTABMAP_STATS(Timing, Proximity_by_time, ms);
159  RTABMAP_STATS(Timing, Proximity_by_space_visual, ms);
160  RTABMAP_STATS(Timing, Proximity_by_space, ms);
161  RTABMAP_STATS(Timing, Cleaning_neighbors, ms);
162  RTABMAP_STATS(Timing, Reactivation, ms);
163  RTABMAP_STATS(Timing, Add_loop_closure_link, ms);
164  RTABMAP_STATS(Timing, Map_optimization, ms);
165  RTABMAP_STATS(Timing, Likelihood_computation, ms);
166  RTABMAP_STATS(Timing, Posterior_computation, ms);
167  RTABMAP_STATS(Timing, Hypotheses_creation, ms);
168  RTABMAP_STATS(Timing, Hypotheses_validation, ms);
169  RTABMAP_STATS(Timing, Statistics_creation, ms);
170  RTABMAP_STATS(Timing, Memory_cleanup, ms);
171  RTABMAP_STATS(Timing, Total, ms);
172  RTABMAP_STATS(Timing, Forgetting, ms);
173  RTABMAP_STATS(Timing, Joining_trash, ms);
174  RTABMAP_STATS(Timing, Emptying_trash, ms);
175  RTABMAP_STATS(Timing, Finalizing_statistics, ms);
176  RTABMAP_STATS(Timing, RAM_estimation, ms);
177 
178  RTABMAP_STATS(TimingMem, Pre_update, ms);
179  RTABMAP_STATS(TimingMem, Signature_creation, ms);
180  RTABMAP_STATS(TimingMem, Rehearsal, ms);
181  RTABMAP_STATS(TimingMem, Keypoints_detection, ms);
182  RTABMAP_STATS(TimingMem, Subpixel, ms);
183  RTABMAP_STATS(TimingMem, Stereo_correspondences, ms);
184  RTABMAP_STATS(TimingMem, Descriptors_extraction, ms);
185  RTABMAP_STATS(TimingMem, Rectification, ms);
186  RTABMAP_STATS(TimingMem, Keypoints_3D, ms);
187  RTABMAP_STATS(TimingMem, Keypoints_3D_motion, ms);
188  RTABMAP_STATS(TimingMem, Joining_dictionary_update, ms);
189  RTABMAP_STATS(TimingMem, Add_new_words, ms);
190  RTABMAP_STATS(TimingMem, Compressing_data, ms);
191  RTABMAP_STATS(TimingMem, Post_decimation, ms);
192  RTABMAP_STATS(TimingMem, Scan_filtering, ms);
193  RTABMAP_STATS(TimingMem, Occupancy_grid, ms);
194  RTABMAP_STATS(TimingMem, Markers_detection, ms);
195 
196  RTABMAP_STATS(Keypoint, Dictionary_size, words);
197  RTABMAP_STATS(Keypoint, Current_frame, words);
198  RTABMAP_STATS(Keypoint, Indexed_words, words);
199  RTABMAP_STATS(Keypoint, Index_memory_usage, KB);
200 
201  RTABMAP_STATS(Gt, Translational_rmse, m);
202  RTABMAP_STATS(Gt, Translational_mean, m);
203  RTABMAP_STATS(Gt, Translational_median, m);
204  RTABMAP_STATS(Gt, Translational_std, m);
205  RTABMAP_STATS(Gt, Translational_min, m);
206  RTABMAP_STATS(Gt, Translational_max, m);
207  RTABMAP_STATS(Gt, Rotational_rmse, deg);
208  RTABMAP_STATS(Gt, Rotational_mean, deg);
209  RTABMAP_STATS(Gt, Rotational_median, deg);
210  RTABMAP_STATS(Gt, Rotational_std, deg);
211  RTABMAP_STATS(Gt, Rotational_min, deg);
212  RTABMAP_STATS(Gt, Rotational_max, deg);
213  RTABMAP_STATS(Gt, Localization_linear_error, m);
214  RTABMAP_STATS(Gt, Localization_angular_error, deg);
215 
216 public:
217  static const std::map<std::string, float> & defaultData();
218  static std::string serializeData(const std::map<std::string, float> & data);
219  static std::map<std::string, float> deserializeData(const std::string & data);
220 
221 public:
222  Statistics();
223  virtual ~Statistics();
224 
225  // name format = "Grp/Name/unit"
226  void addStatistic(const std::string & name, float value);
227 
228  // setters
229  void setExtended(bool extended) {_extended = extended;}
230  void setRefImageId(int id) {_refImageId = id;}
231  void setRefImageMapId(int id) {_refImageMapId = id;}
232  void setLoopClosureId(int id) {_loopClosureId = id;}
233  void setLoopClosureMapId(int id) {_loopClosureMapId = id;}
234  void setProximityDetectionId(int id) {_proximiyDetectionId = id;}
235  void setProximityDetectionMapId(int id) {_proximiyDetectionMapId = id;}
236  void setStamp(double stamp) {_stamp = stamp;}
237 
238  void setLastSignatureData(const Signature & data) {_lastSignatureData = data;}
239 
240  void setPoses(const std::map<int, Transform> & poses) {_poses = poses;}
241  void setConstraints(const std::multimap<int, Link> & constraints) {_constraints = constraints;}
242  void setMapCorrection(const Transform & mapCorrection) {_mapCorrection = mapCorrection;}
243  void setLoopClosureTransform(const Transform & loopClosureTransform) {_loopClosureTransform = loopClosureTransform;}
244  void setLocalizationCovariance(const cv::Mat & covariance) {_localizationCovariance = covariance;}
245  void setLabels(const std::map<int, std::string> & labels) {_labels = labels;}
246  void setWeights(const std::map<int, int> & weights) {_weights = weights;}
247  void setPosterior(const std::map<int, float> & posterior) {_posterior = posterior;}
248  void setLikelihood(const std::map<int, float> & likelihood) {_likelihood = likelihood;}
249  void setRawLikelihood(const std::map<int, float> & rawLikelihood) {_rawLikelihood = rawLikelihood;}
250  void setLocalPath(const std::vector<int> & localPath) {_localPath=localPath;}
251  void setCurrentGoalId(int goal) {_currentGoalId=goal;}
252  void setReducedIds(const std::map<int, int> & reducedIds) {_reducedIds = reducedIds;}
253  void setWmState(const std::vector<int> & state) {_wmState = state;}
254 
255  // getters
256  bool extended() const {return _extended;}
257  int refImageId() const {return _refImageId;}
258  int refImageMapId() const {return _refImageMapId;}
259  int loopClosureId() const {return _loopClosureId;}
260  int loopClosureMapId() const {return _loopClosureMapId;}
261  int proximityDetectionId() const {return _proximiyDetectionId;}
262  int proximityDetectionMapId() const {return _proximiyDetectionMapId;}
263  double stamp() const {return _stamp;}
264 
265  const Signature & getLastSignatureData() const {return _lastSignatureData;}
266 
267  const std::map<int, Transform> & poses() const {return _poses;}
268  const std::multimap<int, Link> & constraints() const {return _constraints;}
269  const Transform & mapCorrection() const {return _mapCorrection;}
270  const Transform & loopClosureTransform() const {return _loopClosureTransform;}
271  const cv::Mat & localizationCovariance() const {return _localizationCovariance;}
272  const std::map<int, std::string> & labels() const {return _labels;}
273  const std::map<int, int> & weights() const {return _weights;}
274  const std::map<int, float> & posterior() const {return _posterior;}
275  const std::map<int, float> & likelihood() const {return _likelihood;}
276  const std::map<int, float> & rawLikelihood() const {return _rawLikelihood;}
277  const std::vector<int> & localPath() const {return _localPath;}
278  int currentGoalId() const {return _currentGoalId;}
279  const std::map<int, int> & reducedIds() const {return _reducedIds;}
280  const std::vector<int> & wmState() const {return _wmState;}
281 
282  const std::map<std::string, float> & data() const {return _data;}
283 
284 private:
285  bool _extended; // 0 -> only loop closure and last signature ID fields are filled
286 
293  double _stamp;
294 
296 
297  std::map<int, Transform> _poses;
298  std::multimap<int, Link> _constraints;
302 
303  std::map<int, std::string> _labels;
304  std::map<int, int> _weights;
305  std::map<int, float> _posterior;
306  std::map<int, float> _likelihood;
307  std::map<int, float> _rawLikelihood;
308 
309  std::vector<int> _localPath;
311 
312  std::map<int, int> _reducedIds;
313 
314  std::vector<int> _wmState;
315 
316  // Format for statistics (Plottable statistics must go in that map) :
317  // {"Group/Name/Unit", value}
318  // Example : {"Timing/Total time/ms", 500.0f}
319  std::map<std::string, float> _data;
320  static std::map<std::string, float> _defaultData;
322  // end extended data
323 };
324 
325 }// end namespace rtabmap
326 
327 #endif /* STATISTICS_H_ */
bool extended() const
Definition: Statistics.h:256
cv::Mat _localizationCovariance
Definition: Statistics.h:301
const std::map< int, std::string > & labels() const
Definition: Statistics.h:272
const cv::Mat & localizationCovariance() const
Definition: Statistics.h:271
std::map< int, int > _weights
Definition: Statistics.h:304
int refImageMapId() const
Definition: Statistics.h:258
std::multimap< int, Link > _constraints
Definition: Statistics.h:298
const std::map< int, float > & likelihood() const
Definition: Statistics.h:275
std::map< std::string, float > _data
Definition: Statistics.h:319
void setLoopClosureId(int id)
Definition: Statistics.h:232
int loopClosureMapId() const
Definition: Statistics.h:260
void setLabels(const std::map< int, std::string > &labels)
Definition: Statistics.h:245
void setPosterior(const std::map< int, float > &posterior)
Definition: Statistics.h:247
int proximityDetectionId() const
Definition: Statistics.h:261
void setRawLikelihood(const std::map< int, float > &rawLikelihood)
Definition: Statistics.h:249
const Signature & getLastSignatureData() const
Definition: Statistics.h:265
void setLoopClosureMapId(int id)
Definition: Statistics.h:233
const std::map< int, float > & posterior() const
Definition: Statistics.h:274
void setRefImageId(int id)
Definition: Statistics.h:230
void setReducedIds(const std::map< int, int > &reducedIds)
Definition: Statistics.h:252
void setProximityDetectionId(int id)
Definition: Statistics.h:234
std::map< int, float > _rawLikelihood
Definition: Statistics.h:307
std::map< int, std::string > _labels
Definition: Statistics.h:303
void setCurrentGoalId(int goal)
Definition: Statistics.h:251
void setConstraints(const std::multimap< int, Link > &constraints)
Definition: Statistics.h:241
const std::map< int, int > & reducedIds() const
Definition: Statistics.h:279
const std::map< int, int > & weights() const
Definition: Statistics.h:273
Transform _loopClosureTransform
Definition: Statistics.h:300
std::map< int, int > _reducedIds
Definition: Statistics.h:312
#define RTABMAP_EXP
Definition: RtabmapExp.h:38
const std::map< std::string, float > & data() const
Definition: Statistics.h:282
void setLocalPath(const std::vector< int > &localPath)
Definition: Statistics.h:250
static std::map< std::string, float > _defaultData
Definition: Statistics.h:320
void setLastSignatureData(const Signature &data)
Definition: Statistics.h:238
void setLocalizationCovariance(const cv::Mat &covariance)
Definition: Statistics.h:244
void setPoses(const std::map< int, Transform > &poses)
Definition: Statistics.h:240
std::map< int, float > _likelihood
Definition: Statistics.h:306
void setExtended(bool extended)
Definition: Statistics.h:229
static bool _defaultDataInitialized
Definition: Statistics.h:321
#define KB
Definition: lz4.c:226
std::vector< int > _localPath
Definition: Statistics.h:309
void setRefImageMapId(int id)
Definition: Statistics.h:231
#define RTABMAP_STATS(PREFIX, NAME, UNIT)
Definition: Statistics.h:43
int proximityDetectionMapId() const
Definition: Statistics.h:262
int loopClosureId() const
Definition: Statistics.h:259
const Transform & loopClosureTransform() const
Definition: Statistics.h:270
RecoveryProgressState state
std::vector< int > _wmState
Definition: Statistics.h:314
void setMapCorrection(const Transform &mapCorrection)
Definition: Statistics.h:242
void setLikelihood(const std::map< int, float > &likelihood)
Definition: Statistics.h:248
const std::map< int, Transform > & poses() const
Definition: Statistics.h:267
void setWmState(const std::vector< int > &state)
Definition: Statistics.h:253
void setStamp(double stamp)
Definition: Statistics.h:236
const std::vector< int > & wmState() const
Definition: Statistics.h:280
const std::multimap< int, Link > & constraints() const
Definition: Statistics.h:268
void setWeights(const std::map< int, int > &weights)
Definition: Statistics.h:246
std::map< int, Transform > _poses
Definition: Statistics.h:297
int currentGoalId() const
Definition: Statistics.h:278
#define MB
Definition: lz4.c:227
void setLoopClosureTransform(const Transform &loopClosureTransform)
Definition: Statistics.h:243
Signature _lastSignatureData
Definition: Statistics.h:295
void setProximityDetectionMapId(int id)
Definition: Statistics.h:235
const Transform & mapCorrection() const
Definition: Statistics.h:269
const std::vector< int > & localPath() const
Definition: Statistics.h:277
int refImageId() const
Definition: Statistics.h:257
std::map< int, float > _posterior
Definition: Statistics.h:305
Transform _mapCorrection
Definition: Statistics.h:299
const std::map< int, float > & rawLikelihood() const
Definition: Statistics.h:276
double stamp() const
Definition: Statistics.h:263


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:37:06