RTAB-Map 0.23.11
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 <map>
36#include <set>
37#include <utility>
38#include <vector>
39#include "rtabmap/utilite/UEventsHandler.h"
40#include "rtabmap/core/Parameters.h"
41
42namespace rtabmap {
43
44class Memory;
45class Signature;
46
47namespace bayes {
48class PredictionModel;
49class DensePrediction;
50class SparsePrediction;
51}
52
81class RTABMAP_CORE_EXPORT BayesFilter
82{
83public:
88 BayesFilter(const ParametersMap & parameters = ParametersMap());
89 virtual ~BayesFilter();
90
95 virtual void parseParameters(const ParametersMap & parameters);
96
111 bool computePosterior(const Memory * memory, const std::map<int, float> & likelihood);
112
116 void reset();
117
131 void setPredictionLC(const std::string & prediction);
132
138 const std::vector<int> & getPosteriorIds() const {return _posteriorIds;}
139
143 const std::vector<float> & getPosteriorValues() const {return _posteriorValues;}
144
149 float getVirtualPlacePrior() const;
150
157 bool isPredictionSparse() const;
158
163 const std::vector<double> & getPredictionLC() const;
164
169 std::string getPredictionLCStr() const;
170
186 cv::Mat generatePrediction(const Memory * memory, const std::vector<int> & ids);
187
192 unsigned long getMemoryUsed() const;
193
194private:
200 void updatePosterior(const Memory * memory, const std::map<int, float> & likelihood);
201
208 void updateKeepSparse();
209
210private:
211 std::vector<int> _posteriorIds;
212 std::vector<float> _posteriorValues;
213 std::vector<int> _likelihoodIds;
214 std::vector<float> _likelihoodValues;
215 std::vector<float> _priorValues;
216
217 bayes::PredictionModel * _model;
218 bayes::DensePrediction * _dense;
219 bayes::SparsePrediction * _sparse;
220 std::map<int, std::map<int, int> > _neighborsIndex;
221
222 bool _fullPredictionUpdate;
223 bool _sparsePrediction;
224 bool _keepSparse;
225 bool _predictionChanged;
226};
227
228} // namespace rtabmap
229
230#endif /* BAYESFILTER_H_ */
Recursive Bayesian filter for loop-closure hypothesis estimation in RTAB-Map.
Definition BayesFilter.h:82
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.
const std::vector< int > & getPosteriorIds() const
The locations the posterior is over, ascending by id.
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.
bool isPredictionSparse() const
Whether the prediction is being kept in its sparse form rather than as a matrix.
bool computePosterior(const Memory *memory, const std::map< int, float > &likelihood)
Runs one Bayes filter iteration (prediction + update).
const std::vector< float > & getPosteriorValues() const
The probability of each location of getPosteriorIds(), in the same order.
const std::vector< double > & getPredictionLC() const
Returns the loop-closure prediction model as a vector of values.
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