|
bitsim
Model, simulate, estimate and control robots in C++
|
A rectangle of the plane cut into square cells, each free or occupied. More...
#include <occupancy_grid.h>
Public Member Functions | |
| OccupancyGrid (uint_t n_cols, uint_t n_rows, real_t cell_size, real_t x0=0.0, real_t y0=0.0) | |
| 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 |
| bool | is_free (const GridCell &c) const noexcept |
| True if the cell is in the grid and not occupied. | |
| void | set_occupied (const GridCell &c, bool occupied=true) |
| void | add_rectangle (real_t x_min, real_t y_min, real_t x_max, real_t y_max) |
| Occupy the cells whose centres are in the rectangle [x_min, x_max] x [y_min, y_max]. | |
| void | add_circle (real_t x, real_t y, real_t radius) |
| Occupy the cells whose centres are within radius of (x, y). | |
| GridCell | to_cell (real_t x, real_t y) const noexcept |
| The cell that the point (x, y) is in. It may be out of bounds. | |
| std::array< real_t, 2 > | to_world (const GridCell &c) const noexcept |
| The centre of a cell [m]. | |
| std::vector< GridCell > | neighbours (const GridCell &c, bool diagonal=true) const |
| The free cells next to c: the four that share a side, and with diagonal the four that share a corner as well. A diagonal move is left out when either cell it passes between is occupied, so a path never cuts the corner of an obstacle. | |
| uint_t | n_occupied () const |
| The number of occupied cells. | |
A rectangle of the plane cut into square cells, each free or occupied.
Cell (0, 0) has its lower left corner at the origin given to the constructor; columns grow with x and rows with y. Obstacles are added as rectangles and circles: every cell whose centre is inside one is occupied. To keep a robot of radius r clear of the obstacles, grow them by r when adding them.
| bitsim::planning::OccupancyGrid::OccupancyGrid | ( | uint_t | n_cols, |
| uint_t | n_rows, | ||
| real_t | cell_size, | ||
| real_t | x0 = 0.0, | ||
| real_t | y0 = 0.0 ) |
| n_cols | The number of columns, along x |
| n_rows | The number of rows, along y |
| cell_size | The side of a cell [m] |
| x0 | The x of the lower left corner of the grid [m] |
| y0 | The y of the lower left corner of the grid [m] |
Occupy the cells whose centres are within radius of (x, y).
| void bitsim::planning::OccupancyGrid::add_rectangle | ( | real_t | x_min, |
| real_t | y_min, | ||
| real_t | x_max, | ||
| real_t | y_max ) |
Occupy the cells whose centres are in the rectangle [x_min, x_max] x [y_min, y_max].
|
inlinenoexcept |
|
noexcept |
|
noexcept |
True if the cell is in the grid and not occupied.
|
inlinenoexcept |
| uint_t bitsim::planning::OccupancyGrid::n_occupied | ( | ) | const |
The number of occupied cells.
|
inlinenoexcept |
| std::vector< GridCell > bitsim::planning::OccupancyGrid::neighbours | ( | const GridCell & | c, |
| bool | diagonal = true ) const |
The free cells next to c: the four that share a side, and with diagonal the four that share a corner as well. A diagonal move is left out when either cell it passes between is occupied, so a path never cuts the corner of an obstacle.
| void bitsim::planning::OccupancyGrid::set_occupied | ( | const GridCell & | c, |
| bool | occupied = true ) |
The cell that the point (x, y) is in. It may be out of bounds.
|
noexcept |
The centre of a cell [m].