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

#include <vector_nav_grid.h>

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

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...
 
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...
 
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...
 
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

std::vector< T > data_
 
- Protected Attributes inherited from nav_grid::NavGrid< T >
default_value_
 
NavGridInfo info_
 

Detailed Description

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

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.

Member Function Documentation

◆ getIndex() [1/2]

template<typename T>
unsigned int nav_grid::VectorNavGrid< T >::getIndex ( unsigned int  mx,
unsigned int  my 
) const
inline

Given two grid coordinates... compute the associated index.

Parameters
[in]mxThe x coordinate
[in]myThe y coordinate
Returns
The associated index

Definition at line 203 of file vector_nav_grid.h.

◆ getIndex() [2/2]

template<typename T>
unsigned int nav_grid::VectorNavGrid< T >::getIndex ( double  x,
double  y 
) const
inline

Given two world coordinates... compute the associated index.

Parameters
[in]mxThe x coordinate
[in]myThe y coordinate
Returns
The associated index

Definition at line 214 of file vector_nav_grid.h.

◆ getValue()

template<typename T>
T nav_grid::VectorNavGrid< T >::getValue ( const unsigned int  x,
const unsigned int  y 
) const
inlineoverridevirtual

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)

Implements nav_grid::NavGrid< T >.

Definition at line 176 of file vector_nav_grid.h.

◆ indexToCells()

template<typename T>
void nav_grid::VectorNavGrid< T >::indexToCells ( unsigned int  index,
unsigned int &  mx,
unsigned int &  my 
) const
inline

Given an index... compute the associated grid coordinates.

Parameters
[in]indexThe index
[out]mxSet to the associated x grid coordinate
[out]mySet to the associated y grid coordinate

Definition at line 227 of file vector_nav_grid.h.

◆ operator[]() [1/2]

template<typename T>
T nav_grid::VectorNavGrid< T >::operator[] ( unsigned int  i) const
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.

◆ operator[]() [2/2]

template<typename T>
T& nav_grid::VectorNavGrid< T >::operator[] ( unsigned int  i)
inline

Definition at line 189 of file vector_nav_grid.h.

◆ reset()

template<typename T>
void nav_grid::VectorNavGrid< T >::reset ( )
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.

◆ setInfo()

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

◆ setValue()

template<typename T>
void nav_grid::VectorNavGrid< T >::setValue ( const unsigned int  x,
const unsigned int  y,
const T &  value 
)
inlineoverridevirtual

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

Parameters
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.

◆ size()

template<typename T>
unsigned int nav_grid::VectorNavGrid< T >::size ( ) const
inline

Return the size of the vector. Equivalent to width * height.

Returns
size of the vector

Definition at line 195 of file vector_nav_grid.h.

◆ updateInfo()

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

Parameters
[in]new_infoNew information to update the grid with

Reimplemented from nav_grid::NavGrid< T >.

Definition at line 107 of file vector_nav_grid.h.

Member Data Documentation

◆ data_

template<typename T>
std::vector<T> nav_grid::VectorNavGrid< T >::data_
protected

Definition at line 235 of file vector_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