|
TinyRobotics
|
A grid map for spatial representation, navigation, and planning. More...
#include <GridMap.h>


Classes | |
| struct | Cell |
| Cell structure to represent grid cell indices. More... | |
Public Member Functions | |
| GridMap ()=default | |
| Default constructor. | |
| GridMap (int xCount, int yCount, DistanceM resolutionM) | |
| Construct with cell counts and resolution in meters. | |
| GridMap (int xCount, int yCount, Distance resolution) | |
| Construct with cell counts and Distance object for resolution. | |
| bool | worldToCell (DistanceM wx, DistanceM wy, Cell &cell) const |
| World to cell conversion. | |
| void | cellToWorld (int cx, int cy, DistanceM &wx, DistanceM &wy) const |
| Cell to world (center of cell) | |
| Coordinate< DistanceM > | toWorld (int cx, int cy) const |
| Provide the workd coordinates for the cell. | |
| bool | getCell (int cx, int cy, StateT &result) |
| Provide access to cell state by cell index. | |
| bool | getCell (int cx, int cy, CellState &result) const |
| Provide access to cell state by cell index. | |
| bool | getCell (Coordinate< T > &coord, CellState &result) |
| Provide access to cell state by coordinate. | |
| void | setCell (Cell &cell, CellState value) |
| Provide access to cell state by coordinate. | |
| void | setCell (int cx, int cy, CellState value) |
| Set cell state (for initialization or manual updates) | |
| void | setCell (Coordinate< T > &coord, CellState value) |
| Set cell state by coordinate (converts to cell index internally) | |
| std::vector< Cell > | getNeighborCells (const Coordinate< DistanceM > from) const |
| Determine all neighboring cells (8-connected) for a given cell coordinate. | |
| std::vector< Coordinate< T > > | getNeighbors (Coordinate< T > from) const |
| Get world coordinates of neighboring cells (for pathfinding or navigation) | |
| void | resize (int newXCount, int newYCount) |
| Resize the grid to new dimensions. | |
| int | getXCount () const |
| Get the number of cells in the x direction. | |
| int | getYCount () const |
| Get the number of cells in the y direction. | |
| float | getResolution () const |
| Get the cell resolution in meters. | |
| void | setResolution (float resM) |
| Defines the resolution in meters. | |
| bool | isValid (const Coordinate< T > &coord) const |
| Check if a coordinate is within the map bounds. | |
| void | setCellStateCallback (CellState(*cb)(const StateT &, void *ref)) |
| Set the callback for converting StateType to CellState. | |
| void | setValidityCallback (bool(*cb)(int cx, int cy, void *ref)) |
| Set the callback for cell validity checking. | |
| void | setReference (void *ref) |
| Set the reference pointer passed to callbacks. | |
| size_t | writeTo (Print &out) |
| Write map to output. | |
| size_t | readFrom (Stream &in) |
| Read map from input. | |
| virtual int | getXCount () const =0 |
| Get the number of cells in the X direction. | |
| virtual int | getYCount () const =0 |
| Get the number of cells in the Y direction. | |
| virtual float | getResolution () const =0 |
| Get the map resolution (cell size in meters). | |
| virtual bool | getCell (int x, int y, CellState &state) const =0 |
| Get the state of a cell by integer indices. | |
| virtual Coordinate< T > | toWorld (int x, int y) const =0 |
| Convert cell indices to world coordinates. | |
| virtual std::vector< Coordinate< T > > | getNeighbors (Coordinate< T > from) const =0 |
| Get world coordinates of neighboring cells (for pathfinding or navigation). | |
| virtual bool | isValid (const Coordinate< T > &coord) const =0 |
| Check if a coordinate is inside the map bounds. | |
Static Protected Member Functions | |
| static bool | isValid (int cx, int cy, void *ref) |
Protected Attributes | |
| int | xCount = 0 |
| int | yCount = 0 |
| float | resolution = 0 |
| Coordinate< T > | origin |
| void * | reference = this |
| bool(* | is_valid_cb )(int cx, int cy, void *) = isValid |
| CellState(* | get_cellstate_cb )(const StateT &, void *ref) = nullptr |
| std::vector< StateT, AllocatorPSRAM< StateT > > | data |
| GridMapSerializer< GridMap< StateT >, StateT, T > | serializer |
A grid map for spatial representation, navigation, and planning.
The GridMap class models the environment as a regular grid of cells, each storing a state (e.g., occupancy, height, or other user-defined data). It supports:
Typical use cases include:
Features:
Callback Notes:
Example:
| StateType | The type stored in each cell (e.g., occupancy, height) |
| T | Numeric type for coordinates (default: float) |
|
inlinevirtual |
Provide access to cell state by cell index.
Implements IMap< T >.
|
inlinevirtual |
Get world coordinates of neighboring cells (for pathfinding or navigation)
Implements IMapNeighbors< T >.
|
inlinevirtual |
Get the cell resolution in meters.
Implements IMap< T >.
|
inlinevirtual |
Get the number of cells in the x direction.
Implements IMap< T >.
|
inlinevirtual |
Get the number of cells in the y direction.
Implements IMap< T >.
|
inlinevirtual |
Check if a coordinate is within the map bounds.
| coord | The coordinate to check. |
Implements IMapNeighbors< T >.
|
inlinestaticprotected |
Default validity check: a cell is valid if it's not occupied. This can be overridden with a custom callback for more complex logic (e.g., dynamic obstacles, special terrain, etc.).
|
inlinevirtual |
Provide the workd coordinates for the cell.
Implements IMap< T >.