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

Represents a node in RTAB-Map's pose graph. More...

#include <Signature.h>

Public Member Functions

 Signature ()
 Default constructor.
 
 Signature (int id, int mapId=-1, int weight=0, double stamp=0.0, const std::string &label=std::string(), const Transform &pose=Transform(), const Transform &groundTruthPose=Transform(), const SensorData &sensorData=SensorData())
 Constructor with explicit parameters.
 
 Signature (const SensorData &data)
 Constructor from sensor data.
 
virtual ~Signature ()
 Virtual destructor.
 
float compareTo (const Signature &signature) const
 Compares this signature to another signature.
 
bool isBadSignature () const
 Checks if this signature is considered "bad".
 
int id () const
 Returns the signature ID.
 
int mapId () const
 Returns the map ID.
 
void setWeight (int weight)
 Sets the weight/importance of this signature.
 
int getWeight () const
 Returns the weight/importance of this signature.
 
void setLabel (const std::string &label)
 Sets a label/name for this signature.
 
const std::string & getLabel () const
 Returns the label/name of this signature.
 
double getStamp () const
 Returns the timestamp of this signature.
 
void addLinks (const std::list< Link > &links)
 Adds multiple links from a list.
 
void addLinks (const std::map< int, Link > &links)
 Adds multiple links from a map.
 
void addLink (const Link &link)
 Adds a single link to this signature.
 
bool hasLink (int idTo, Link::Type type=Link::kUndef) const
 Checks if this signature has a link to a target signature.
 
void changeLinkIds (int idFrom, int idTo)
 Changes all link target IDs from one value to another.
 
void removeLinks (bool keepSelfReferringLinks=false)
 Removes all links from this signature.
 
void removeLink (int idTo)
 Removes a specific link to a target signature.
 
void removeVirtualLinks ()
 Removes all virtual links from this signature.
 
void addLandmark (const Link &landmark)
 Adds a landmark observation to this signature.
 
const std::map< int, Link > & getLandmarks () const
 Returns all landmark observations.
 
void removeLandmarks ()
 Removes all landmark observations.
 
void removeLandmark (int landmarkId)
 Removes a specific landmark observation.
 
void setSaved (bool saved)
 Sets whether this signature has been saved to the database.
 
void setModified (bool modified)
 Sets the modification flag for this signature.
 
const std::multimap< int, Link > & getLinks () const
 Returns all links from this signature.
 
bool isSaved () const
 Checks if this signature has been saved to the database.
 
bool isModified () const
 Checks if this signature has been modified.
 
bool isLinksModified () const
 Checks if the links have been modified.
 
void removeAllWords ()
 Removes all visual words from this signature.
 
void changeWordsRef (int oldWordId, int activeWordId)
 Changes visual word references from one word ID to another.
 
void setWords (const std::multimap< int, int > &words, const std::vector< cv::KeyPoint > &keypoints, const std::vector< cv::Point3f > &words3, const cv::Mat &descriptors)
 Sets all visual words for this signature.
 
bool isEnabled () const
 Checks if this signature is enabled.
 
void setEnabled (bool enabled)
 Sets whether this signature is enabled.
 
const std::multimap< int, int > & getWords () const
 Returns the visual words map.
 
const std::vector< cv::KeyPoint > & getWordsKpts () const
 Returns the keypoints associated with visual words.
 
int getInvalidWordsCount () const
 Returns the count of invalid visual words.
 
const std::map< int, int > & getWordsChanged () const
 Returns the word ID change mapping.
 
const cv::Mat & getWordsDescriptors () const
 Returns the feature descriptors for visual words.
 
void setWordsDescriptors (const cv::Mat &descriptors)
 Sets the feature descriptors for visual words.
 
void setPose (const Transform &pose)
 Sets the pose of this signature.
 
void setGroundTruthPose (const Transform &pose)
 Sets the ground truth pose for evaluation.
 
void setVelocity (float vx, float vy, float vz, float vroll, float vpitch, float vyaw)
 Sets the velocity of this signature.
 
const std::vector< cv::Point3f > & getWords3 () const
 Returns the 3D points of visual words.
 
const TransformgetPose () const
 Returns the pose of this signature.
 
cv::Mat getPoseCovariance () const
 Gets the pose covariance matrix.
 
const TransformgetGroundTruthPose () const
 Returns the ground truth pose.
 
const std::vector< float > & getVelocity () const
 Returns the velocity of this signature.
 
SensorDatasensorData ()
 Returns mutable access to the sensor data.
 
const SensorDatasensorData () const
 Returns const access to the sensor data.
 
unsigned long getMemoryUsed (bool withSensorData=true) const
 Computes the memory usage of this signature.
 

Detailed Description

Represents a node in RTAB-Map's pose graph.

The Signature class is a fundamental building block of RTAB-Map's graph-based mapping system. Each signature represents a unique location or pose in the map and contains:

  • Visual words: Bag-of-words representation using visual features (keypoints, descriptors, 3D points) for place recognition
  • Links: Connections to other signatures (neighbors, loop closures, landmarks)
  • Pose information: Current pose, ground truth pose, velocity
  • Sensor data: Images, depth, laser scans, etc. captured at this location
  • Metadata: ID, map ID, timestamp, label, weight, modification flags

Signatures are used for:

  • Place recognition: Comparing signatures to detect loop closures
  • Graph construction: Building the pose graph through links
  • Localization: Matching current observations to stored signatures
  • Mapping: Storing sensor data, visual features and local occupancy grid for each location

The class tracks modification state to optimize database updates, and provides methods to manage visual words, links, landmarks, and pose information.

Note
Signatures are typically managed by the Memory class, which handles storage, retrieval, and graph operations.
See also
Link
SensorData
Memory

Definition at line 83 of file Signature.h.

Constructor & Destructor Documentation

◆ Signature() [1/3]

rtabmap::Signature::Signature ( )

Default constructor.

Creates an empty signature with invalid ID (0), default map ID (-1), and all fields initialized to default values.

◆ Signature() [2/3]

rtabmap::Signature::Signature ( int  id,
int  mapId = -1,
int  weight = 0,
double  stamp = 0.0,
const std::string &  label = std::string(),
const Transform pose = Transform(),
const Transform groundTruthPose = Transform(),
const SensorData sensorData = SensorData() 
)

Constructor with explicit parameters.

Creates a signature with the specified parameters. The sensor data ID will be automatically set to match the signature ID if not already set.

Parameters
idUnique signature ID (must be > 0 for valid signature)
mapIdMap ID this signature belongs to (default: -1 for no map)
weightWeight/importance of this signature (default: 0)
stampTimestamp in seconds (default: 0.0)
labelOptional label/name for this signature (default: empty)
poseCurrent pose of the signature (default: identity null transform)
groundTruthPoseGround truth pose for evaluation (default: null transform)
sensorDataSensor data captured at this location (default: empty)
Note
The signature is marked as modified and not saved by default.

◆ Signature() [3/3]

rtabmap::Signature::Signature ( const SensorData data)

Constructor from sensor data.

Creates a signature from sensor data. The signature ID is taken from the sensor data ID, and the ground truth pose is extracted from the sensor data if available.

Parameters
dataSensor data to create signature from
Note
The signature pose is initialized to identity transform.

Member Function Documentation

◆ compareTo()

float rtabmap::Signature::compareTo ( const Signature signature) const

Compares this signature to another signature.

Computes a similarity score between this signature and another signature based on their visual words. The comparison uses bag-of-words matching to determine how similar the two locations are.

Parameters
signatureThe signature to compare against
Returns
Similarity score between 0.0 and 1.0, where 1.0 means 100% similarity
Note
This method is used for loop closure detection and place recognition.

◆ isBadSignature()

bool rtabmap::Signature::isBadSignature ( ) const

Checks if this signature is considered "bad".

A signature is considered bad if it has no valid visual words (all words are invalid or the signature has no words at all). Bad signatures cannot be used for place recognition.

Returns
True if the signature has no valid visual words, false otherwise

◆ id()

int rtabmap::Signature::id ( ) const
inline

Returns the signature ID.

Returns
The unique signature ID (0 if invalid/uninitialized)

Definition at line 168 of file Signature.h.

◆ mapId()

int rtabmap::Signature::mapId ( ) const
inline

Returns the map ID.

Returns
The map ID this signature belongs to (-1 if no map assigned)

Definition at line 174 of file Signature.h.

◆ setWeight()

void rtabmap::Signature::setWeight ( int  weight)
inline

Sets the weight/importance of this signature.

The weight represents the importance or priority of this signature, typically set by Rehearsal mechanism (see Memory::rehearsal). Higher weights may be used to prioritize certain signatures during memory management or loop closure detection.

Parameters
weightThe weight value
Note
Marks the signature as modified if the weight changes. A signature already flagged as modified stays modified.

Definition at line 189 of file Signature.h.

◆ getWeight()

int rtabmap::Signature::getWeight ( ) const
inline

Returns the weight/importance of this signature.

Returns
The weight value

Definition at line 195 of file Signature.h.

◆ setLabel()

void rtabmap::Signature::setLabel ( const std::string &  label)
inline

Sets a label/name for this signature.

Labels are optional text identifiers that can be used to tag or categorize signatures (e.g., "room1", "corridor", "entrance").

Parameters
labelThe label string
Note
Marks the signature as modified if the label changes. A signature already flagged as modified stays modified.

Definition at line 208 of file Signature.h.

◆ getLabel()

const std::string & rtabmap::Signature::getLabel ( ) const
inline

Returns the label/name of this signature.

Returns
The label string (empty if not set)

Definition at line 214 of file Signature.h.

◆ getStamp()

double rtabmap::Signature::getStamp ( ) const
inline

Returns the timestamp of this signature.

Returns
Timestamp in seconds (typically seconds since epoch)

Definition at line 220 of file Signature.h.

◆ addLinks() [1/2]

void rtabmap::Signature::addLinks ( const std::list< Link > &  links)

Adds multiple links from a list.

Adds all links from the provided list to this signature's link collection.

Parameters
linksList of links to add
Note
Each link must have from() equal to this signature's ID.
Automatically marks links as modified.
See also
addLink()

◆ addLinks() [2/2]

void rtabmap::Signature::addLinks ( const std::map< int, Link > &  links)

Adds multiple links from a map.

Adds all links from the provided map to this signature's link collection.

Parameters
linksMap of target IDs to links
Note
Each link must have from() equal to this signature's ID.
The map's keys are the target IDs (to() values of the links).
Automatically marks links as modified.
See also
addLink()

◆ addLink()

void rtabmap::Signature::addLink ( const Link link)

Adds a single link to this signature.

Adds a link connecting this signature to another signature. The link represents a constraint in the pose graph (e.g., neighbor, loop closure).

Parameters
linkThe link to add
Note
The link's from() must equal this signature's ID.
The link's to() must be different from this signature's ID (except for self-referring links like pose priors or gravity).
Duplicate links to the same target are not allowed (assertion failure).
Automatically marks links as modified.

◆ hasLink()

bool rtabmap::Signature::hasLink ( int  idTo,
Link::Type  type = Link::kUndef 
) const

Checks if this signature has a link to a target signature.

Parameters
idToTarget signature ID (0 to check for any link of the specified type)
typeLink type to check for (default: Link::kUndef to check any type)
Returns
True if a matching link exists, false otherwise

◆ changeLinkIds()

void rtabmap::Signature::changeLinkIds ( int  idFrom,
int  idTo 
)

Changes all link target IDs from one value to another.

Updates all links that point to idFrom to point to idTo instead. This is useful when merging or reorganizing the graph.

Parameters
idFromOriginal target ID
idToNew target ID
Note
Automatically marks links as modified.

◆ removeLinks()

void rtabmap::Signature::removeLinks ( bool  keepSelfReferringLinks = false)

Removes all links from this signature.

Parameters
keepSelfReferringLinksIf true, preserves self-referring links (pose priors, gravity) that have from() == to()
Note
Automatically marks links as modified.

◆ removeLink()

void rtabmap::Signature::removeLink ( int  idTo)

Removes a specific link to a target signature.

Parameters
idToTarget signature ID of the link to remove
Note
Automatically marks links as modified.

◆ removeVirtualLinks()

void rtabmap::Signature::removeVirtualLinks ( )

Removes all virtual links from this signature.

Virtual links are links of type Link::kVirtualClosure.

Note
Automatically marks links as modified.

◆ addLandmark()

void rtabmap::Signature::addLandmark ( const Link landmark)

Adds a landmark observation to this signature.

Landmarks are persistent features in the environment that can be observed from multiple locations. This method adds a link representing the observation of a landmark from this signature's location.

Parameters
landmarkLink representing the landmark observation
Note
Landmark IDs are typically negative to distinguish them from regular nodes.

◆ getLandmarks()

const std::map< int, Link > & rtabmap::Signature::getLandmarks ( ) const
inline

Returns all landmark observations.

Returns
Const reference to the map of landmark IDs to landmark links

Definition at line 332 of file Signature.h.

◆ removeLandmark()

void rtabmap::Signature::removeLandmark ( int  landmarkId)

Removes a specific landmark observation.

Parameters
landmarkIdThe landmark ID to remove

◆ setSaved()

void rtabmap::Signature::setSaved ( bool  saved)
inline

Sets whether this signature has been saved to the database.

Parameters
savedTrue if saved, false otherwise

Definition at line 349 of file Signature.h.

◆ setModified()

void rtabmap::Signature::setModified ( bool  modified)
inline

Sets the modification flag for this signature.

Marks the signature as modified (or unmodified). When set to true, also marks links as modified.

Parameters
modifiedTrue if modified, false otherwise

Definition at line 359 of file Signature.h.

◆ getLinks()

const std::multimap< int, Link > & rtabmap::Signature::getLinks ( ) const
inline

Returns all links from this signature.

Returns
Const reference to the multimap of target IDs to links

Definition at line 365 of file Signature.h.

◆ isSaved()

bool rtabmap::Signature::isSaved ( ) const
inline

Checks if this signature has been saved to the database.

Returns
True if saved, false otherwise

Definition at line 371 of file Signature.h.

◆ isModified()

bool rtabmap::Signature::isModified ( ) const
inline

Checks if this signature has been modified.

Returns true if either the signature data or links have been modified.

Returns
True if modified, false otherwise

Definition at line 380 of file Signature.h.

◆ isLinksModified()

bool rtabmap::Signature::isLinksModified ( ) const
inline

Checks if the links have been modified.

Returns
True if links are modified, false otherwise

Definition at line 386 of file Signature.h.

◆ removeAllWords()

void rtabmap::Signature::removeAllWords ( )

Removes all visual words from this signature.

Clears all visual words, keypoints, 3D points, and descriptors. The signature will be disabled after this operation.

◆ changeWordsRef()

void rtabmap::Signature::changeWordsRef ( int  oldWordId,
int  activeWordId 
)

Changes visual word references from one word ID to another.

Updates all occurrences of oldWordId to activeWordId in the visual words. This is used when words are merged or reorganized in the dictionary.

Parameters
oldWordIdThe original word ID to replace
activeWordIdThe new word ID to use
Note
Tracks word ID changes in _wordsChanged for reference.

◆ setWords()

void rtabmap::Signature::setWords ( const std::multimap< int, int > &  words,
const std::vector< cv::KeyPoint > &  keypoints,
const std::vector< cv::Point3f > &  words3,
const cv::Mat &  descriptors 
)

Sets all visual words for this signature.

Sets the complete visual word representation including word IDs, keypoints, 3D points, and descriptors. All arrays must have matching sizes.

Parameters
wordsMultimap of word IDs to keypoint indices (allows duplicate words). The keypoint indices match the keypoints, points and descriptors.
keypointsVector of 2D keypoints in image coordinates. The keypoints must be in the same order as the words.
words3Vector of 3D points in base_link frame (with localTransform applied). The points must be in the same order as the words.
descriptorsFeature descriptors matrix (one row per word). The descriptors must be in the same order as the words.
Note
The signature is disabled after setting words (must be explicitly enabled).
Invalid words (ID <= 0) are counted in _invalidWordsCount.
All arrays must have the same size (number of words).

◆ isEnabled()

bool rtabmap::Signature::isEnabled ( ) const
inline

Checks if this signature is enabled.

Enabled signatures can be used for place recognition and loop closure detection. More explicitly, it means that the signature is registered to the VWDictionary (see Memory::enableWordsRef).

Returns
True if enabled, false otherwise

Definition at line 436 of file Signature.h.

◆ setEnabled()

void rtabmap::Signature::setEnabled ( bool  enabled)
inline

Sets whether this signature is enabled.

Parameters
enabledTrue to enable, false to disable

Definition at line 442 of file Signature.h.

◆ getWords()

const std::multimap< int, int > & rtabmap::Signature::getWords ( ) const
inline

Returns the visual words map.

Returns a multimap of word IDs to keypoint indices. The multimap allows duplicate word IDs (a word can appear multiple times in the signature).

Returns
Const reference to the words multimap

Definition at line 452 of file Signature.h.

◆ getWordsKpts()

const std::vector< cv::KeyPoint > & rtabmap::Signature::getWordsKpts ( ) const
inline

Returns the keypoints associated with visual words.

Returns
Const reference to the vector of 2D keypoints

Definition at line 458 of file Signature.h.

◆ getInvalidWordsCount()

int rtabmap::Signature::getInvalidWordsCount ( ) const
inline

Returns the count of invalid visual words.

Invalid words are those with ID <= 0. These words cannot be used for place recognition. However, they are still used for transform estimation after loop closures are detected with the valid words.

Returns
Number of invalid words

Definition at line 469 of file Signature.h.

◆ getWordsChanged()

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

Returns the word ID change mapping.

Returns a map of old word IDs to new word IDs, tracking changes made through changeWordsRef().

Returns
Const reference to the word ID change map

Definition at line 479 of file Signature.h.

◆ getWordsDescriptors()

const cv::Mat & rtabmap::Signature::getWordsDescriptors ( ) const
inline

Returns the feature descriptors for visual words.

Returns
Const reference to the descriptors matrix (one row per word)

Definition at line 485 of file Signature.h.

◆ setWordsDescriptors()

void rtabmap::Signature::setWordsDescriptors ( const cv::Mat &  descriptors)

Sets the feature descriptors for visual words.

Updates the descriptors matrix. The number of rows must match the number of visual words.

Parameters
descriptorsDescriptors matrix (one row per word)

◆ setPose()

void rtabmap::Signature::setPose ( const Transform pose)
inline

Sets the pose of this signature.

The pose represents the position and orientation of this signature in the odometry coordinate frame. To get the pose in map coordinate frame, use the map correction transform computed by graph optimization and apply it to this pose.

Parameters
poseThe transform representing the pose in the odometry coordinate frame.
// Get pose in map coordinate frame
Statistics stats;
Transform poseInMapFrame = stats.mapCorrection() * signature.getPose();
// poseInMapFrame is the pose in map coordinate frame
// signature.getPose() returns the pose in odometry coordinate frame
Collects and manages runtime statistics for RTAB-Map.
Definition Statistics.h:108
const Transform & mapCorrection() const
Returns the map correction transform.
Definition Statistics.h:657
Represents a 3D rigid body transformation (rotation + translation).
Definition Transform.h:53
See also
Statistics::mapCorrection()
getPose()

Definition at line 519 of file Signature.h.

◆ setGroundTruthPose()

void rtabmap::Signature::setGroundTruthPose ( const Transform pose)
inline

Sets the ground truth pose for evaluation.

Ground truth poses are used for evaluating localization accuracy and comparing against the estimated pose.

Parameters
poseThe ground truth transform

Definition at line 529 of file Signature.h.

◆ setVelocity()

void rtabmap::Signature::setVelocity ( float  vx,
float  vy,
float  vz,
float  vroll,
float  vpitch,
float  vyaw 
)
inline

Sets the velocity of this signature.

Sets the 6DOF velocity (linear and angular) at the time this signature was captured.

Parameters
vxLinear velocity in x direction (m/s)
vyLinear velocity in y direction (m/s)
vzLinear velocity in z direction (m/s)
vrollAngular velocity around x axis (rad/s)
vpitchAngular velocity around y axis (rad/s)
vyawAngular velocity around z axis (rad/s)

Definition at line 544 of file Signature.h.

◆ getWords3()

const std::vector< cv::Point3f > & rtabmap::Signature::getWords3 ( ) const
inline

Returns the 3D points of visual words.

Returns the 3D coordinates of visual words in the base_link frame (with localTransform applied).

Returns
Const reference to the vector of 3D points

Definition at line 562 of file Signature.h.

◆ getPose()

const Transform & rtabmap::Signature::getPose ( ) const
inline

Returns the pose of this signature.

Returns
Const reference to the pose transform in the odometry coordinate frame.
See also
setPose() for an example of how to get the pose in map coordinate frame.

Definition at line 569 of file Signature.h.

◆ getPoseCovariance()

cv::Mat rtabmap::Signature::getPoseCovariance ( ) const

Gets the pose covariance matrix.

Gets the covariance matrix representing the uncertainty between the current pose and the previous pose (e.g, from the odometry link with the previous signature).

Returns
6x6 covariance matrix (3x3 for translation, 3x3 for rotation)

◆ getGroundTruthPose()

const Transform & rtabmap::Signature::getGroundTruthPose ( ) const
inline

Returns the ground truth pose.

Returns
Const reference to the ground truth transform

Definition at line 585 of file Signature.h.

◆ getVelocity()

const std::vector< float > & rtabmap::Signature::getVelocity ( ) const
inline

Returns the velocity of this signature.

Returns
Const reference to the velocity vector [vx, vy, vz, vroll, vpitch, vyaw]

Definition at line 591 of file Signature.h.

◆ sensorData() [1/2]

SensorData & rtabmap::Signature::sensorData ( )
inline

Returns mutable access to the sensor data.

Returns
Reference to the sensor data

Definition at line 597 of file Signature.h.

◆ sensorData() [2/2]

const SensorData & rtabmap::Signature::sensorData ( ) const
inline

Returns const access to the sensor data.

Returns
Const reference to the sensor data

Definition at line 603 of file Signature.h.

◆ getMemoryUsed()

unsigned long rtabmap::Signature::getMemoryUsed ( bool  withSensorData = true) const

Computes the memory usage of this signature.

Calculates the approximate memory footprint of this signature, including visual words, links, sensor data, and other internal structures.

Parameters
withSensorDataIf true, includes sensor data in the calculation
Returns
Memory usage in bytes

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