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

Recursive Bayesian filter for loop-closure hypothesis estimation in RTAB-Map. More...

#include <BayesFilter.h>

Public Member Functions

 BayesFilter (const ParametersMap &parameters=ParametersMap())
 Constructs a Bayes filter with default or custom parameters.
 
virtual void parseParameters (const ParametersMap &parameters)
 Updates internal settings from the parameter map.
 
const std::map< int, float > & computePosterior (const Memory *memory, const std::map< int, float > &likelihood)
 Runs one Bayes filter iteration (prediction + update).
 
void reset ()
 Clears posterior, prediction matrix and cached neighbor indices.
 
void setPredictionLC (const std::string &prediction)
 Sets the loop-closure prediction model from a space-separated string.
 
const std::map< int, float > & getPosterior () const
 Returns the current posterior probability map.
 
float getVirtualPlacePrior () const
 Returns the virtual place prior threshold.
 
const std::vector< double > & getPredictionLC () const
 Returns the loop-closure prediction model as a vector of values.
 
std::string getPredictionLCStr () const
 Returns the loop-closure prediction model as a space-separated string.
 
cv::Mat generatePrediction (const Memory *memory, const std::vector< int > &ids)
 Builds or updates the prediction (transition) matrix for the given signature ids.
 
unsigned long getMemoryUsed () const
 Estimates memory usage of this object and its internal containers.
 

Detailed Description

Recursive Bayesian filter for loop-closure hypothesis estimation in RTAB-Map.

This class implements the prediction and update steps of a Bayes filter used to estimate the posterior probability over candidate locations (signatures) in working memory. It is typically called by Rtabmap after likelihood values have been computed from visual word comparisons.

The filter operates in two steps on each iteration:

  • Prediction: builds a transition matrix from the memory graph and multiplies it with the previous posterior to obtain the prior.
  • Update: multiplies the prior by the observation likelihood and normalizes the result.

The prediction matrix is built from neighbor relationships in Memory, using a Gaussian-like model configured through Parameters::kBayesPredictionLC(). A virtual place (negative signature id, see Memory::kIdVirtual) represents the hypothesis that the current observation comes from a new location.

Related parameters (see Parameters):

See also
Memory::getNeighborsId()
Rtabmap

Definition at line 71 of file BayesFilter.h.

Constructor & Destructor Documentation

◆ BayesFilter()

rtabmap::BayesFilter::BayesFilter ( const ParametersMap parameters = ParametersMap())

Constructs a Bayes filter with default or custom parameters.

Parameters
parametersOptional parameter map (Bayes group keys). Defaults are used for missing keys.

Member Function Documentation

◆ parseParameters()

virtual void rtabmap::BayesFilter::parseParameters ( const ParametersMap parameters)
virtual

Updates internal settings from the parameter map.

Parameters
parametersMap containing Bayes group keys.

◆ computePosterior()

const std::map< int, float > & rtabmap::BayesFilter::computePosterior ( const Memory memory,
const std::map< int, float > &  likelihood 
)

Runs one Bayes filter iteration (prediction + update).

Given a likelihood map over signature ids, computes and stores the normalized posterior. The prediction matrix is generated or updated from Memory using the ids present in likelihood.

Parameters
memoryWorking memory instance (must not be null).
likelihoodObservation likelihood per signature id (must not be empty).
Returns
Reference to the internal posterior map (id → probability). On error (null memory, empty likelihood, or invalid prediction model), returns the unchanged posterior.

◆ setPredictionLC()

void rtabmap::BayesFilter::setPredictionLC ( const std::string &  prediction)

Sets the loop-closure prediction model from a space-separated string.

Format: {Vp, Lc, l1, l2, l3, ...} where:

  • Vp — virtual place probability. This is the probability to move to a new place (unvisited location).
  • Lc — loop closure (depth 0) probability. This is the probability to stay at the same location.
  • l1, l2, ... — probabilities for neighbors at increasing graph depth levels. This is the probability to move to a neighbor at the given depth level.

Each value must be in [0, 1]. At least two values are required. Invalid strings are rejected and the previous model is kept.

Parameters
predictionSpace-separated list of probabilities (same format as Parameters::kBayesPredictionLC()).

◆ getPosterior()

const std::map< int, float > & rtabmap::BayesFilter::getPosterior ( ) const
inline

Returns the current posterior probability map.

Returns
Map of signature id to normalized posterior probability. This is the probability to be at the given location.

Definition at line 125 of file BayesFilter.h.

◆ getVirtualPlacePrior()

float rtabmap::BayesFilter::getVirtualPlacePrior ( ) const
inline

Returns the virtual place prior threshold.

Returns
Value in [0, 1] used when building the virtual place row of the prediction matrix.

Definition at line 131 of file BayesFilter.h.

◆ getPredictionLC()

const std::vector< double > & rtabmap::BayesFilter::getPredictionLC ( ) const

Returns the loop-closure prediction model as a vector of values.

Returns
Vector in the format {Vp, Lc, l1, l2, l3, ...}.

◆ getPredictionLCStr()

std::string rtabmap::BayesFilter::getPredictionLCStr ( ) const

Returns the loop-closure prediction model as a space-separated string.

Returns
String representation of getPredictionLC().

◆ generatePrediction()

cv::Mat rtabmap::BayesFilter::generatePrediction ( const Memory memory,
const std::vector< int > &  ids 
)

Builds or updates the prediction (transition) matrix for the given signature ids.

Rows and columns correspond to ids. Neighbor links are queried from Memory to fill transition probabilities according to getPredictionLC(). When ids match the current posterior keys, the cached matrix may be returned without recomputation.

Parameters
memoryWorking memory instance (must not be null).
idsOrdered list of signature ids (often includes Memory::kIdVirtual as first element).
Returns
Square CV_32FC1 matrix of size ids.size() × ids.size().

◆ getMemoryUsed()

unsigned long rtabmap::BayesFilter::getMemoryUsed ( ) const

Estimates memory usage of this object and its internal containers.

Returns
Approximate memory footprint in bytes.

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