#include <vector_nav_grid.h>
Public Member Functions | |
unsigned int | getIndex (unsigned int mx, unsigned int my) const |
Given two grid coordinates... compute the associated index. More... | |
unsigned int | getIndex (double x, double y) const |
Given two world coordinates... compute the associated index. More... | |
T | getValue (const unsigned int x, const unsigned int y) const override |
get the value of the grid at (x,y) More... | |
void | indexToCells (unsigned int index, unsigned int &mx, unsigned int &my) const |
Given an index... compute the associated grid coordinates. More... | |
T | operator[] (unsigned int i) const |
T & | operator[] (unsigned int i) |
void | reset () override |
Reset the contents of the grid to the default value. More... | |
void | setInfo (const NavGridInfo &new_info) override |
Change the info while attempting to keep the values associated with the grid coordinates. More... | |
void | setValue (const unsigned int x, const unsigned int y, const T &value) override |
set the value of the grid at (x,y) More... | |
unsigned int | size () const |
Return the size of the vector. Equivalent to width * height. More... | |
void | updateInfo (const NavGridInfo &new_info) override |
Update the info while keeping the data geometrically in tact. More... | |
Public Member Functions inherited from nav_grid::NavGrid< T > | |
std::string | getFrameId () const |
unsigned int | getHeight () const |
NavGridInfo | getInfo () const |
double | getOriginX () const |
double | getOriginY () const |
double | getResolution () const |
unsigned int | getWidth () const |
NavGrid (const T default_value=T{}) | |
void | setDefaultValue (const T new_value) |
Set the default value. More... | |
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 | |
std::vector< T > | data_ |
Protected Attributes inherited from nav_grid::NavGrid< T > | |
T | default_value_ |
NavGridInfo | info_ |
A straight-forward implementation of the NavGrid class where the data for cell (x, y) is stored in a std::vector with index (y * info.width + x).
Definition at line 50 of file vector_nav_grid.h.
|
inline |
Given two grid coordinates... compute the associated index.
[in] | mx | The x coordinate |
[in] | my | The y coordinate |
Definition at line 203 of file vector_nav_grid.h.
|
inline |
Given two world coordinates... compute the associated index.
[in] | mx | The x coordinate |
[in] | my | The y coordinate |
Definition at line 214 of file vector_nav_grid.h.
|
inlineoverridevirtual |
get the value of the grid at (x,y)
x[in] | Valid x coordinate |
y[in] | Valid y coordinate |
Implements nav_grid::NavGrid< T >.
Definition at line 176 of file vector_nav_grid.h.
|
inline |
Given an index... compute the associated grid coordinates.
[in] | index | The index |
[out] | mx | Set to the associated x grid coordinate |
[out] | my | Set to the associated y grid coordinate |
Definition at line 227 of file vector_nav_grid.h.
|
inline |
Overloading the [] operator so that the data can be accessed directly with vector_nav_grid[i]
Definition at line 188 of file vector_nav_grid.h.
|
inline |
Definition at line 189 of file vector_nav_grid.h.
|
inlineoverridevirtual |
Reset the contents of the grid to the default value.
Implements nav_grid::NavGrid< T >.
Definition at line 58 of file vector_nav_grid.h.
|
inlineoverridevirtual |
Change the info while attempting to keep the values associated with the grid coordinates.
If the width changes, we need to move each row to its new location
If just the height changes, then we can resize the vector without having to move elements
We just overwrite the rest of the grid info
Implements nav_grid::NavGrid< T >.
Definition at line 72 of file vector_nav_grid.h.
|
inlineoverridevirtual |
set the value of the grid at (x,y)
x[in] | Valid x coordinate |
y[in] | Valid y coordinate |
value[in] | New Value |
Implements nav_grid::NavGrid< T >.
Definition at line 171 of file vector_nav_grid.h.
|
inline |
Return the size of the vector. Equivalent to width * height.
Definition at line 195 of file vector_nav_grid.h.
|
inlineoverridevirtual |
Update the info while keeping the data geometrically in tact.
If the resolution or frame_id changes, reset all the data.
Otherwise, adjust the new_info so the grid stays aligned (The grid's new info will be within a resolution-length of the original new_info). Then copy the common values into the new grid.
[in] | new_info | New information to update the grid with |
Reimplemented from nav_grid::NavGrid< T >.
Definition at line 107 of file vector_nav_grid.h.
|
protected |
Definition at line 235 of file vector_nav_grid.h.