Wiki

Costmap2DROS

The costmap_2d::Costmap2DROS object is a wrapper for a costmap_2d::Costmap2D object that exposes its functionality as a C++ ROS Wrapper. It operates within a ROS namespace (assumed to be name from here on) specified on initialization.

Example creation of a costmap_2d::Costmap2DROS object specifying the my_costmap namespace:

   1 #include <tf/transform_listener.h>
   2 #include <costmap_2d/costmap_2d_ros.h>
   3 
   4 ...
   5 
   6 tf::TransformListener tf(ros::Duration(10));
   7 costmap_2d::Costmap2DROS costmap("my_costmap", tf);

If you rosrun or roslaunch the costmap_2d node directly it will run in the costmap namespace. In this case all references to name below should be replaced with costmap.

The more common case is to run the full navigation stack by launching the move_base node. This will create 2 costmaps, each with its own namespace: local_costmap and global_costmap. You may need to set some parameters twice, once for each costmap.

ROS API

The C++ API has changed as of Hydro.

Subscribed Topics

~<name>/footprint (geometry_msgs/Polygon)

Published Topics

~<name>/costmap (nav_msgs/OccupancyGrid) ~<name>/costmap_updates (map_msgs/OccupancyGridUpdate) ~<name>/voxel_grid (costmap_2d/VoxelGrid)

Parameters

Pre-Hydro Parameters

Hydro and later releases use plugins for all costmap_2d layers. If you don't provide a plugins parameter then the initialization code will assume that your configuration is pre-Hydro and will load a default set of plugins with default namespaces. Your parameters will be moved to the new namespaces automagically. The default namespaces are static_layer, obstacle_layer and inflation_layer. Some tutorials (and books) still refer to pre-Hydro parameters, so pay close attention. To be safe, be sure to provide a plugins parameter.

Plugins

~<name>/plugins (sequence, default: pre-Hydro behavior)

Coordinate frame and tf parameters

~<name>/global_frame (string, default: "/map")

~<name>/robot_base_frame (string, default: "base_link") ~<name>/transform_tolerance (double, default: 0.2)

Rate parameters

~<name>/update_frequency (double, default: 5.0)

~<name>/publish_frequency (double, default: 0.0)

Map management parameters

~<name>/rolling_window (bool, default: false)

~<name>/always_send_full_costmap (bool, default: false)

The following parameters can be overwritten by some layers, namely the static map layer.

Required tf Transforms

(value of global_frame parameter)(value of robot_base_frame parameter)

C++ API

For C++ level API documentation on the costmap_2d::Costmap2DROS class, please see the following page: Costmap2DROS C++ API

Layer Specifications

Static Map Layer

The static map layer represents a largely unchanging portion of the costmap, like those generated by SLAM.

Obstacle Map Layer

The obstacle layer tracks the obstacles as read by the sensor data. The ObstacleCostmapPlugin marks and raytraces obstacles in two dimensions, while the VoxelCostmapPlugin does so in three dimensions.

Inflation Layer

The inflation layer is an optimization that adds new values around lethal obstacles (i.e. inflates the obstacles) in order to make the costmap represent the configuration space of the robot.

Other Layers

Other layers can be implemented and used in the costmap via pluginlib. Any additional plugins are welcomed to be listed and linked to below.

Wiki: costmap_2d/layered (last edited 2018-03-28 16:04:02 by RomainReignier)