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

Revision history [back]

In the trivial case where the origin of /map and your grid 0,0 are the same and there is no rotation between the two, you need a pixel to real world units (meters) scale factor. OccupancyGrid has resolution in meters/cell. So pose.x / resolution = cell_x. In your example the x is negative so the cell coordinate is not in your map at all, you probably want the the center of the map at 2000,2000 to be where the /map origin is, so pose.x / resolution + 2000 = cell_x.

You should look at using nav_msgs/OccupancyGrid which has the 2d array as well as the additional information ( http://docs.ros.org/indigo/api/nav_msgs/html/msg/MapMetaData.html ) required to transform from frame_id coordinates into pixel locations. http://wiki.ros.org/occupancy_grid_utils looks like it would be useful but hasn't been getting maintained. Also look at http://wiki.ros.org/costmap_2d.

I've uploaded your image because external links are unreliable over time (I assume you don't have the minimum points to upload images? Also github is giving me unicorn error messages right now so I can't see the robot publisher code...)

image description

In the trivial case where the origin of /map and your grid 0,0 are the same and there is no rotation between the two, you need a pixel to real world units (meters) scale factor. OccupancyGrid has resolution in meters/cell. So pose.x / resolution = cell_x. In your example the x is negative so the cell coordinate is not in your map at all, you probably want the the center of the map grid at 2000,2000 to be where the /map origin is, so pose.x / resolution + 2000 = cell_x.

You should look at using nav_msgs/OccupancyGrid which has the 2d array as well as the additional information ( http://docs.ros.org/indigo/api/nav_msgs/html/msg/MapMetaData.html ) required to transform from frame_id coordinates into pixel locations. http://wiki.ros.org/occupancy_grid_utils looks like it would be useful but hasn't been getting maintained. Also look at http://wiki.ros.org/costmap_2d.

I've uploaded your image because external links are unreliable over time (I assume you don't have the minimum points to upload images? Also github is giving me unicorn error messages right now so I can't see the robot publisher code...)

image description