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, RejectedHypothesis,);
56  RTABMAP_STATS(Loop, Accepted_hypothesis_id,);
57  RTABMAP_STATS(Loop, Highest_hypothesis_id,);
58  RTABMAP_STATS(Loop, Highest_hypothesis_value,);
59  RTABMAP_STATS(Loop, Vp_hypothesis,);
60  RTABMAP_STATS(Loop, Reactivate_id,);
61  RTABMAP_STATS(Loop, Hypothesis_ratio,);
62  RTABMAP_STATS(Loop, Hypothesis_reactivated,);
63  RTABMAP_STATS(Loop, Visual_inliers,);
64  RTABMAP_STATS(Loop, Visual_matches,);
65  RTABMAP_STATS(Loop, Last_id,);
66  RTABMAP_STATS(Loop, Optimization_max_error, m);
67  RTABMAP_STATS(Loop, Optimization_max_error_ratio, );
68  RTABMAP_STATS(Loop, Optimization_error, );
69  RTABMAP_STATS(Loop, Optimization_iterations, );
70  RTABMAP_STATS(Loop, Linear_variance,);
71  RTABMAP_STATS(Loop, Angular_variance,);
72 
73  RTABMAP_STATS(Proximity, Time_detections,);
74  RTABMAP_STATS(Proximity, Space_last_detection_id,);
75  RTABMAP_STATS(Proximity, Space_paths,);
76  RTABMAP_STATS(Proximity, Space_visual_paths_checked,);
77  RTABMAP_STATS(Proximity, Space_scan_paths_checked,);
78  RTABMAP_STATS(Proximity, Space_detections_added_visually,);
79  RTABMAP_STATS(Proximity, Space_detections_added_icp_only,);
80 
81  RTABMAP_STATS(NeighborLinkRefining, Accepted,);
82  RTABMAP_STATS(NeighborLinkRefining, Inliers,);
83  RTABMAP_STATS(NeighborLinkRefining, ICP_inliers_ratio,);
84  RTABMAP_STATS(NeighborLinkRefining, ICP_rotation, rad);
85  RTABMAP_STATS(NeighborLinkRefining, ICP_translation, m);
86  RTABMAP_STATS(NeighborLinkRefining, ICP_complexity,);
87  RTABMAP_STATS(NeighborLinkRefining, Variance,);
88  RTABMAP_STATS(NeighborLinkRefining, Pts,);
89 
90  RTABMAP_STATS(Memory, Working_memory_size,);
91  RTABMAP_STATS(Memory, Short_time_memory_size,);
92  RTABMAP_STATS(Memory, Database_memory_used, MB);
93  RTABMAP_STATS(Memory, Signatures_removed,);
94  RTABMAP_STATS(Memory, Immunized_globally,);
95  RTABMAP_STATS(Memory, Immunized_locally,);
96  RTABMAP_STATS(Memory, Immunized_locally_max,);
97  RTABMAP_STATS(Memory, Signatures_retrieved,);
98  RTABMAP_STATS(Memory, Images_buffered,);
99  RTABMAP_STATS(Memory, Rehearsal_sim,);
100  RTABMAP_STATS(Memory, Rehearsal_id,);
101  RTABMAP_STATS(Memory, Rehearsal_merged,);
102  RTABMAP_STATS(Memory, Local_graph_size,);
103  RTABMAP_STATS(Memory, Small_movement,);
104  RTABMAP_STATS(Memory, Fast_movement,);
105  RTABMAP_STATS(Memory, Odometry_variance_ang,);
106  RTABMAP_STATS(Memory, Odometry_variance_lin,);
107  RTABMAP_STATS(Memory, Distance_travelled, m);
108  RTABMAP_STATS(Memory, RAM_usage, MB);
109  RTABMAP_STATS(Memory, Triangulated_points, );
110 
111  RTABMAP_STATS(Timing, Memory_update, ms);
112  RTABMAP_STATS(Timing, Neighbor_link_refining, ms);
113  RTABMAP_STATS(Timing, Proximity_by_time, ms);
114  RTABMAP_STATS(Timing, Proximity_by_space_visual, ms);
115  RTABMAP_STATS(Timing, Proximity_by_space, ms);
116  RTABMAP_STATS(Timing, Cleaning_neighbors, ms);
117  RTABMAP_STATS(Timing, Reactivation, ms);
118  RTABMAP_STATS(Timing, Add_loop_closure_link, ms);
119  RTABMAP_STATS(Timing, Map_optimization, ms);
120  RTABMAP_STATS(Timing, Likelihood_computation, ms);
121  RTABMAP_STATS(Timing, Posterior_computation, ms);
122  RTABMAP_STATS(Timing, Hypotheses_creation, ms);
123  RTABMAP_STATS(Timing, Hypotheses_validation, ms);
124  RTABMAP_STATS(Timing, Statistics_creation, ms);
125  RTABMAP_STATS(Timing, Memory_cleanup, ms);
126  RTABMAP_STATS(Timing, Total, ms);
127  RTABMAP_STATS(Timing, Forgetting, ms);
128  RTABMAP_STATS(Timing, Joining_trash, ms);
129  RTABMAP_STATS(Timing, Emptying_trash, ms);
130 
131  RTABMAP_STATS(TimingMem, Pre_update, ms);
132  RTABMAP_STATS(TimingMem, Signature_creation, ms);
133  RTABMAP_STATS(TimingMem, Rehearsal, ms);
134  RTABMAP_STATS(TimingMem, Keypoints_detection, ms);
135  RTABMAP_STATS(TimingMem, Subpixel, ms);
136  RTABMAP_STATS(TimingMem, Stereo_correspondences, ms);
137  RTABMAP_STATS(TimingMem, Descriptors_extraction, ms);
138  RTABMAP_STATS(TimingMem, Rectification, ms);
139  RTABMAP_STATS(TimingMem, Keypoints_3D, ms);
140  RTABMAP_STATS(TimingMem, Keypoints_3D_motion, ms);
141  RTABMAP_STATS(TimingMem, Joining_dictionary_update, ms);
142  RTABMAP_STATS(TimingMem, Add_new_words, ms);
143  RTABMAP_STATS(TimingMem, Compressing_data, ms);
144  RTABMAP_STATS(TimingMem, Post_decimation, ms);
145  RTABMAP_STATS(TimingMem, Scan_filtering, ms);
146  RTABMAP_STATS(TimingMem, Occupancy_grid, ms);
147 
148  RTABMAP_STATS(Keypoint, Dictionary_size, words);
149  RTABMAP_STATS(Keypoint, Indexed_words, words);
150  RTABMAP_STATS(Keypoint, Index_memory_usage, KB);
151 
152  RTABMAP_STATS(Gt, Translational_rmse, m);
153  RTABMAP_STATS(Gt, Translational_mean, m);
154  RTABMAP_STATS(Gt, Translational_median, m);
155  RTABMAP_STATS(Gt, Translational_std, m);
156  RTABMAP_STATS(Gt, Translational_min, m);
157  RTABMAP_STATS(Gt, Translational_max, m);
158  RTABMAP_STATS(Gt, Rotational_rmse, deg);
159  RTABMAP_STATS(Gt, Rotational_mean, deg);
160  RTABMAP_STATS(Gt, Rotational_median, deg);
161  RTABMAP_STATS(Gt, Rotational_std, deg);
162  RTABMAP_STATS(Gt, Rotational_min, deg);
163  RTABMAP_STATS(Gt, Rotational_max, deg);
164 
165 public:
166  static const std::map<std::string, float> & defaultData();
167  static std::string serializeData(const std::map<std::string, float> & data);
168  static std::map<std::string, float> deserializeData(const std::string & data);
169 
170 public:
171  Statistics();
172  virtual ~Statistics();
173 
174  // name format = "Grp/Name/unit"
175  void addStatistic(const std::string & name, float value);
176 
177  // setters
178  void setExtended(bool extended) {_extended = extended;}
179  void setRefImageId(int refImageId) {_refImageId = refImageId;}
180  void setLoopClosureId(int loopClosureId) {_loopClosureId = loopClosureId;}
181  void setProximityDetectionId(int id) {_proximiyDetectionId = id;}
182  void setStamp(double stamp) {_stamp = stamp;}
183 
184  void setSignatures(const std::map<int, Signature> & signatures) {_signatures = signatures;}
185 
186  void setPoses(const std::map<int, Transform> & poses) {_poses = poses;}
187  void setConstraints(const std::multimap<int, Link> & constraints) {_constraints = constraints;}
188  void setMapCorrection(const Transform & mapCorrection) {_mapCorrection = mapCorrection;}
189  void setLoopClosureTransform(const Transform & loopClosureTransform) {_loopClosureTransform = loopClosureTransform;}
190  void setLocalizationCovariance(const cv::Mat & covariance) {_localizationCovariance = covariance;}
191  void setWeights(const std::map<int, int> & weights) {_weights = weights;}
192  void setPosterior(const std::map<int, float> & posterior) {_posterior = posterior;}
193  void setLikelihood(const std::map<int, float> & likelihood) {_likelihood = likelihood;}
194  void setRawLikelihood(const std::map<int, float> & rawLikelihood) {_rawLikelihood = rawLikelihood;}
195  void setLocalPath(const std::vector<int> & localPath) {_localPath=localPath;}
196  void setCurrentGoalId(int goal) {_currentGoalId=goal;}
197  void setReducedIds(const std::map<int, int> & reducedIds) {_reducedIds = reducedIds;}
198  void setWmState(const std::vector<int> & state) {_wmState = state;}
199 
200  // getters
201  bool extended() const {return _extended;}
202  int refImageId() const {return _refImageId;}
203  int loopClosureId() const {return _loopClosureId;}
204  int proximityDetectionId() const {return _proximiyDetectionId;}
205  double stamp() const {return _stamp;}
206 
207  const std::map<int, Signature> & getSignatures() const {return _signatures;}
208 
209  const std::map<int, Transform> & poses() const {return _poses;}
210  const std::multimap<int, Link> & constraints() const {return _constraints;}
211  const Transform & mapCorrection() const {return _mapCorrection;}
212  const Transform & loopClosureTransform() const {return _loopClosureTransform;}
213  const cv::Mat & localizationCovariance() const {return _localizationCovariance;}
214  const std::map<int, int> & weights() const {return _weights;}
215  const std::map<int, float> & posterior() const {return _posterior;}
216  const std::map<int, float> & likelihood() const {return _likelihood;}
217  const std::map<int, float> & rawLikelihood() const {return _rawLikelihood;}
218  const std::vector<int> & localPath() const {return _localPath;}
219  int currentGoalId() const {return _currentGoalId;}
220  const std::map<int, int> & reducedIds() const {return _reducedIds;}
221  const std::vector<int> & wmState() const {return _wmState;}
222 
223  const std::map<std::string, float> & data() const {return _data;}
224 
225 private:
226  bool _extended; // 0 -> only loop closure and last signature ID fields are filled
227 
231  double _stamp;
232 
233  std::map<int, Signature> _signatures;
234 
235  std::map<int, Transform> _poses;
236  std::multimap<int, Link> _constraints;
240 
241  std::map<int, int> _weights;
242  std::map<int, float> _posterior;
243  std::map<int, float> _likelihood;
244  std::map<int, float> _rawLikelihood;
245 
246  std::vector<int> _localPath;
248 
249  std::map<int, int> _reducedIds;
250 
251  std::vector<int> _wmState;
252 
253  // Format for statistics (Plottable statistics must go in that map) :
254  // {"Group/Name/Unit", value}
255  // Example : {"Timing/Total time/ms", 500.0f}
256  std::map<std::string, float> _data;
257  static std::map<std::string, float> _defaultData;
259  // end extended data
260 };
261 
262 }// end namespace rtabmap
263 
264 #endif /* STATISTICS_H_ */
bool extended() const
Definition: Statistics.h:201
cv::Mat _localizationCovariance
Definition: Statistics.h:239
const cv::Mat & localizationCovariance() const
Definition: Statistics.h:213
std::map< int, int > _weights
Definition: Statistics.h:241
const std::map< int, Signature > & getSignatures() const
Definition: Statistics.h:207
std::multimap< int, Link > _constraints
Definition: Statistics.h:236
void setRefImageId(int refImageId)
Definition: Statistics.h:179
const std::map< int, float > & likelihood() const
Definition: Statistics.h:216
std::map< std::string, float > _data
Definition: Statistics.h:256
void setPosterior(const std::map< int, float > &posterior)
Definition: Statistics.h:192
int proximityDetectionId() const
Definition: Statistics.h:204
void setRawLikelihood(const std::map< int, float > &rawLikelihood)
Definition: Statistics.h:194
const std::map< int, float > & posterior() const
Definition: Statistics.h:215
void setReducedIds(const std::map< int, int > &reducedIds)
Definition: Statistics.h:197
void setProximityDetectionId(int id)
Definition: Statistics.h:181
std::map< int, float > _rawLikelihood
Definition: Statistics.h:244
void setCurrentGoalId(int goal)
Definition: Statistics.h:196
void setConstraints(const std::multimap< int, Link > &constraints)
Definition: Statistics.h:187
const std::map< int, int > & reducedIds() const
Definition: Statistics.h:220
const std::map< int, int > & weights() const
Definition: Statistics.h:214
Transform _loopClosureTransform
Definition: Statistics.h:238
std::map< int, int > _reducedIds
Definition: Statistics.h:249
#define RTABMAP_EXP
Definition: RtabmapExp.h:38
const std::map< std::string, float > & data() const
Definition: Statistics.h:223
void setLocalPath(const std::vector< int > &localPath)
Definition: Statistics.h:195
static std::map< std::string, float > _defaultData
Definition: Statistics.h:257
void setLocalizationCovariance(const cv::Mat &covariance)
Definition: Statistics.h:190
void setPoses(const std::map< int, Transform > &poses)
Definition: Statistics.h:186
std::map< int, float > _likelihood
Definition: Statistics.h:243
void setExtended(bool extended)
Definition: Statistics.h:178
static bool _defaultDataInitialized
Definition: Statistics.h:258
#define KB
Definition: lz4.c:226
std::vector< int > _localPath
Definition: Statistics.h:246
void setLoopClosureId(int loopClosureId)
Definition: Statistics.h:180
#define RTABMAP_STATS(PREFIX, NAME, UNIT)
Definition: Statistics.h:43
int loopClosureId() const
Definition: Statistics.h:203
std::map< int, Signature > _signatures
Definition: Statistics.h:233
const Transform & loopClosureTransform() const
Definition: Statistics.h:212
RecoveryProgressState state
std::vector< int > _wmState
Definition: Statistics.h:251
void setMapCorrection(const Transform &mapCorrection)
Definition: Statistics.h:188
void setLikelihood(const std::map< int, float > &likelihood)
Definition: Statistics.h:193
const std::map< int, Transform > & poses() const
Definition: Statistics.h:209
void setSignatures(const std::map< int, Signature > &signatures)
Definition: Statistics.h:184
void setWmState(const std::vector< int > &state)
Definition: Statistics.h:198
void setStamp(double stamp)
Definition: Statistics.h:182
const std::vector< int > & wmState() const
Definition: Statistics.h:221
const std::multimap< int, Link > & constraints() const
Definition: Statistics.h:210
void setWeights(const std::map< int, int > &weights)
Definition: Statistics.h:191
std::map< int, Transform > _poses
Definition: Statistics.h:235
int currentGoalId() const
Definition: Statistics.h:219
#define MB
Definition: lz4.c:227
void setLoopClosureTransform(const Transform &loopClosureTransform)
Definition: Statistics.h:189
const Transform & mapCorrection() const
Definition: Statistics.h:211
const std::vector< int > & localPath() const
Definition: Statistics.h:218
int refImageId() const
Definition: Statistics.h:202
std::map< int, float > _posterior
Definition: Statistics.h:242
Transform _mapCorrection
Definition: Statistics.h:237
const std::map< int, float > & rawLikelihood() const
Definition: Statistics.h:217
double stamp() const
Definition: Statistics.h:205


rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:43:40