gmapping_occupancy_observation_pe.h
Go to the documentation of this file.
1 #ifndef SLAM_CTOR_GMAPPING_OCCUPANCY_OBSERVATION_PE
2 #define SLAM_CTOR_GMAPPING_OCCUPANCY_OBSERVATION_PE
3 
4 #include <cmath>
5 #include <cassert>
6 
7 #include "../../core/scan_matchers/occupancy_observation_probability.h"
8 #include "../../core/geometry_utils.h"
9 
12 public:
13  GmappingOccupancyObservationPE(double fullness_th, unsigned window_size)
14  : Fullness_Th{fullness_th}, Window_Sz{int(window_size)}, _cached_prob{-1} {}
16  const LightWeightRectangle &,
17  const GridMap &map) const override {
18  assert(aoo.is_occupied);
19  auto sp_coord = map.world_to_cell(aoo.obstacle);
20  if (sp_coord == _cached_coord && _cached_prob != -1) {
21  return _cached_prob;
22  }
23 
24  double best_prob = 0;
25  for (int d_x = -Window_Sz; d_x <= Window_Sz; ++d_x) {
26  for (int d_y = -Window_Sz; d_y <= Window_Sz; ++d_y) {
27  auto cell_coord = sp_coord + DiscretePoint2D{d_x, d_y};
28  const auto &cell = map[cell_coord];
29  if (cell < Fullness_Th) { continue; }
30  best_prob = std::max(best_prob, 1.0 - cell.discrepancy(aoo));
31  }
32  }
33 
34  _cached_coord = sp_coord;
35  return _cached_prob = best_prob;
36  }
37 
38 private:
39  const double Fullness_Th;
40  const int Window_Sz;
42  mutable double _cached_prob;
43 };
44 
45 
46 #endif
double probability(const AreaOccupancyObservation &aoo, const LightWeightRectangle &, const GridMap &map) const override
Coord world_to_cell(const Point2D &pt) const
GmappingOccupancyObservationPE(double fullness_th, unsigned window_size)


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