gmapping_grid_cell.h
Go to the documentation of this file.
1 #ifndef SLAM_CTOR_SLAM_GMAPPING_GRID_CELL_H
2 #define SLAM_CTOR_SLAM_GMAPPING_GRID_CELL_H
3 
4 #include <memory>
5 #include <cmath>
6 #include "../../core/geometry_utils.h"
7 #include "../../core/maps/grid_cell.h"
8 
9 class GmappingBaseCell : public GridCell {
10 private:
11  // TODO: move to param
12  constexpr static double DIST_VARIANCE = 0.05;
13 public:
15 
16  std::unique_ptr<GridCell> clone() const override {
17  return std::make_unique<GmappingBaseCell>(*this);
18  }
19 
20  void operator+=(const AreaOccupancyObservation &aoo) override {
21  if (!aoo.occupancy.is_valid()) { return; }
22 
23  ++_tries;
24  bool aoo_is_free = aoo.occupancy <= 0.5;
25  double aoo_p = aoo_is_free ? 0.0 : aoo.occupancy.prob_occ;
26  _occupancy.prob_occ = ((*this) * (_tries - 1) + aoo_p) / _tries;
27  if (aoo_is_free) return;
28 
29  ++_hits;
30  obst.x = (obst.x * (_hits - 1) + aoo.obstacle.x) / _hits;
31  obst.y = (obst.y * (_hits - 1) + aoo.obstacle.y) / _hits;
32  }
33 
34  double discrepancy(const AreaOccupancyObservation &aoo) const override {
35  auto similarity = std::exp(-obst.dist_sq(aoo.obstacle) / DIST_VARIANCE);
36  return 1.0 - similarity;
37  }
38 
39 private:
40  int _hits, _tries;
42 };
43 
44 #endif
double prob_occ
Definition: state_data.h:8
double dist_sq(const Point2D &pt) const
std::unique_ptr< GridCell > clone() const override
void operator+=(const AreaOccupancyObservation &aoo) override
static constexpr double DIST_VARIANCE
bool is_valid() const
Definition: state_data.h:23
Occupancy _occupancy
Definition: grid_cell.h:47
double discrepancy(const AreaOccupancyObservation &aoo) const override


slam_constructor
Author(s): JetBrains Research, OSLL team
autogenerated on Mon Jun 10 2019 15:08:25