occupancy_observation_probability.h
Go to the documentation of this file.
1 #ifndef SLAM_CTOR_CORE_OCCUPANCY_OBSERVATION_PROBABILITY_H
2 #define SLAM_CTOR_CORE_OCCUPANCY_OBSERVATION_PROBABILITY_H
3 
4 #include <cmath>
5 #include "../maps/grid_rasterization.h"
6 #include "grid_scan_matcher.h"
7 
8 // TODO: add an option that alters
9 // aoo.observation quality based on overlap
10 // map.world_cell_bounds(area_id).overlap(area); // NB: order
11 
14 public:
16  const LightWeightRectangle &,
17  const GridMap &map) const override {
18  assert(aoo.is_occupied);
19  double prob = 1.0 - map[map.world_to_cell(aoo.obstacle)].discrepancy(aoo);
20  assert(0 <= prob);
21  return prob;
22  }
23 };
24 
27 public:
29  const LightWeightRectangle &area,
30  const GridMap &map) const override {
31  assert(aoo.is_occupied);
32  auto max_probability = double{0};
33  auto area_ids = GridRasterizedRectangle{map, area};
34 
35  while (area_ids.has_next()) {
36  auto area_id = area_ids.next();
37  double obs_prob = 1.0 - map[area_id].discrepancy(aoo);
38  assert(0 <= obs_prob);
39  max_probability = std::max(obs_prob, max_probability);
40  }
41  return max_probability;
42  }
43 };
44 
47 public:
49  const LightWeightRectangle &area,
50  const GridMap &map) const override {
51  assert(aoo.is_occupied);
52  auto tot_probability = double{0};
53  auto area_nm = unsigned{0};
54 
55  auto area_ids = GridRasterizedRectangle{map, area};
56  while (area_ids.has_next()) {
57  auto obs_prob = 1.0 - map[area_ids.next()].discrepancy(aoo);
58  assert(0 <= obs_prob);
59  tot_probability += obs_prob;
60  area_nm += 1;
61  }
62  return area_nm ? tot_probability / area_nm : 0.5;
63  }
64 };
65 
68 public:
70  const LightWeightRectangle &area,
71  const GridMap &map) const override {
72  assert(aoo.is_occupied);
73  double tot_probability = 0;
74  double tot_weight = 0;
75 
76  auto area_ids = GridRasterizedRectangle{map, area};
77  while (area_ids.has_next()) {
78  auto area_id = area_ids.next();
79  auto obs_prob = 1.0 - map[area_id].discrepancy(aoo);
80  assert(0 <= obs_prob);
81  auto weight = area.overlap(map.world_cell_bounds(area_id));
82  tot_probability += obs_prob * weight;
83  tot_weight += weight;
84  }
85  return tot_weight ? tot_probability / tot_weight : 0.5;
86  }
87 };
88 
89 #endif
Coord world_to_cell(const Point2D &pt) const
Rectangle world_cell_bounds(const Coord &coord) const
double probability(const AreaOccupancyObservation &aoo, const LightWeightRectangle &area, const GridMap &map) const override
double probability(const AreaOccupancyObservation &aoo, const LightWeightRectangle &area, const GridMap &map) const override
double probability(const AreaOccupancyObservation &aoo, const LightWeightRectangle &area, const GridMap &map) const override
double probability(const AreaOccupancyObservation &aoo, const LightWeightRectangle &, const GridMap &map) const override


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