ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Checking whether a particular position in the map has any obstacle

asked 2016-01-28 00:01:04 -0500

mayank_m gravatar image

How to check whether a particular position in the map has any obstacle. I want to check if at any particular location (x,y) the corresponding cell has any obstacle or not. How to do that using costmap in ros ?

edit retag flag offensive close merge delete


did you find a solution for this?

aarontan gravatar image aarontan  ( 2018-07-05 15:25:39 -0500 )edit

Hello, have found a solution to this. i am searching for he same thing

samir menaa gravatar image samir menaa  ( 2020-06-03 06:56:11 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-01-28 01:29:44 -0500

mgruhler gravatar image

Depends on where you want to do the check, seperate node (probably subscriber), node that has the costmap as a member.

I guess it is straight forward if the costmap is member, than translate the coordinate to the relevant cell (e.g. using the worldToMap function), check the costs (e.g. using the getCost function) and then compare against the cost values).

Maybe there is a more direct way, but I don't know.

If it is a seperate node where you subscribe to, the way should be the same...

edit flag offensive delete link more


Thank You....what if we need to take the footprint of the robot into account, i.e., not to consider the robot as a point object ?

mayank_m gravatar image mayank_m  ( 2016-01-28 02:55:55 -0500 )edit

This is what the costs are for. So you need to use the inflation_layer which gets inflated depending on the robot footprint. There are costs for "definitely in collision" and "maybe in collision", as they use the inscribed and curcumscribed radius, repsecitvely.

mgruhler gravatar image mgruhler  ( 2016-01-28 03:32:28 -0500 )edit

Check out for more information on the cost calculation and how the footprints are used.

mgruhler gravatar image mgruhler  ( 2016-01-28 03:32:50 -0500 )edit

Do I need to create another costmap object exactly similar to what is already running in the nav stack, and then add my custom function? Or, is there a simpler way to instantiate a costmap object with the latest costmap information (including current information from all the layers)?

Omair Khalid gravatar image Omair Khalid  ( 2021-06-14 04:41:47 -0500 )edit

@Omair Khalid did you find the solution ?

N.N.Huy gravatar image N.N.Huy  ( 2022-01-04 04:45:31 -0500 )edit

Question Tools

1 follower


Asked: 2016-01-28 00:01:04 -0500

Seen: 1,813 times

Last updated: Jan 28 '16