Ask Your Question

What Range of Costs Does ROS Navigation Support?

asked 2019-10-16 15:56:59 -0500

cmcheung gravatar image

I'm looking to make custom costmap2d layer, where each cell in the occupancy grid would be a range of values rather than a binary OBSTACLE/NO OBSTACLE. For instance, if the robot was trapped between cells with cost 20, and cells with cost 50, it would opt to travel over the lower cost area (20 in this case).

While I know that the occupancy grid can technically take a range of values from [0,100], the costmap2d page on ROS wiki seems to indicate what I want to do is not possible:

Occupied, Free, and Unknown Space While each cell in the costmap can have one of 255 different cost values (see the inflation section), the underlying structure that it uses is capable of representing only three. Specifically, each cell in this structure can be either free, occupied, or unknown. Each status has a special cost value assigned to it upon projection into the costmap. Columns that have a certain number of occupied cells (see mark_threshold parameter) are assigned a costmap_2d::LETHAL_OBSTACLE cost, columns that have a certain number of unknown cells (see unknown_threshold parameter) are assigned a costmap_2d::NO_INFORMATION cost, and other columns are assigned a costmap_2d::FREE_SPACE cost.

Based on my reading of that, the costmap points essentially only has three states it can be in (Occupied, Free, or Unknown), and I can't assign an actual cost to bias the robot to go certain directions.

Is my reading of "only three states" correct? The original layered costmap paper from David Lu ( seems to indicate that there is a concept of adding non-lethal costs, and variable costs overall, but the wiki entry seems to contradict that.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-10-20 18:06:53 -0500

fergs gravatar image

The underlying Costmap2d (and associated layers) actually work on 8-bit values. if you look closely at the inflation layer, you'll see it sets a wide range of values - since you want to have a decreasing cost the farther away from an obstacle you are - so what you want to do is definitely possible.

The piece of text talking about only 3 levels, I think might actually refer specifically to the VoxelLayer - which does do some funky packing of the data in order to represent each vertical column of voxels in a single 32-bit word. I'm thinking that the documentation has been somewhat incorrectly refactored over time (the whole layer thing was added years after the original Costmap_2d was created).

edit flag offensive delete link more


Thanks for the info!

cmcheung gravatar image cmcheung  ( 2019-10-25 09:35:36 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-10-16 15:56:59 -0500

Seen: 318 times

Last updated: Oct 20 '19