Template Class Costmap2DConverter

Class Documentation

template<typename MapType, typename TranslationTable = Costmap2DDefaultTranslationTable<typename MapType::DataType>>
class Costmap2DConverter

Convert Costmap2DRos objects into cost or grid maps.

See also

Costmap2DDirectTranslationTable, Costmap2DCenturyTranslationTable

Template Parameters:
  • MapType – : either grid_map::GridMap or cost_map::CostMap

  • TranslationTable – : class that creates a cost -> new type conversion table

Public Functions

Costmap2DConverter() = default
virtual ~Costmap2DConverter() = default
inline void initializeFromGridMap(const MapType &gridMap, nav2_costmap_2d::Costmap2D &outputCostmap)

Initialize cost map size and properties from a grid map.

Parameters:
  • gridMap – Grid map containing size info and properties.

  • outputCostmap – Resized costmap.

inline bool setCostmap2DFromGridMap(const MapType &gridMap, const std::string &layer, nav2_costmap_2d::Costmap2D &outputCostmap)

Load the grid map layer into the costmap2d object.

Parameters:
  • outputMap – from this gridmap type object.

  • layer – the name of the layer to convert.

  • outputCostmap – to this costmap type object.

Returns:

true if successful, false otherwise.

inline void initializeFromCostmap2D(nav2_costmap_2d::Costmap2DROS &costmap2d, MapType &outputMap)
inline void initializeFromCostmap2D(const nav2_costmap_2d::Costmap2D &costmap2d, MapType &outputMap)
inline bool addLayerFromCostmap2D(const nav2_costmap_2d::Costmap2D &costmap2d, const std::string &layer, MapType &outputMap)

Load the costmap2d into the specified layer.

Warning

This does not lock the costmap2d object, you should take care to do so from outside this function.

Parameters:
  • costmap2d – from this costmap type object.

  • layer – the name of the layer to insert.

  • outputMap – to this costmap type object.

Returns:

true if successful, false otherwise.

inline bool addLayerFromCostmap2D(nav2_costmap_2d::Costmap2DROS &costmap2d, const std::string &layer, MapType &outputMap)

Load the costmap2d into the specified layer.

Warning

This does not lock the costmap2d object, you should take care to do so from outside this function.

Parameters:
  • costmap2d – from this costmap type object.

  • layer – the name of the layer to insert.

  • outputMap – to this costmap type object.

Returns:

true if successful, false otherwise.

inline bool initializeFromCostmap2DAtRobotPose(nav2_costmap_2d::Costmap2DROS &costmap2d, const Length &length, MapType &outputMap)

Initialize the output map at the robot pose of the underlying Costmap2DROS object.

Note: This needs some beyond just fixing the center of the output map to the robot pose itself. To avoid introducing error, you want to shift the center so the underlying costmap2d cells align with the newly created map object. This does that here.

Warning

this does not lock the costmap2d object, you should take care to do so from outside this function in scope with any addLayerFromCostmap2DAtRobotPose calls you wish to make.

Parameters:
  • costmap2d – : the underlying Costmap2DROS object

  • geometry – size of the subwindow to snapshot around the robot pose

  • outputMap – : initialise the output map with the required parameters

inline bool addLayerFromCostmap2DAtRobotPose(nav2_costmap_2d::Costmap2DROS &costmap2d, const std::string &layer, MapType &outputMap)

Fill a layer in the output map with data from the subwindow centered at the robot pose.

Warning

This does not lock the costmap2d object, you should take care to do so from outside this function in scope with any initializeFromCostmap2DAtRobotPose calls you wish to make.

Parameters:
  • costmap2d – the underlying Costmap2DROS object.

  • layer – the layer name to add.

  • outputMap – the initialized and filled in map output map.

inline std::string errorMessage() const

Human readable error message string.

Can be used to get a human readable description of the error type after one of the class methods has failed.

Returns:

std::string