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

Conversion from cell grid to map point

asked 2019-01-09 14:23:02 -0600

ophir gravatar image

Hi, I'm working on a navigation service and I saw here that the right way to convert from map point to grid cell is: cellx = floor((mapx - originx) / resolution) But I'm having a hard time understanding how should I implement the reverse conversion (from grid to map), because it is not one to one (one grid cell includes many map points). can you please help? Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2019-01-10 02:50:02 -0600

juanlu gravatar image

updated 2019-01-10 02:53:48 -0600

This will get you the center of the grid cell with "map" being a nav_msgs/OccupancyGrid:

map_x_coordinate_in_meters = (gridcell_x_coordinate * map.info.resolution) +
                             map.info.origin.position.x + 
                             map.info.resolution / 2;
map_y_coordinate_in_meters = (gridcell_y_coordinate * map.info.resolution) +
                             map.info.origin.position.y +
                             map.info.resolution/ 2;

You are correct, a grid contains a lot of "map points" and that information was lost when codifying in a lower resolution (the grid) so you can only choose where the output map point is.

edit flag offensive delete link more

Comments

Are you taking into account that my map origin point is the bottom left point, while my occupancy grid 2D array starts from top left?

ophir gravatar image ophir  ( 2019-01-10 08:34:54 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2019-01-09 14:23:02 -0600

Seen: 682 times

Last updated: Jan 10 '19