Rosanswers logo


This might be a newbie question but i need a help with it or at least to be pointed in the right direction. I need to extract/acquire the (x, y) coordinates of a given map's (grid) cells to be used in a path planning program.

  • like in the RVIZ that you click somewhere on the map and it prints out the coordinates of that specific location. what i need to achieve is to acquire all of available "unoccupied" cells coordinates of a given map for my Node to calculate a STC path for the robot to travel.

How can i achieve this goal through a ROS node?

Does the (x, y) map coordinates system follow a certain rule? for example (0, 0) is always at a specific corner or there is a system for row and column numbering, etc.

Thank you!

Originally posted by sobot on ROS Answers with karma: 116 on 2015-04-26

Post score: 2


1 Answer 1


Rosanswers logo


Please have a look into yaml of map you are using.

using origin and resolution you can find position of each cell.

origin : The 2-D pose of the lower-left pixel in the map, as (x, y, yaw), with yaw as counterclockwise rotation (yaw=0 means no rotation). Many parts of the system currently ignore yaw.

resolution : Resolution of the map, meters / pixel


Occupancy Grid msg member data is having

Occupancy probabilities are in the range [0,100]. Unknown is -1.

Use free_thresh param to get Unoccupied cells (i.e free cells).

free_thresh : Pixels with occupancy probability less than this threshold are considered completely free.

if free_thresh: 0.196 then all cells with occupancy lessthan 19.6 (and not -1 ) are free .

Originally posted by bvbdort with karma: 3034 on 2015-04-26

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by sobot on 2015-04-26:
Thanks so much! This answers the second part of my question. a little twist though, what if its not a static map (would local_costmap_params.yaml serve the same purpose?) Any idea about the first part of the problem (extracting unoccupied grid coordinates) through use of cpp codes?

Comment by bvbdort on 2015-04-26:
check update, yes if map is not static you have to use cost map but you need good localization.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.