RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
rtabmap::Statistics Class Reference

Collects and manages runtime statistics for RTAB-Map. More...

#include <Statistics.h>

Public Member Functions

 Statistics ()
 Default constructor.
 
virtual ~Statistics ()
 Virtual destructor.
 
void addStatistic (const std::string &name, float value)
 Adds a statistic value to the data map.
 
void setExtended (bool extended)
 Sets whether extended statistics mode is enabled.
 
void setRefImageId (int id)
 Sets the reference image ID (current/last processed signature ID)
 
void setRefImageMapId (int id)
 Sets the reference image map ID.
 
void setLoopClosureId (int id)
 Sets the loop closure detection ID.
 
void setLoopClosureMapId (int id)
 Sets the loop closure map ID.
 
void setProximityDetectionId (int id)
 Sets the proximity detection ID.
 
void setProximityDetectionMapId (int id)
 Sets the proximity detection map ID.
 
void setStamp (double stamp)
 Sets the timestamp for these statistics.
 
RTABMAP_DEPRECATED void setLastSignatureData (const Signature &data)
 Sets the last signature data (deprecated)
 
void addSignatureData (const Signature &data)
 Adds signature data to the statistics.
 
void setSignaturesData (const std::map< int, Signature > &data)
 Sets all signature data at once.
 
void setPoses (const std::map< int, Transform > &poses)
 Sets the pose graph (node poses)
 
void setConstraints (const std::multimap< int, Link > &constraints)
 Sets the constraint graph (links between nodes)
 
void setMapCorrection (const Transform &mapCorrection)
 Sets the map correction transform.
 
void setLoopClosureTransform (const Transform &loopClosureTransform)
 Sets the loop closure transform.
 
void setLocalizationCovariance (const cv::Mat &covariance)
 Sets the localization covariance matrix.
 
void setLabels (const std::map< int, std::string > &labels)
 Sets node labels.
 
void setWeights (const std::map< int, int > &weights)
 Sets node weights.
 
void setPosterior (const std::map< int, float > &posterior)
 Sets posterior probabilities for loop closure hypotheses.
 
void setLikelihood (const std::map< int, float > &likelihood)
 Sets likelihood values for loop closure hypotheses.
 
void setRawLikelihood (const std::map< int, float > &rawLikelihood)
 Sets raw likelihood values (before normalization)
 
void setLocalPath (const std::vector< int > &localPath)
 Sets the local path (sequence of node IDs)
 
void setCurrentGoalId (int goal)
 Sets the current goal node ID.
 
void setReducedIds (const std::map< int, int > &reducedIds)
 Sets the reduced IDs mapping.
 
void setWmState (const std::vector< int > &state)
 Sets the working memory state.
 
void setOdomCachePoses (const std::map< int, Transform > &poses)
 Sets odometry cache poses.
 
void setOdomCacheConstraints (const std::multimap< int, Link > &constraints)
 Sets odometry cache constraints.
 
bool extended () const
 Returns whether extended statistics mode is enabled.
 
int refImageId () const
 Returns the reference image ID.
 
int refImageMapId () const
 Returns the reference image map ID.
 
int loopClosureId () const
 Returns the loop closure detection ID.
 
int loopClosureMapId () const
 Returns the loop closure map ID.
 
int proximityDetectionId () const
 Returns the proximity detection ID.
 
int proximityDetectionMapId () const
 Returns the proximity detection map ID.
 
double stamp () const
 Returns the timestamp.
 
const SignaturegetLastSignatureData () const
 Returns the last signature data.
 
const std::map< int, Signature > & getSignaturesData () const
 Returns all signature data.
 
const std::map< int, Transform > & poses () const
 Returns the pose graph.
 
const std::multimap< int, Link > & constraints () const
 Returns the constraint graph.
 
const TransformmapCorrection () const
 Returns the map correction transform.
 
const TransformloopClosureTransform () const
 Returns the loop closure transform.
 
const cv::Mat & localizationCovariance () const
 Returns the localization covariance matrix.
 
const std::map< int, std::string > & labels () const
 Returns node labels.
 
const std::map< int, int > & weights () const
 Returns node weights.
 
const std::map< int, float > & posterior () const
 Returns posterior probabilities.
 
const std::map< int, float > & likelihood () const
 Returns likelihood values.
 
const std::map< int, float > & rawLikelihood () const
 Returns raw likelihood values.
 
const std::vector< int > & localPath () const
 Returns the local path.
 
int currentGoalId () const
 Returns the current goal node ID.
 
const std::map< int, int > & reducedIds () const
 Returns the reduced IDs mapping.
 
const std::vector< int > & wmState () const
 Returns the working memory state.
 
const std::map< int, Transform > & odomCachePoses () const
 Returns odometry cache poses.
 
const std::multimap< int, Link > & odomCacheConstraints () const
 Returns odometry cache constraints.
 
const std::map< std::string, float > & data () const
 Returns the statistics data map.
 

Static Public Member Functions

static const std::map< std::string, float > & defaultData ()
 Returns the default statistics data map.
 
static std::string serializeData (const std::map< std::string, float > &data)
 Serializes a statistics data map to a string.
 
static std::map< std::string, float > deserializeData (const std::string &data)
 Deserializes a statistics data map from a string.
 

Detailed Description

Collects and manages runtime statistics for RTAB-Map.

The Statistics class provides a comprehensive system for collecting, storing, and managing various runtime statistics about RTAB-Map's operation. Statistics are organized into groups such as:

  • Loop: Loop closure detection, hypothesis validation, optimization errors
  • Proximity: Proximity-based detection statistics
  • Memory: Working memory size, database usage, signature management
  • Timing: Performance measurements for various operations
  • Keypoint: Visual word dictionary and feature statistics
  • Gt: Ground truth comparison statistics

Statistics are stored in a map with keys in the format "Group/Name/Unit" (e.g., "Timing/Total time/ms"). This hierarchical naming allows for easy categorization and plotting.

The class supports two modes:

  • Basic mode (extended() == false): Only stores loop closure and last signature ID fields
  • Extended mode (extended() == true): Stores all available statistics including poses, constraints, likelihoods, posteriors, and detailed timing information

Statistics can be serialized to/from strings for storage in databases or transmission over networks.

Note
Statistics are typically created by RTAB-Map's core components (Rtabmap, Memory, etc.) and can be retrieved for analysis, visualization, or debugging purposes.

Definition at line 107 of file Statistics.h.

Constructor & Destructor Documentation

◆ Statistics()

rtabmap::Statistics::Statistics ( )

Default constructor.

Creates a new Statistics object in basic mode (extended = false). Initializes all ID fields to 0 or -1, and timestamp to 0.0.

Note
The first Statistics object constructed will initialize the default data map.

Member Function Documentation

◆ defaultData()

static const std::map< std::string, float > & rtabmap::Statistics::defaultData ( )
static

Returns the default statistics data map.

Returns a map containing all predefined statistics with their default values (0.0). This map is initialized when the first Statistics object is constructed.

Returns
Const reference to the default statistics data map

◆ serializeData()

static std::string rtabmap::Statistics::serializeData ( const std::map< std::string, float > &  data)
static

Serializes a statistics data map to a string.

Converts a statistics data map into a serialized string format suitable for storage or transmission. The format is: "key1:value1;key2:value2;..." where values are formatted as numbers with dots (not commas) as decimal separators (independent of the system's locale).

Parameters
dataThe statistics data map to serialize
Returns
Serialized string representation of the data
Note
Empty maps result in empty strings
See also
deserializeData()

◆ deserializeData()

static std::map< std::string, float > rtabmap::Statistics::deserializeData ( const std::string &  data)
static

Deserializes a statistics data map from a string.

Parses a serialized statistics string back into a data map. The string format should be: "key1:value1;key2:value2;..." as produced by serializeData().

Parameters
dataThe serialized string to parse
Returns
Deserialized statistics data map
Note
Invalid entries (missing colons, malformed values) are silently skipped
See also
serializeData()

◆ addStatistic()

void rtabmap::Statistics::addStatistic ( const std::string &  name,
float  value 
)

Adds a statistic value to the data map.

Adds or updates a statistic in the internal data map. The name should follow the format "Group/Name/Unit" (e.g., "Timing/Total time/ms").

Parameters
nameThe statistic name in the format "Group/Name/Unit"
valueThe statistic value to store
Note
If a statistic with the same name already exists, it will be overwritten.
Use the static methods generated by RTABMAP_STATS() to get standardized names:
statistics.addStatistic(Statistics::kTimingTotal(), 500.0f);

◆ setExtended()

void rtabmap::Statistics::setExtended ( bool  extended)
inline

Sets whether extended statistics mode is enabled.

In basic mode (extended = false), only loop closure and last signature ID fields are filled. In extended mode (extended = true), all available statistics including poses, constraints, likelihoods, posteriors, and detailed timing information are stored.

Parameters
extendedTrue to enable extended mode, false for basic mode

Definition at line 367 of file Statistics.h.

◆ setRefImageId()

void rtabmap::Statistics::setRefImageId ( int  id)
inline

Sets the reference image ID (current/last processed signature ID)

Parameters
idThe signature ID

Definition at line 373 of file Statistics.h.

◆ setRefImageMapId()

void rtabmap::Statistics::setRefImageMapId ( int  id)
inline

Sets the reference image map ID.

Parameters
idThe map ID associated with the reference image

Definition at line 379 of file Statistics.h.

◆ setLoopClosureId()

void rtabmap::Statistics::setLoopClosureId ( int  id)
inline

Sets the loop closure detection ID.

Parameters
idThe signature ID where a loop closure was detected (0 if none)

Definition at line 385 of file Statistics.h.

◆ setLoopClosureMapId()

void rtabmap::Statistics::setLoopClosureMapId ( int  id)
inline

Sets the loop closure map ID.

Parameters
idThe map ID associated with the loop closure

Definition at line 391 of file Statistics.h.

◆ setProximityDetectionId()

void rtabmap::Statistics::setProximityDetectionId ( int  id)
inline

Sets the proximity detection ID.

Parameters
idThe signature ID where proximity was detected (0 if none)

Definition at line 397 of file Statistics.h.

◆ setProximityDetectionMapId()

void rtabmap::Statistics::setProximityDetectionMapId ( int  id)
inline

Sets the proximity detection map ID.

Parameters
idThe map ID associated with the proximity detection

Definition at line 403 of file Statistics.h.

◆ setStamp()

void rtabmap::Statistics::setStamp ( double  stamp)
inline

Sets the timestamp for these statistics.

Parameters
stampThe timestamp (typically in seconds since epoch)

Definition at line 409 of file Statistics.h.

◆ setLastSignatureData()

RTABMAP_DEPRECATED void rtabmap::Statistics::setLastSignatureData ( const Signature data)

Sets the last signature data (deprecated)

Deprecated:
Use addSignatureData() instead

This method is deprecated. Use addSignatureData() instead, which allows storing multiple signatures.

◆ addSignatureData()

void rtabmap::Statistics::addSignatureData ( const Signature data)
inline

Adds signature data to the statistics.

Adds a signature to the internal signatures data map. Multiple signatures can be stored, indexed by their ID.

Parameters
dataThe signature to add
Note
If a signature with the same ID already exists, it will be overwritten.

Definition at line 430 of file Statistics.h.

◆ setSignaturesData()

void rtabmap::Statistics::setSignaturesData ( const std::map< int, Signature > &  data)
inline

Sets all signature data at once.

Parameters
dataMap of signature IDs to Signature objects

Definition at line 436 of file Statistics.h.

◆ setPoses()

void rtabmap::Statistics::setPoses ( const std::map< int, Transform > &  poses)
inline

Sets the pose graph (node poses)

Sets the complete pose graph, mapping node IDs to their Transform poses. Used in extended mode for visualization and analysis.

Parameters
posesMap of node IDs to their poses

Definition at line 446 of file Statistics.h.

◆ setConstraints()

void rtabmap::Statistics::setConstraints ( const std::multimap< int, Link > &  constraints)
inline

Sets the constraint graph (links between nodes)

Sets the complete constraint graph, mapping node IDs to their Link constraints. Used in extended mode for visualization and analysis.

Parameters
constraintsMultimap of node IDs to their links (a node can have multiple links)

Definition at line 456 of file Statistics.h.

◆ setMapCorrection()

void rtabmap::Statistics::setMapCorrection ( const Transform mapCorrection)
inline

Sets the map correction transform.

The map correction transform represents the transformation from the map fixed frame to the odometry fixed frame. This transform is typically updated after graph optimization to transform the odometry pose in map frame.

Parameters
mapCorrectionThe pose of odometry frame in map coordinate system

Definition at line 467 of file Statistics.h.

◆ setLoopClosureTransform()

void rtabmap::Statistics::setLoopClosureTransform ( const Transform loopClosureTransform)
inline

Sets the loop closure transform.

The transform between the current pose and the loop closure pose.

Parameters
loopClosureTransformThe loop closure transform

Definition at line 476 of file Statistics.h.

◆ setLocalizationCovariance()

void rtabmap::Statistics::setLocalizationCovariance ( const cv::Mat &  covariance)
inline

Sets the localization covariance matrix.

The covariance matrix representing the uncertainty in the current localization estimate.

Parameters
covarianceThe covariance matrix (typically 6x6 for 3D pose)

Definition at line 485 of file Statistics.h.

◆ setLabels()

void rtabmap::Statistics::setLabels ( const std::map< int, std::string > &  labels)
inline

Sets node labels.

Parameters
labelsMap of node IDs to their string labels

Definition at line 491 of file Statistics.h.

◆ setWeights()

void rtabmap::Statistics::setWeights ( const std::map< int, int > &  weights)
inline

Sets node weights.

Parameters
weightsMap of node IDs to their integer weights

Definition at line 497 of file Statistics.h.

◆ setPosterior()

void rtabmap::Statistics::setPosterior ( const std::map< int, float > &  posterior)
inline

Sets posterior probabilities for loop closure hypotheses.

Parameters
posteriorMap of node IDs to their posterior probabilities

Definition at line 504 of file Statistics.h.

◆ setLikelihood()

void rtabmap::Statistics::setLikelihood ( const std::map< int, float > &  likelihood)
inline

Sets likelihood values for loop closure hypotheses.

Likelihood values represent how well each hypothesis matches the current observation.

Parameters
likelihoodMap of node IDs to their likelihood values

Definition at line 513 of file Statistics.h.

◆ setRawLikelihood()

void rtabmap::Statistics::setRawLikelihood ( const std::map< int, float > &  rawLikelihood)
inline

Sets raw likelihood values (before normalization)

Parameters
rawLikelihoodMap of node IDs to their raw likelihood values

Definition at line 519 of file Statistics.h.

◆ setLocalPath()

void rtabmap::Statistics::setLocalPath ( const std::vector< int > &  localPath)
inline

Sets the local path (sequence of node IDs)

The local path represents the sequence of next nodes to visit for path planning.

Parameters
localPathVector of node IDs in order of next nodes to visit

Definition at line 528 of file Statistics.h.

◆ setCurrentGoalId()

void rtabmap::Statistics::setCurrentGoalId ( int  goal)
inline

Sets the current goal node ID.

Parameters
goalThe goal node ID (0 if no goal)

Definition at line 534 of file Statistics.h.

◆ setReducedIds()

void rtabmap::Statistics::setReducedIds ( const std::map< int, int > &  reducedIds)
inline

Sets the reduced IDs mapping.

Maps original node IDs to reduced IDs, used for memory optimization.

Parameters
reducedIdsMap of original IDs to reduced IDs

Definition at line 543 of file Statistics.h.

◆ setWmState()

void rtabmap::Statistics::setWmState ( const std::vector< int > &  state)
inline

Sets the working memory state.

The working memory state is a vector of node IDs currently in working memory.

Parameters
stateVector of node IDs in working memory

Definition at line 552 of file Statistics.h.

◆ setOdomCachePoses()

void rtabmap::Statistics::setOdomCachePoses ( const std::map< int, Transform > &  poses)
inline

Sets odometry cache poses.

Cached odometry poses during localization mode.

Parameters
posesMap of node IDs to their cached odometry poses

Definition at line 561 of file Statistics.h.

◆ setOdomCacheConstraints()

void rtabmap::Statistics::setOdomCacheConstraints ( const std::multimap< int, Link > &  constraints)
inline

Sets odometry cache constraints.

Cached odometry constraints (links) between nodes.

Parameters
constraintsMultimap of node IDs to their cached odometry links

Definition at line 570 of file Statistics.h.

◆ extended()

bool rtabmap::Statistics::extended ( ) const
inline

Returns whether extended statistics mode is enabled.

Returns
True if extended mode, false if basic mode

Definition at line 578 of file Statistics.h.

◆ refImageId()

int rtabmap::Statistics::refImageId ( ) const
inline

Returns the reference image ID.

Returns
The signature ID (0 if not set)

Definition at line 584 of file Statistics.h.

◆ refImageMapId()

int rtabmap::Statistics::refImageMapId ( ) const
inline

Returns the reference image map ID.

Returns
The map ID (-1 if not set)

Definition at line 590 of file Statistics.h.

◆ loopClosureId()

int rtabmap::Statistics::loopClosureId ( ) const
inline

Returns the loop closure detection ID.

Returns
The signature ID where loop closure was detected (0 if none)

Definition at line 596 of file Statistics.h.

◆ loopClosureMapId()

int rtabmap::Statistics::loopClosureMapId ( ) const
inline

Returns the loop closure map ID.

Returns
The map ID associated with the loop closure (-1 if not set)

Definition at line 602 of file Statistics.h.

◆ proximityDetectionId()

int rtabmap::Statistics::proximityDetectionId ( ) const
inline

Returns the proximity detection ID.

Returns
The signature ID where proximity was detected (0 if none)

Definition at line 608 of file Statistics.h.

◆ proximityDetectionMapId()

int rtabmap::Statistics::proximityDetectionMapId ( ) const
inline

Returns the proximity detection map ID.

Returns
The map ID associated with the proximity detection (-1 if not set)

Definition at line 614 of file Statistics.h.

◆ stamp()

double rtabmap::Statistics::stamp ( ) const
inline

Returns the timestamp.

Returns
The timestamp (0.0 if not set)

Definition at line 620 of file Statistics.h.

◆ getLastSignatureData()

const Signature & rtabmap::Statistics::getLastSignatureData ( ) const
inline

Returns the last signature data.

Returns the most recently added signature (by ID). If no signatures are stored, returns a dummy empty signature.

Returns
Reference to the last signature data

Definition at line 630 of file Statistics.h.

◆ getSignaturesData()

const std::map< int, Signature > & rtabmap::Statistics::getSignaturesData ( ) const
inline

Returns all signature data.

Returns
Const reference to the map of signature IDs to Signature objects

Definition at line 636 of file Statistics.h.

◆ poses()

const std::map< int, Transform > & rtabmap::Statistics::poses ( ) const
inline

Returns the pose graph.

Returns
Const reference to the map of node IDs to poses

Definition at line 642 of file Statistics.h.

◆ constraints()

const std::multimap< int, Link > & rtabmap::Statistics::constraints ( ) const
inline

Returns the constraint graph.

Returns
Const reference to the multimap of node IDs to links

Definition at line 648 of file Statistics.h.

◆ mapCorrection()

const Transform & rtabmap::Statistics::mapCorrection ( ) const
inline

Returns the map correction transform.

Returns the transform from the map fixed frame to the odometry fixed frame.

Returns
Const reference to the map correction transform

Definition at line 657 of file Statistics.h.

◆ loopClosureTransform()

const Transform & rtabmap::Statistics::loopClosureTransform ( ) const
inline

Returns the loop closure transform.

Returns
Const reference to the loop closure transform

Definition at line 663 of file Statistics.h.

◆ localizationCovariance()

const cv::Mat & rtabmap::Statistics::localizationCovariance ( ) const
inline

Returns the localization covariance matrix.

Returns
Const reference to the covariance matrix (may be empty)

Definition at line 669 of file Statistics.h.

◆ labels()

const std::map< int, std::string > & rtabmap::Statistics::labels ( ) const
inline

Returns node labels.

Returns
Const reference to the map of node IDs to labels

Definition at line 675 of file Statistics.h.

◆ weights()

const std::map< int, int > & rtabmap::Statistics::weights ( ) const
inline

Returns node weights.

Returns
Const reference to the map of node IDs to weights

Definition at line 681 of file Statistics.h.

◆ posterior()

const std::map< int, float > & rtabmap::Statistics::posterior ( ) const
inline

Returns posterior probabilities.

Returns
Const reference to the map of node IDs to posterior probabilities

Definition at line 687 of file Statistics.h.

◆ likelihood()

const std::map< int, float > & rtabmap::Statistics::likelihood ( ) const
inline

Returns likelihood values.

Returns
Const reference to the map of node IDs to likelihood values

Definition at line 693 of file Statistics.h.

◆ rawLikelihood()

const std::map< int, float > & rtabmap::Statistics::rawLikelihood ( ) const
inline

Returns raw likelihood values.

Returns
Const reference to the map of node IDs to raw likelihood values

Definition at line 699 of file Statistics.h.

◆ localPath()

const std::vector< int > & rtabmap::Statistics::localPath ( ) const
inline

Returns the local path.

Returns
Const reference to the vector of node IDs

Definition at line 705 of file Statistics.h.

◆ currentGoalId()

int rtabmap::Statistics::currentGoalId ( ) const
inline

Returns the current goal node ID.

Returns
The goal node ID (0 if no goal)

Definition at line 711 of file Statistics.h.

◆ reducedIds()

const std::map< int, int > & rtabmap::Statistics::reducedIds ( ) const
inline

Returns the reduced IDs mapping.

Returns
Const reference to the map of original IDs to reduced IDs

Definition at line 717 of file Statistics.h.

◆ wmState()

const std::vector< int > & rtabmap::Statistics::wmState ( ) const
inline

Returns the working memory state.

Returns
Const reference to the vector of node IDs in working memory

Definition at line 723 of file Statistics.h.

◆ odomCachePoses()

const std::map< int, Transform > & rtabmap::Statistics::odomCachePoses ( ) const
inline

Returns odometry cache poses.

Returns
Const reference to the map of node IDs to cached odometry poses

Definition at line 729 of file Statistics.h.

◆ odomCacheConstraints()

const std::multimap< int, Link > & rtabmap::Statistics::odomCacheConstraints ( ) const
inline

Returns odometry cache constraints.

Returns
Const reference to the multimap of node IDs to cached odometry links

Definition at line 735 of file Statistics.h.

◆ data()

const std::map< std::string, float > & rtabmap::Statistics::data ( ) const
inline

Returns the statistics data map.

Returns the map containing all plottable statistics in the format "Group/Name/Unit" -> value. This is the main data structure for storing numeric statistics.

Returns
Const reference to the statistics data map
Note
Use addStatistic() to add values to this map
Use serializeData() to convert this map to a string for storage

Definition at line 748 of file Statistics.h.


The documentation for this class was generated from the following file: