Conversion from cell grid to map point
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!
Asked by ophir on 2019-01-09 15:23:02 UTC
Answers
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.
Asked by juanlu on 2019-01-10 03:50:02 UTC
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?
Asked by ophir on 2019-01-10 09:34:54 UTC
Comments