smmap.h
Go to the documentation of this file.
1 #ifndef SMMAP_H
2 #define SMMAP_H
3 #include <gmapping/grid/map.h>
5 #include <gmapping/utils/point.h>
6 #define SIGHT_INC 1
7
8 namespace GMapping {
9
12  /* before
13  PointAccumulator(int i=-1): acc(0,0), n(0), visits(0){assert(i==-1);}
14  */
15  /*after begin*/
16  PointAccumulator(): acc(0,0), n(0), visits(0){}
17  PointAccumulator(int i): acc(0,0), n(0), visits(0){assert(i==-1);}
18  /*after end*/
19  inline void update(bool value, const Point& p=Point(0,0));
20  inline Point mean() const {return 1./n*Point(acc.x, acc.y);}
21  inline operator double() const { return visits?(double)n*SIGHT_INC/(double)visits:-1; }
22  inline void add(const PointAccumulator& p) {acc=acc+p.acc; n+=p.n; visits+=p.visits; }
23  static const PointAccumulator& Unknown();
25  FloatPoint acc;
26  int n, visits;
27  inline double entropy() const;
28 };
29
30 void PointAccumulator::update(bool value, const Point& p){
31  if (value) {
32  acc.x+= static_cast<float>(p.x);
33  acc.y+= static_cast<float>(p.y);
34  n++;
36  } else
37  visits++;
38 }
39
41  if (!visits)
42  return -log(.5);
43  if (n==visits || n==0)
44  return 0;
45  double x=(double)n*SIGHT_INC/(double)visits;
46  return -( x*log(x)+ (1-x)*log(1-x) );
47 }
48
49
51
52 };
53
54 #endif
Definition: smmap.h:22
void update(bool value, const Point &p=Point(0, 0))
Definition: smmap.h:30
point< float > FloatPoint
Definition: smmap.h:11
point< double > Point
Definition: point.h:202
static const PointAccumulator & Unknown()
Definition: smmap.cpp:5
#define SIGHT_INC
Definition: smmap.h:6
static PointAccumulator * unknown_ptr
Definition: smmap.h:24
Point mean() const
Definition: smmap.h:20
Map< PointAccumulator, HierarchicalArray2D< PointAccumulator > > ScanMatcherMap
Definition: smmap.h:50
double entropy() const
Definition: smmap.h:40

openslam_gmapping
Author(s): Giorgio Grisetti, Cyrill Stachniss, Wolfram Burgard
autogenerated on Mon Jun 10 2019 14:04:22