#include <nav_grid.h>
Public Member Functions | |
std::string | getFrameId () const |
unsigned int | getHeight () const |
NavGridInfo | getInfo () const |
double | getOriginX () const |
double | getOriginY () const |
double | getResolution () const |
virtual T | getValue (const unsigned int x, const unsigned int y) const =0 |
get the value of the grid at (x,y) More... | |
unsigned int | getWidth () const |
NavGrid (const T default_value=T{}) | |
virtual void | reset ()=0 |
Reset the contents of the grid. More... | |
void | setDefaultValue (const T new_value) |
Set the default value. More... | |
virtual void | setInfo (const NavGridInfo &new_info)=0 |
Change the info while attempting to keep the values associated with the grid coordinates. More... | |
virtual void | setValue (const unsigned int x, const unsigned int y, const T &value)=0 |
set the value of the grid at (x,y) More... | |
virtual void | updateInfo (const NavGridInfo &new_info) |
Change the info while attempting to keep the values associated with the world coordinates. More... | |
Convenience Aliases | |
T | getValue (const Index &index) |
T | operator() (const unsigned int x, const unsigned int y) const |
T | operator() (const Index &index) const |
void | setValue (const Index &index, const T &value) |
Protected Attributes | |
T | default_value_ |
NavGridInfo | info_ |
This class is a spiritual successor to the costmap_2d::Costmap2D class, with the key differences being that the datatype and data storage methods are not specified, and the frame_id is specified.
The templatized nature of the class allows you to store whatever you like at each grid location, including unsigned chars if emulating Costmap2D or floating point numbers if emulating the grid_map package, or whatever else.
The VectorNavGrid class in this package implements this class with a straight-forward single-dimensional vector representing the two dimensional grid. Other classes could implement the data storage differently.
Getting data from the grid can be done either through the getValue methods or the parenthetical operators (which call getValue internally). Implementing classes must implement getValue. x = grid(0, 0) + grid.getValue(0, 1);
Writing data to the grid must be done through the setValue method (which implementing classes must implement) grid.setValue(0, 0, x);
You can also use nav_grid::Index objects nav_grid::Index index(0, 0); x = grid(index) + grid.getValue(index); index.y = 3; grid.setCost(index, x); The Index methods also internally call setValue/getValue
The geometry of the grid is specified by the NavGridInfo. Borrowing an idea from the grid_map package, two separate methods are defined for changing the info. setInfo will change the info without changing the grid values. updateInfo will change the info while trying to preserve the contents of the grid.
The final component is a collection of methods inspired by Costmap2D for converting coordinates of different types.
Definition at line 76 of file nav_grid.h.
|
inlineexplicit |
Definition at line 79 of file nav_grid.h.
|
inline |
Definition at line 146 of file nav_grid.h.
|
inline |
Definition at line 144 of file nav_grid.h.
|
inline |
Definition at line 129 of file nav_grid.h.
|
inline |
Definition at line 147 of file nav_grid.h.
|
inline |
Definition at line 148 of file nav_grid.h.
|
inline |
Definition at line 145 of file nav_grid.h.
|
pure virtual |
get the value of the grid at (x,y)
x[in] | Valid x coordinate |
y[in] | Valid y coordinate |
Implemented in nav_grid::VectorNavGrid< T >.
|
inline |
Definition at line 106 of file nav_grid.h.
|
inline |
Definition at line 143 of file nav_grid.h.
|
inline |
Definition at line 107 of file nav_grid.h.
|
inline |
Definition at line 108 of file nav_grid.h.
|
pure virtual |
Reset the contents of the grid.
Implemented in nav_grid::VectorNavGrid< T >.
|
inline |
Set the default value.
[in] | new_value | New Default Value |
Definition at line 135 of file nav_grid.h.
|
pure virtual |
Change the info while attempting to keep the values associated with the grid coordinates.
[in] | new_info | New grid info |
Implemented in nav_grid::VectorNavGrid< T >.
|
pure virtual |
set the value of the grid at (x,y)
x[in] | Valid x coordinate |
y[in] | Valid y coordinate |
value[in] | New Value |
Implemented in nav_grid::VectorNavGrid< T >.
|
inline |
Definition at line 109 of file nav_grid.h.
|
inlinevirtual |
Change the info while attempting to keep the values associated with the world coordinates.
For example, if the only change to the info is to the origin's x coordinate (increasing by an amount equal to the resolution), then all the values should be shifted one grid cell to the left.
[in] | new_info | New grid info |
Reimplemented in nav_grid::VectorNavGrid< T >.
Definition at line 127 of file nav_grid.h.
|
protected |
Definition at line 152 of file nav_grid.h.
|
protected |
Definition at line 151 of file nav_grid.h.