Ask Your Question

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

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 * +
                    / 2;
map_y_coordinate_in_meters = (gridcell_y_coordinate * +

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


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

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-01-09 14:23:02 -0600

Seen: 369 times

Last updated: Jan 10 '19