Public Member Functions | Protected Attributes | List of all members
nav_grid::NavGrid< T > Class Template Referenceabstract

#include <nav_grid.h>

Inheritance diagram for nav_grid::NavGrid< T >:
Inheritance graph
[legend]

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
getValue (const Index &index)
 
operator() (const unsigned int x, const unsigned int y) const
 
operator() (const Index &index) const
 
void setValue (const Index &index, const T &value)
 

Protected Attributes

default_value_
 
NavGridInfo info_
 

Detailed Description

template<typename T>
class nav_grid::NavGrid< T >

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.

Constructor & Destructor Documentation

◆ NavGrid()

template<typename T >
nav_grid::NavGrid< T >::NavGrid ( const T  default_value = T{})
inlineexplicit

Definition at line 79 of file nav_grid.h.

Member Function Documentation

◆ getFrameId()

template<typename T >
std::string nav_grid::NavGrid< T >::getFrameId ( ) const
inline

Definition at line 146 of file nav_grid.h.

◆ getHeight()

template<typename T >
unsigned int nav_grid::NavGrid< T >::getHeight ( ) const
inline

Definition at line 144 of file nav_grid.h.

◆ getInfo()

template<typename T >
NavGridInfo nav_grid::NavGrid< T >::getInfo ( ) const
inline

Definition at line 129 of file nav_grid.h.

◆ getOriginX()

template<typename T >
double nav_grid::NavGrid< T >::getOriginX ( ) const
inline

Definition at line 147 of file nav_grid.h.

◆ getOriginY()

template<typename T >
double nav_grid::NavGrid< T >::getOriginY ( ) const
inline

Definition at line 148 of file nav_grid.h.

◆ getResolution()

template<typename T >
double nav_grid::NavGrid< T >::getResolution ( ) const
inline

Definition at line 145 of file nav_grid.h.

◆ getValue() [1/2]

template<typename T >
virtual T nav_grid::NavGrid< T >::getValue ( const unsigned int  x,
const unsigned int  y 
) const
pure virtual

get the value of the grid at (x,y)

Parameters
x[in]Valid x coordinate
y[in]Valid y coordinate
Returns
value at (x,y)

Implemented in nav_grid::VectorNavGrid< T >.

◆ getValue() [2/2]

template<typename T >
T nav_grid::NavGrid< T >::getValue ( const Index index)
inline

Definition at line 106 of file nav_grid.h.

◆ getWidth()

template<typename T >
unsigned int nav_grid::NavGrid< T >::getWidth ( ) const
inline

Definition at line 143 of file nav_grid.h.

◆ operator()() [1/2]

template<typename T >
T nav_grid::NavGrid< T >::operator() ( const unsigned int  x,
const unsigned int  y 
) const
inline

Definition at line 107 of file nav_grid.h.

◆ operator()() [2/2]

template<typename T >
T nav_grid::NavGrid< T >::operator() ( const Index index) const
inline

Definition at line 108 of file nav_grid.h.

◆ reset()

template<typename T >
virtual void nav_grid::NavGrid< T >::reset ( )
pure virtual

Reset the contents of the grid.

Implemented in nav_grid::VectorNavGrid< T >.

◆ setDefaultValue()

template<typename T >
void nav_grid::NavGrid< T >::setDefaultValue ( const T  new_value)
inline

Set the default value.

Parameters
[in]new_valueNew Default Value

Definition at line 135 of file nav_grid.h.

◆ setInfo()

template<typename T >
virtual void nav_grid::NavGrid< T >::setInfo ( const NavGridInfo new_info)
pure virtual

Change the info while attempting to keep the values associated with the grid coordinates.

Parameters
[in]new_infoNew grid info

Implemented in nav_grid::VectorNavGrid< T >.

◆ setValue() [1/2]

template<typename T >
virtual void nav_grid::NavGrid< T >::setValue ( const unsigned int  x,
const unsigned int  y,
const T &  value 
)
pure virtual

set the value of the grid at (x,y)

Parameters
x[in]Valid x coordinate
y[in]Valid y coordinate
value[in]New Value

Implemented in nav_grid::VectorNavGrid< T >.

◆ setValue() [2/2]

template<typename T >
void nav_grid::NavGrid< T >::setValue ( const Index index,
const T &  value 
)
inline

Definition at line 109 of file nav_grid.h.

◆ updateInfo()

template<typename T >
virtual void nav_grid::NavGrid< T >::updateInfo ( const NavGridInfo new_info)
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.

Parameters
[in]new_infoNew grid info

Reimplemented in nav_grid::VectorNavGrid< T >.

Definition at line 127 of file nav_grid.h.

Member Data Documentation

◆ default_value_

template<typename T >
T nav_grid::NavGrid< T >::default_value_
protected

Definition at line 152 of file nav_grid.h.

◆ info_

template<typename T >
NavGridInfo nav_grid::NavGrid< T >::info_
protected

Definition at line 151 of file nav_grid.h.


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


nav_grid
Author(s):
autogenerated on Mon Feb 28 2022 23:32:36