|
RTAB-Map 0.23.11
Real-Time Appearance-Based Mapping
|
Recursive Bayesian filter for loop-closure hypothesis estimation in RTAB-Map. More...
#include <BayesFilter.h>
Public Member Functions | |
| BayesFilter (const ParametersMap ¶meters=ParametersMap()) | |
| Constructs a Bayes filter with default or custom parameters. | |
| virtual void | parseParameters (const ParametersMap ¶meters) |
| Updates internal settings from the parameter map. | |
| bool | 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::vector< int > & | getPosteriorIds () const |
| The locations the posterior is over, ascending by id. | |
| const std::vector< float > & | getPosteriorValues () const |
| The probability of each location of getPosteriorIds(), in the same order. | |
| float | getVirtualPlacePrior () const |
| Returns the virtual place prior threshold. | |
| bool | isPredictionSparse () const |
| Whether the prediction is being kept in its sparse form rather than as a matrix. | |
| 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. | |
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:
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):
Definition at line 81 of file BayesFilter.h.
| rtabmap::BayesFilter::BayesFilter | ( | const ParametersMap & | parameters = ParametersMap() | ) |
Constructs a Bayes filter with default or custom parameters.
| parameters | Optional parameter map (Bayes group keys). Defaults are used for missing keys. |
|
virtual |
Updates internal settings from the parameter map.
| parameters | Map containing Bayes group keys. |
| bool 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.
Read the result with getPosteriorIds() and getPosteriorValues().
| memory | Working memory instance (must not be null). |
| likelihood | Observation likelihood per signature id (must not be empty). |
| 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:
Each value must be in [0, 1]. At least two values are required. Invalid strings are rejected and the previous model is kept.
| prediction | Space-separated list of probabilities (same format as Parameters::kBayesPredictionLC()). |
|
inline |
The locations the posterior is over, ascending by id.
The virtual place (Memory::kIdVirtual) is the first of them when it is one.
Definition at line 138 of file BayesFilter.h.
|
inline |
The probability of each location of getPosteriorIds(), in the same order.
Definition at line 143 of file BayesFilter.h.
| float rtabmap::BayesFilter::getVirtualPlacePrior | ( | ) | const |
Returns the virtual place prior threshold.
| bool rtabmap::BayesFilter::isPredictionSparse | ( | ) | const |
Whether the prediction is being kept in its sparse form rather than as a matrix.
False when Parameters::kBayesSparsePrediction() is disabled, and over a model whose values sum to less than 1, which leaves no zero in a column to keep out of the values.
| const std::vector< double > & rtabmap::BayesFilter::getPredictionLC | ( | ) | const |
Returns the loop-closure prediction model as a vector of values.
{Vp, Lc, l1, l2, l3, ...}. | std::string rtabmap::BayesFilter::getPredictionLCStr | ( | ) | const |
Returns the loop-closure prediction model as a space-separated string.
| 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.
When the prediction is being kept sparse, the matrix is expanded from it rather than kept: it costs the memory that keeping the prediction sparse is saving, so ask for it to read, dump or compare the prediction, not on every iteration.
| memory | Working memory instance (must not be null). |
| ids | Ordered list of signature ids (often includes Memory::kIdVirtual as first element). |
| unsigned long rtabmap::BayesFilter::getMemoryUsed | ( | ) | const |
Estimates memory usage of this object and its internal containers.