Public Types | Public Member Functions | Private Member Functions | Private Attributes
grid_map::GridMap Class Reference

#include <GridMap.hpp>

List of all members.

Public Types

typedef grid_map::DataType DataType
typedef grid_map::Matrix Matrix

Public Member Functions

void add (const std::string &layer, const double value=NAN)
void add (const std::string &layer, const Matrix &data)
bool addDataFrom (const GridMap &other, bool extendMap, bool overwriteData, bool copyAllLayers, std::vector< std::string > layers=std::vector< std::string >())
float & at (const std::string &layer, const Index &index)
float at (const std::string &layer, const Index &index) const
float & atPosition (const std::string &layer, const Position &position)
float atPosition (const std::string &layer, const Position &position, InterpolationMethods interpolationMethod=InterpolationMethods::INTER_NEAREST) const
void clear (const std::string &layer)
void clearAll ()
void clearBasic ()
void convertToDefaultStartIndex ()
bool erase (const std::string &layer)
bool exists (const std::string &layer) const
bool extendToInclude (const GridMap &other)
const Matrixget (const std::string &layer) const
Matrixget (const std::string &layer)
const std::vector< std::string > & getBasicLayers () const
const std::string & getFrameId () const
bool getIndex (const Position &position, Index &index) const
const std::vector< std::string > & getLayers () const
const LengthgetLength () const
bool getPosition (const Index &index, Position &position) const
const PositiongetPosition () const
bool getPosition3 (const std::string &layer, const Index &index, Position3 &position) const
double getResolution () const
const SizegetSize () const
const IndexgetStartIndex () const
GridMap getSubmap (const Position &position, const Length &length, bool &isSuccess) const
GridMap getSubmap (const Position &position, const Length &length, Index &indexInSubmap, bool &isSuccess) const
Time getTimestamp () const
bool getVector (const std::string &layerPrefix, const Index &index, Eigen::Vector3d &vector) const
 GridMap (const std::vector< std::string > &layers)
 GridMap ()
 GridMap (const GridMap &)
 GridMap (GridMap &&)
bool hasBasicLayers () const
bool hasSameLayers (const grid_map::GridMap &other) const
bool isDefaultStartIndex () const
bool isInside (const Position &position) const
bool isValid (const Index &index) const
bool isValid (const Index &index, const std::string &layer) const
bool isValid (const Index &index, const std::vector< std::string > &layers) const
bool move (const Position &position, std::vector< BufferRegion > &newRegions)
bool move (const Position &position)
GridMapoperator= (const GridMap &)
GridMapoperator= (GridMap &&)
const Matrixoperator[] (const std::string &layer) const
Matrixoperator[] (const std::string &layer)
void resetTimestamp ()
void setBasicLayers (const std::vector< std::string > &basicLayers)
void setFrameId (const std::string &frameId)
void setGeometry (const Length &length, const double resolution, const Position &position=Position::Zero())
void setGeometry (const SubmapGeometry &geometry)
void setPosition (const Position &position)
void setStartIndex (const Index &startIndex)
void setTimestamp (const Time timestamp)
virtual ~GridMap ()

Private Member Functions

bool atPositionLinearInterpolated (const std::string &layer, const Position &position, float &value) const
void clearCols (unsigned int index, unsigned int nCols)
void clearRows (unsigned int index, unsigned int nRows)
void resize (const Index &bufferSize)

Private Attributes

std::vector< std::string > basicLayers_
std::unordered_map
< std::string, Matrix
data_
 Grid map data stored as layers of matrices.
std::string frameId_
 Frame id of the grid map.
std::vector< std::string > layers_
 Names of the data layers.
Length length_
 Side length of the map in x- and y-direction [m].
Position position_
 Map position in the grid map frame [m].
double resolution_
 Map resolution in xy plane [m/cell].
Size size_
 Size of the buffer (rows and cols of the data structure).
Index startIndex_
 Circular buffer start indeces.
Time timestamp_
 Timestamp of the grid map (nanoseconds).

Detailed Description

Grid map managing multiple overlaying maps holding float values. Data structure implemented as two-dimensional circular buffer so map can be moved efficiently.

Data is defined with string keys. Examples are:

Definition at line 39 of file GridMap.hpp.


Member Typedef Documentation

Definition at line 43 of file GridMap.hpp.

Definition at line 44 of file GridMap.hpp.


Constructor & Destructor Documentation

grid_map::GridMap::GridMap ( const std::vector< std::string > &  layers)

Constructor.

Parameters:
layersa vector of strings containing the definition/description of the data layer.

Definition at line 27 of file GridMap.cpp.

Emtpy constructor.

Definition at line 42 of file GridMap.cpp.

Default copy assign and copy constructors.

Destructor.

Definition at line 47 of file GridMap.cpp.


Member Function Documentation

void grid_map::GridMap::add ( const std::string &  layer,
const double  value = NAN 
)

Add a new empty data layer.

Parameters:
layerthe name of the layer. value the value to initialize the cells with.

Definition at line 100 of file GridMap.cpp.

void grid_map::GridMap::add ( const std::string &  layer,
const Matrix data 
)

Add a new data layer (if the layer already exists, overwrite its data, otherwise add layer and data).

Parameters:
layerthe name of the layer.
datathe data to be added.

Definition at line 105 of file GridMap.cpp.

bool grid_map::GridMap::addDataFrom ( const GridMap other,
bool  extendMap,
bool  overwriteData,
bool  copyAllLayers,
std::vector< std::string >  layers = std::vector<std::string>() 
)

Adds data from an other grid map to this grid map

Parameters:
otherthe grid map to take data from.
extendMapif true the grid map is resized that the other map fits within.
overwriteDataif true the new data replaces the old values, else only invalid cells are updated.
copyAllLayerif true all layers are used to add data.
layersthe layers that are copied if not all layers are used.
Returns:
true if successful.

Definition at line 420 of file GridMap.cpp.

float & grid_map::GridMap::at ( const std::string &  layer,
const Index index 
)

Get cell data for requested index.

Parameters:
layerthe name of the layer to be accessed.
indexthe requested index.
Returns:
the data of the cell.
Exceptions:
std::out_of_rangeif no map layer with name `layer` is present.

Definition at line 209 of file GridMap.cpp.

float grid_map::GridMap::at ( const std::string &  layer,
const Index index 
) const

Get cell data for requested index. Const version form above.

Parameters:
layerthe name of the layer to be accessed.
indexthe requested index.
Returns:
the data of the cell.
Exceptions:
std::out_of_rangeif no map layer with name `layer` is present.

Definition at line 218 of file GridMap.cpp.

float & grid_map::GridMap::atPosition ( const std::string &  layer,
const Position position 
)

Get cell data at requested position.

Parameters:
layerthe name of the layer to be accessed.
positionthe requested position.
Returns:
the data of the cell.
Exceptions:
std::out_of_rangeif no map layer with name `layer` is present.

Definition at line 174 of file GridMap.cpp.

float grid_map::GridMap::atPosition ( const std::string &  layer,
const Position position,
InterpolationMethods  interpolationMethod = InterpolationMethods::INTER_NEAREST 
) const

Get cell data at requested position. Const version form above.

Parameters:
layerthe name of the layer to be accessed.
positionthe requested position.
Returns:
the data of the cell.
Exceptions:
std::out_of_rangeif no map layer with name `layer` is present.
std::runtime_errorif the specified interpolation method is not implemented.

Definition at line 183 of file GridMap.cpp.

bool grid_map::GridMap::atPositionLinearInterpolated ( const std::string &  layer,
const Position position,
float &  value 
) const [private]

Get cell data at requested position, linearly interpolated from 2x2 cells.

Parameters:
layerthe name of the layer to be accessed.
positionthe requested position.
valuethe data of the cell.
Returns:
true if linear interpolation was successful.

Definition at line 656 of file GridMap.cpp.

void grid_map::GridMap::clear ( const std::string &  layer)

Clears all cells (set to NAN) for a layer.

Parameters:
layerthe layer to be cleared.

Definition at line 613 of file GridMap.cpp.

Clears all cells of all layers. If basic layers are used, clearBasic() is preferred as it is more efficient. Header information (geometry etc.) remains valid.

Definition at line 629 of file GridMap.cpp.

Clears all cells (set to NAN) for all basic layers. Header information (geometry etc.) remains valid.

Definition at line 622 of file GridMap.cpp.

void grid_map::GridMap::clearCols ( unsigned int  index,
unsigned int  nCols 
) [private]

Clear a number of columns of the grid map.

Parameters:
indexthe left index for the columns to be reset.
nColsthe number of columns to reset.

Definition at line 646 of file GridMap.cpp.

void grid_map::GridMap::clearRows ( unsigned int  index,
unsigned int  nRows 
) [private]

Clear a number of rows of the grid map.

Parameters:
indexthe upper index for the rows to be reset.
nRowsthe number of rows to reset.

Definition at line 636 of file GridMap.cpp.

Rearranges data such that the buffer start index is at (0,0).

Definition at line 582 of file GridMap.cpp.

bool grid_map::GridMap::erase ( const std::string &  layer)

Removes a layer from the grid map.

Parameters:
layerthe name of the layer to be removed.
Returns:
true if successful.

Definition at line 153 of file GridMap.cpp.

bool grid_map::GridMap::exists ( const std::string &  layer) const

Checks if data layer exists.

Parameters:
layerthe name of the layer.
Returns:
true if layer exists, false otherwise.

Definition at line 120 of file GridMap.cpp.

Extends the size of the grip map such that the other grid map fits within.

Parameters:
otherthe grid map to extend the size to.
Returns:
true if successful.

Definition at line 452 of file GridMap.cpp.

const Matrix & grid_map::GridMap::get ( const std::string &  layer) const

Returns the grid map data for a layer as matrix.

Parameters:
layerthe name of the layer to be returned.
Returns:
grid map data as matrix.
Exceptions:
std::out_of_rangeif no map layer with name `layer` is present.

Definition at line 125 of file GridMap.cpp.

Matrix & grid_map::GridMap::get ( const std::string &  layer)

Returns the grid map data for a layer as non-const. Use this method with care!

Parameters:
layerthe name of the layer to be returned.
Returns:
grid map data.
Exceptions:
std::out_of_rangeif no map layer with name `layer` is present.

Definition at line 134 of file GridMap.cpp.

const std::vector< std::string > & grid_map::GridMap::getBasicLayers ( ) const

Gets the names of the basic layers.

Returns:
the names of the basic layers.

Definition at line 82 of file GridMap.cpp.

const std::string & grid_map::GridMap::getFrameId ( ) const

Get the frameId of the grid map.

Returns:
frameId.

Definition at line 543 of file GridMap.cpp.

bool grid_map::GridMap::getIndex ( const Position position,
Index index 
) const

Gets the corresponding cell index for a position.

Parameters:
[in]positionthe requested position.
[out]indexthe corresponding index.
Returns:
true if successful, false if position outside of map.

Definition at line 227 of file GridMap.cpp.

const std::vector< std::string > & grid_map::GridMap::getLayers ( ) const

Gets the names of the layers.

Returns:
the names of the layers.

Definition at line 169 of file GridMap.cpp.

Get the side length of the grid map.

Returns:
side length of the grid map.

Definition at line 548 of file GridMap.cpp.

bool grid_map::GridMap::getPosition ( const Index index,
Position position 
) const

Gets the 2d position of cell specified by the index (x, y of cell position) in the grid map frame.

Parameters:
[in]indexthe index of the requested cell.
[out]positionthe position of the data point in the parent frame.
Returns:
true if successful, false if index not within range of buffer.

Definition at line 232 of file GridMap.cpp.

Get the 2d position of the grid map in the grid map frame.

Returns:
position of the grid map in the grid map frame.

Definition at line 553 of file GridMap.cpp.

bool grid_map::GridMap::getPosition3 ( const std::string &  layer,
const Index index,
Position3 position 
) const

Gets the 3d position of a data point (x, y of cell position & cell value as z) in the grid map frame. This is useful for data layers such as elevation.

Parameters:
layerthe name of the layer to be accessed.
indexthe index of the requested cell.
positionthe position of the data point in the parent frame.
Returns:
true if successful, false if no valid data available.

Definition at line 262 of file GridMap.cpp.

Get the resolution of the grid map.

Returns:
resolution of the grid map in the xy plane [m/cell].

Definition at line 558 of file GridMap.cpp.

const Size & grid_map::GridMap::getSize ( ) const

Get the grid map size (rows and cols of the data structure).

Returns:
grid map size.

Definition at line 563 of file GridMap.cpp.

Get the start index of the circular buffer.

Returns:
buffer start index.

Definition at line 572 of file GridMap.cpp.

GridMap grid_map::GridMap::getSubmap ( const Position position,
const Length length,
bool &  isSuccess 
) const

Gets a submap from the map. The requested submap is specified with the requested location and length. Note: The returned submap may not have the requested length due to the borders of the map and discretization.

Parameters:
[in]positionthe requested position of the submap (usually the center).
[in]lengththe requested length of the submap.
[out]isSuccesstrue if successful, false otherwise.
Returns:
submap (is empty if success is false).

Definition at line 287 of file GridMap.cpp.

GridMap grid_map::GridMap::getSubmap ( const Position position,
const Length length,
Index indexInSubmap,
bool &  isSuccess 
) const

Gets a submap from the map. The requested submap is specified with the requested location and length. Note: The returned submap may not have the requested length due to the borders of the map and discretization.

Parameters:
[in]positionthe requested position of the submap (usually the center).
[in]lengththe requested length of the submap.
[out]indexInSubmapthe index of the requested position in the submap.
[out]isSuccesstrue if successful, false otherwise.
Returns:
submap (is empty if success is false).

Definition at line 294 of file GridMap.cpp.

Get the timestamp of the grid map.

Returns:
timestamp in nanoseconds.

Definition at line 528 of file GridMap.cpp.

bool grid_map::GridMap::getVector ( const std::string &  layerPrefix,
const Index index,
Eigen::Vector3d &  vector 
) const

Gets the 3d vector of three layers with suffixes 'x', 'y', and 'z'.

Parameters:
layerPrefixthe prefix for the layer to bet get as vector.
indexthe index of the requested cell.
vectorthe vector with the values of the data type.
Returns:
true if successful, false if no valid data available.

Definition at line 273 of file GridMap.cpp.

True if basic layers are defined.

Returns:
true if basic layers are defined, false otherwise.

Definition at line 87 of file GridMap.cpp.

bool grid_map::GridMap::hasSameLayers ( const grid_map::GridMap other) const

Checks if another grid map contains the same layers as this grid map. The other grid map could contain more layers than the checked ones. Does not check the selection of basic layers.

Parameters:
otherthe other grid map.
Returns:
true if the other grid map has the same layers, false otherwise.

Definition at line 92 of file GridMap.cpp.

Checks if the buffer is at start index (0,0).

Returns:
true if buffer is at default start index.

Definition at line 577 of file GridMap.cpp.

bool grid_map::GridMap::isInside ( const Position position) const

Check if position is within the map boundaries.

Parameters:
positionthe position to be checked.
Returns:
true if position is within map, false otherwise.

Definition at line 237 of file GridMap.cpp.

bool grid_map::GridMap::isValid ( const Index index) const

Checks if the index of all layers defined as basic types are valid, i.e. if all basic types are finite. Returns `false` if no basic types are defined.

Parameters:
indexthe index to check.
Returns:
true if cell is valid, false otherwise.

Definition at line 242 of file GridMap.cpp.

bool grid_map::GridMap::isValid ( const Index index,
const std::string &  layer 
) const

Checks if cell at index is a valid (finite) for a certain layer.

Parameters:
indexthe index to check.
layerthe name of the layer to be checked for validity.
Returns:
true if cell is valid, false otherwise.

Definition at line 247 of file GridMap.cpp.

bool grid_map::GridMap::isValid ( const Index index,
const std::vector< std::string > &  layers 
) const

Checks if cell at index is a valid (finite) for certain layers.

Parameters:
indexthe index to check.
layersthe layers to be checked for validity.
Returns:
true if cell is valid, false otherwise.

Definition at line 253 of file GridMap.cpp.

bool grid_map::GridMap::move ( const Position position,
std::vector< BufferRegion > &  newRegions 
)

Move the grid map w.r.t. to the grid map frame. Use this to move the grid map boundaries without moving the grid map data. Takes care of all the data handling, such that the grid map data is stationary in the grid map frame. Note: For a comparison between the `setPosition` and the `move` method, see the `move_demo_node.cpp` file of the `grid_map_demos` package.

Parameters:
positionthe new location of the grid map in the map frame.
newRegionsthe regions of the newly covered / previously uncovered regions of the buffer.
Returns:
true if map has been moved, false otherwise.

Definition at line 346 of file GridMap.cpp.

bool grid_map::GridMap::move ( const Position position)

Move the grid map w.r.t. to the grid map frame. Use this to move the grid map boundaries without moving the grid map data. Takes care of all the data handling, such that the grid map data is stationary in the grid map frame.

Parameters:
positionthe new location of the grid map in the map frame.
Returns:
true if map has been moved, false otherwise.

Definition at line 414 of file GridMap.cpp.

GridMap& grid_map::GridMap::operator= ( const GridMap )
GridMap& grid_map::GridMap::operator= ( GridMap &&  )
const Matrix & grid_map::GridMap::operator[] ( const std::string &  layer) const

Returns the grid map data for a layer as matrix.

Parameters:
layerthe name of the layer to be returned.
Returns:
grid map data as matrix.
Exceptions:
std::out_of_rangeif no map layer with name `layer` is present.

Definition at line 143 of file GridMap.cpp.

Matrix & grid_map::GridMap::operator[] ( const std::string &  layer)

Returns the grid map data for a layer as non-const. Use this method with care!

Parameters:
layerthe name of the layer to be returned.
Returns:
grid map data.
Exceptions:
std::out_of_rangeif no map layer with name `layer` is present.

Definition at line 148 of file GridMap.cpp.

Resets the timestamp of the grid map (to zero).

Definition at line 533 of file GridMap.cpp.

void grid_map::GridMap::resize ( const Index bufferSize) [private]

Resize the buffer.

Parameters:
bufferSizethe requested buffer size.

Definition at line 712 of file GridMap.cpp.

void grid_map::GridMap::setBasicLayers ( const std::vector< std::string > &  basicLayers)

Set the basic layers that need to be valid for a cell to be considered as valid. Also, the basic layers are set to NAN when clearing the cells with `clearBasic()`. By default the list of basic layers is empty.

Parameters:
basicLayersthe list of layers that are the basic layers of the map.

Definition at line 77 of file GridMap.cpp.

void grid_map::GridMap::setFrameId ( const std::string &  frameId)

Set the frame id of the grid map.

Parameters:
frameIdthe frame id to set.

Definition at line 538 of file GridMap.cpp.

void grid_map::GridMap::setGeometry ( const Length length,
const double  resolution,
const Position position = Position::Zero() 
)

Set the geometry of the grid map. Clears all the data.

Parameters:
lengththe side lengths in x, and y-direction of the grid map [m].
resolutionthe cell size in [m/cell].
positionthe 2d position of the grid map in the grid map frame [m].

Definition at line 51 of file GridMap.cpp.

void grid_map::GridMap::setGeometry ( const SubmapGeometry geometry)

Set the geometry of the grid map from submap geometry information.

Parameters:
geometrythe submap geometry information.

Definition at line 72 of file GridMap.cpp.

void grid_map::GridMap::setPosition ( const Position position)

Set the position of the grid map. Note: This method does not change the data stored in the grid map and is complementary to the `move(...)` method. For a comparison between the `setPosition` and the `move` method, see the `move_demo_node.cpp` file of the `grid_map_demos` package.

Parameters:
positionthe 2d position of the grid map in the grid map frame [m].

Definition at line 341 of file GridMap.cpp.

void grid_map::GridMap::setStartIndex ( const Index startIndex)

Set the start index of the circular buffer. Use this method with caution!

Returns:
buffer start index.

Definition at line 568 of file GridMap.cpp.

void grid_map::GridMap::setTimestamp ( const Time  timestamp)

Set the timestamp of the grid map.

Parameters:
timestampthe timestamp to set (in nanoseconds).

Definition at line 523 of file GridMap.cpp.


Member Data Documentation

std::vector<std::string> grid_map::GridMap::basicLayers_ [private]

List of layers from `data_` that are the basic grid map layers. This means that for a cell to be valid, all basic layers need to be valid. Also, the basic layers are set to NAN when clearing the map with `clear()`.

Definition at line 507 of file GridMap.hpp.

std::unordered_map<std::string, Matrix> grid_map::GridMap::data_ [private]

Grid map data stored as layers of matrices.

Definition at line 499 of file GridMap.hpp.

std::string grid_map::GridMap::frameId_ [private]

Frame id of the grid map.

Definition at line 493 of file GridMap.hpp.

std::vector<std::string> grid_map::GridMap::layers_ [private]

Names of the data layers.

Definition at line 502 of file GridMap.hpp.

Side length of the map in x- and y-direction [m].

Definition at line 510 of file GridMap.hpp.

Map position in the grid map frame [m].

Definition at line 516 of file GridMap.hpp.

Map resolution in xy plane [m/cell].

Definition at line 513 of file GridMap.hpp.

Size of the buffer (rows and cols of the data structure).

Definition at line 519 of file GridMap.hpp.

Circular buffer start indeces.

Definition at line 522 of file GridMap.hpp.

Timestamp of the grid map (nanoseconds).

Definition at line 496 of file GridMap.hpp.


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


grid_map_core
Author(s): Péter Fankhauser
autogenerated on Mon Oct 9 2017 03:09:17