bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitsim::planning::ProbabilityGrid Class Reference

An occupancy map built from range sensors, each cell holding the probability that it is occupied. More...

#include <probability_grid.h>

Classes

struct  Parameters
 The inverse sensor model: how strongly one beam moves a cell's probability. More...

Public Types

using Point = std::array<real_t, 2>

Public Member Functions

 ProbabilityGrid (uint_t n_cols, uint_t n_rows, real_t cell_size, real_t x0=0.0, real_t y0=0.0)
 ProbabilityGrid (uint_t n_cols, uint_t n_rows, real_t cell_size, real_t x0, real_t y0, const Parameters &parameters)
 As above, with the inverse sensor model given.
uint_t n_cols () const noexcept
uint_t n_rows () const noexcept
real_t cell_size () const noexcept
bool in_bounds (const GridCell &c) const noexcept
GridCell to_cell (real_t x, real_t y) const noexcept
std::array< real_t, 2 > to_world (const GridCell &c) const noexcept
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.
bool is_known (const GridCell &c) const noexcept
 Whether any beam has touched the cell. An untouched cell keeps the 0.5 prior.
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, and if hit the endpoint cell is made more likely occupied. origin and endpoint are in world metres; set hit false when the beam reached its maximum range without striking anything. Cells outside the grid are ignored, so a hit beyond the grid only frees the cells the beam crossed: make the grid a little larger than the walls it should capture.
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 measured ranges[i]. A range of max_range or more, or not finite, is treated as a miss.
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_threshold. An unknown cell, which no beam has seen, is occupied when unknown_is_occupied, the safe default, so a planner does not route through unseen space.

Detailed Description

An occupancy map built from range sensors, each cell holding the probability that it is occupied.

Where an OccupancyGrid says only free or occupied, a ProbabilityGrid accumulates evidence: a robot drives through the world and a range sensor reports how far away the nearest obstacle is along each beam. Every beam marks the cells it passes through as a little more likely free, and the cell it ends on, if it struck something, as a little more likely occupied. A cell no beam has touched stays unknown.

The evidence is kept as log-odds, \(l = \log\frac{p}{1-p}\), so an update is just an addition and is clamped to a range, after which thresholding gives the OccupancyGrid a planner can search. The cells follow the same convention as OccupancyGrid: column (0, 0) has its lower left corner at (x0, y0), columns grow with x and rows with y.

Member Typedef Documentation

◆ Point

Constructor & Destructor Documentation

◆ ProbabilityGrid() [1/2]

bitsim::planning::ProbabilityGrid::ProbabilityGrid ( uint_t n_cols,
uint_t n_rows,
real_t cell_size,
real_t x0 = 0.0,
real_t y0 = 0.0 )
Parameters
n_colsThe number of columns, along x
n_rowsThe number of rows, along y
cell_sizeThe side of a cell [m]
x0The x of the lower left corner of the grid [m]
y0The y of the lower left corner of the grid [m]

◆ ProbabilityGrid() [2/2]

bitsim::planning::ProbabilityGrid::ProbabilityGrid ( uint_t n_cols,
uint_t n_rows,
real_t cell_size,
real_t x0,
real_t y0,
const Parameters & parameters )

As above, with the inverse sensor model given.

Member Function Documentation

◆ cell_size()

real_t bitsim::planning::ProbabilityGrid::cell_size ( ) const
inlinenoexcept

◆ in_bounds()

bool bitsim::planning::ProbabilityGrid::in_bounds ( const GridCell & c) const
noexcept

◆ integrate_beam()

void bitsim::planning::ProbabilityGrid::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, and if hit the endpoint cell is made more likely occupied. origin and endpoint are in world metres; set hit false when the beam reached its maximum range without striking anything. Cells outside the grid are ignored, so a hit beyond the grid only frees the cells the beam crossed: make the grid a little larger than the walls it should capture.

◆ integrate_scan()

void bitsim::planning::ProbabilityGrid::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 measured ranges[i]. A range of max_range or more, or not finite, is treated as a miss.

◆ is_known()

bool bitsim::planning::ProbabilityGrid::is_known ( const GridCell & c) const
noexcept

Whether any beam has touched the cell. An untouched cell keeps the 0.5 prior.

◆ n_cols()

uint_t bitsim::planning::ProbabilityGrid::n_cols ( ) const
inlinenoexcept

◆ n_rows()

uint_t bitsim::planning::ProbabilityGrid::n_rows ( ) const
inlinenoexcept

◆ probability()

real_t bitsim::planning::ProbabilityGrid::probability ( const GridCell & c) const
noexcept

The probability that the cell is occupied, 0.5 for an unknown or out-of-bounds cell.

◆ to_cell()

GridCell bitsim::planning::ProbabilityGrid::to_cell ( real_t x,
real_t y ) const
noexcept

◆ to_occupancy_grid()

OccupancyGrid bitsim::planning::ProbabilityGrid::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_threshold. An unknown cell, which no beam has seen, is occupied when unknown_is_occupied, the safe default, so a planner does not route through unseen space.

◆ to_world()

std::array< real_t, 2 > bitsim::planning::ProbabilityGrid::to_world ( const GridCell & c) const
noexcept

The documentation for this class was generated from the following files: