RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
BayesFilter.h
1/*
2Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, 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
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON 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
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#ifndef BAYESFILTER_H_
29#define BAYESFILTER_H_
30
31#include "rtabmap/core/rtabmap_core_export.h" // DLL export/import defines
32
33#include <opencv2/core/core.hpp>
34#include <list>
35#include <set>
36#include "rtabmap/utilite/UEventsHandler.h"
37#include "rtabmap/core/Parameters.h"
38
39namespace rtabmap {
40
41class Memory;
42class Signature;
43
71class RTABMAP_CORE_EXPORT BayesFilter
72{
73public:
78 BayesFilter(const ParametersMap & parameters = ParametersMap());
79 virtual ~BayesFilter();
80
85 virtual void parseParameters(const ParametersMap & parameters);
86
99 const std::map<int, float> & computePosterior(const Memory * memory, const std::map<int, float> & likelihood);
100
104 void reset();
105
119 void setPredictionLC(const std::string & prediction);
120
125 const std::map<int, float> & getPosterior() const {return _posterior;}
126
131 float getVirtualPlacePrior() const {return _virtualPlacePrior;}
132
137 const std::vector<double> & getPredictionLC() const;
138
143 std::string getPredictionLCStr() const;
144
156 cv::Mat generatePrediction(const Memory * memory, const std::vector<int> & ids);
157
162 unsigned long getMemoryUsed() const;
163
164private:
168 cv::Mat updatePrediction(const cv::Mat & oldPrediction,
169 const Memory * memory,
170 const std::vector<int> & oldIds,
171 const std::vector<int> & newIds);
172
176 void updatePosterior(const Memory * memory, const std::vector<int> & likelihoodIds);
177
181 void normalize(cv::Mat & prediction, unsigned int index, float addedProbabilitiesSum, bool virtualPlaceUsed) const;
182
183private:
184 std::map<int, float> _posterior;
185 cv::Mat _prediction;
186 float _virtualPlacePrior;
187 std::vector<double> _predictionLC;
188 bool _fullPredictionUpdate;
189 float _totalPredictionLCValues;
190 float _predictionEpsilon;
191 std::map<int, std::map<int, int> > _neighborsIndex;
192};
193
194} // namespace rtabmap
195
196#endif /* BAYESFILTER_H_ */
Recursive Bayesian filter for loop-closure hypothesis estimation in RTAB-Map.
Definition BayesFilter.h:72
std::string getPredictionLCStr() const
Returns the loop-closure prediction model as a space-separated string.
float getVirtualPlacePrior() const
Returns the virtual place prior threshold.
BayesFilter(const ParametersMap &parameters=ParametersMap())
Constructs a Bayes filter with default or custom parameters.
void setPredictionLC(const std::string &prediction)
Sets the loop-closure prediction model from 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.
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).
const std::vector< double > & getPredictionLC() const
Returns the loop-closure prediction model as a vector of values.
const std::map< int, float > & getPosterior() const
Returns the current posterior probability map.
void reset()
Clears posterior, prediction matrix and cached neighbor indices.
Three-tiered memory management (STM, WM, LTM) for RTAB-Map.
Definition Memory.h:102
Represents a node in RTAB-Map's pose graph.
Definition Signature.h:84
std::map< std::string, std::string > ParametersMap
Parameter keys mapped to their values, as used by every configurable class (see Parameters).
Definition Parameters.h:44