bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
probability_grid.h
Go to the documentation of this file.
1#ifndef BITSIM_PLANNING_PROBABILITY_GRID_H
2#define BITSIM_PLANNING_PROBABILITY_GRID_H
3
6
7#include <array>
8#include <vector>
9
10namespace bitsim
11{
12namespace planning
13{
14
33{
34 public:
35 using Point = std::array<real_t, 2>;
36
39 {
42 real_t p_min{0.12};
44 };
45
54 real_t y0 = 0.0);
55
60 const Parameters &parameters);
61
62 uint_t n_cols() const noexcept { return n_cols_; }
63 uint_t n_rows() const noexcept { return n_rows_; }
64 real_t cell_size() const noexcept { return cell_size_; }
65
66 bool in_bounds(const GridCell &c) const noexcept;
67 GridCell to_cell(real_t x, real_t y) const noexcept;
68 std::array<real_t, 2> to_world(const GridCell &c) const noexcept;
69
73 real_t probability(const GridCell &c) const noexcept;
74
78 bool is_known(const GridCell &c) const noexcept;
79
88 void integrate_beam(const Point &origin, const Point &endpoint, bool hit);
89
95 void integrate_scan(const std::array<real_t, 3> &pose, const std::vector<real_t> &bearings,
96 const std::vector<real_t> &ranges, real_t max_range);
97
103 OccupancyGrid to_occupancy_grid(real_t occupied_threshold = 0.5,
104 bool unknown_is_occupied = true) const;
105
106 private:
107 std::size_t index_(const GridCell &c) const noexcept;
108 void update_(const GridCell &c, real_t delta_log_odds);
109
110 uint_t n_cols_;
111 uint_t n_rows_;
112 real_t cell_size_;
113 real_t x0_;
114 real_t y0_;
115 real_t l_hit_;
116 real_t l_miss_;
117 real_t l_min_;
118 real_t l_max_;
119 std::vector<real_t> log_odds_;
120};
121
122} // namespace planning
123} // namespace bitsim
124
125#endif // BITSIM_PLANNING_PROBABILITY_GRID_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
A rectangle of the plane cut into square cells, each free or occupied.
Definition occupancy_grid.h:43
void integrate_beam(const Point &origin, const Point &endpoint, bool hit)
Fold one range beam into the map: the cells from origin to endpoint are made more likely free,...
Definition probability_grid.cpp:89
uint_t n_cols() const noexcept
Definition probability_grid.h:62
real_t cell_size() const noexcept
Definition probability_grid.h:64
GridCell to_cell(real_t x, real_t y) const noexcept
Definition probability_grid.cpp:53
std::array< real_t, 2 > Point
Definition probability_grid.h:35
std::array< real_t, 2 > to_world(const GridCell &c) const noexcept
Definition probability_grid.cpp:59
bool in_bounds(const GridCell &c) const noexcept
Definition probability_grid.cpp:42
real_t probability(const GridCell &c) const noexcept
The probability that the cell is occupied, 0.5 for an unknown or out-of-bounds cell.
Definition probability_grid.cpp:64
void integrate_scan(const std::array< real_t, 3 > &pose, const std::vector< real_t > &bearings, const std::vector< real_t > &ranges, real_t max_range)
Fold a whole scan taken at pose (x, y, heading): beam i is cast along heading + bearings[i] and measu...
Definition probability_grid.cpp:133
bool is_known(const GridCell &c) const noexcept
Whether any beam has touched the cell. An untouched cell keeps the 0.5 prior.
Definition probability_grid.cpp:74
uint_t n_rows() const noexcept
Definition probability_grid.h:63
OccupancyGrid to_occupancy_grid(real_t occupied_threshold=0.5, bool unknown_is_occupied=true) const
The map as an OccupancyGrid for a planner: a cell is occupied if its probability is at least occupied...
Definition probability_grid.cpp:151
ProbabilityGrid(uint_t n_cols, uint_t n_rows, real_t cell_size, real_t x0=0.0, real_t y0=0.0)
Definition probability_grid.cpp:17
Definition a_star_search.cpp:8
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20
A cell of an OccupancyGrid: its column, along x, and row, along y.
Definition occupancy_grid.h:21
The inverse sensor model: how strongly one beam moves a cell's probability.
Definition probability_grid.h:39
real_t p_max
Definition probability_grid.h:43
real_t p_min
the probability is clamped to [p_min, p_max]
Definition probability_grid.h:42
real_t p_miss
a cell a beam passes through is this likely occupied (< 0.5)
Definition probability_grid.h:41
real_t p_hit
a cell a beam ends on is this likely occupied
Definition probability_grid.h:40