BayesFilter.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, 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 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON 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
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef BAYESFILTER_H_
29 #define BAYESFILTER_H_
30 
31 #include "rtabmap/core/RtabmapExp.h" // DLL export/import defines
32 
33 #include <opencv2/core/core.hpp>
34 #include <list>
35 #include <set>
38 
39 namespace rtabmap {
40 
41 class Memory;
42 class Signature;
43 
45 {
46 public:
47  BayesFilter(const ParametersMap & parameters = ParametersMap());
48  virtual ~BayesFilter();
49  virtual void parseParameters(const ParametersMap & parameters);
50  const std::map<int, float> & computePosterior(const Memory * memory, const std::map<int, float> & likelihood);
51  void reset();
52 
53  //setters
54  void setPredictionLC(const std::string & prediction);
55 
56  //getters
57  const std::map<int, float> & getPosterior() const {return _posterior;}
58  float getVirtualPlacePrior() const {return _virtualPlacePrior;}
59  const std::vector<double> & getPredictionLC() const; // {Vp, Lc, l1, l2, l3, l4...}
60  std::string getPredictionLCStr() const; // for convenience {Vp, Lc, l1, l2, l3, l4...}
61 
62  cv::Mat generatePrediction(const Memory * memory, const std::vector<int> & ids);
63 
64  unsigned long getMemoryUsed() const;
65 
66 private:
67  cv::Mat updatePrediction(const cv::Mat & oldPrediction,
68  const Memory * memory,
69  const std::vector<int> & oldIds,
70  const std::vector<int> & newIds);
71  void updatePosterior(const Memory * memory, const std::vector<int> & likelihoodIds);
72  void normalize(cv::Mat & prediction, unsigned int index, float addedProbabilitiesSum, bool virtualPlaceUsed) const;
73 
74 private:
75  std::map<int, float> _posterior;
76  cv::Mat _prediction;
78  std::vector<double> _predictionLC; // {Vp, Lc, l1, l2, l3, l4...}
82  std::map<int, std::map<int, int> > _neighborsIndex;
83 };
84 
85 } // namespace rtabmap
86 
87 #endif /* BAYESFILTER_H_ */
float _totalPredictionLCValues
Definition: BayesFilter.h:80
float getVirtualPlacePrior() const
Definition: BayesFilter.h:58
std::map< std::string, std::string > ParametersMap
Definition: Parameters.h:43
const std::map< int, float > & getPosterior() const
Definition: BayesFilter.h:57
#define RTABMAP_EXP
Definition: RtabmapExp.h:38
GLM_FUNC_DECL genType normalize(genType const &x)
std::map< int, std::map< int, int > > _neighborsIndex
Definition: BayesFilter.h:82
std::map< int, float > _posterior
Definition: BayesFilter.h:75
std::vector< double > _predictionLC
Definition: BayesFilter.h:78


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:34:58