ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

# Where is the origin of a map made by gmapping?

When I construct a 2d map using laser gmapping, how can I be sure where the origin is? For example, before starting gmapping, if I go in gazebo simulation to the desired center in my environment and then start gmapping:

1. Will that be considered as the origin?
2. If yes, then if I go left by 1 meter, does it mean that now I moved x=-1 y=0 z=0?
3. So with my resolution of 0.5, do I need to translate to ROS by saying : x= (-1 * 0.5), y = 0, z=0 ?
edit retag close merge delete

Sort by » oldest newest most voted

If you are talking about the orign as the coordinates (0;0) then the origin is set to the position of the robot at the beginning of your simulation (you can verify that by looking at the position of the frame map and odom). Also, if you look at the information of mapmetadata there is an attribute origin that is always on the bottom right corner of the map but it's not a frame, it's just the origin (not (0;0) but the pose of the first cell of the occupancygrid) of the map created accordingly to have your robot centered at the beginning.

1. No, when you launch gmapping it creates the frame map. gmapping can locate the robot according to sensors data and odometry so the frame is created at the same pose as the frame odom. So your origin when you launch gmapping is odom.
2. You have misunderstood the axis in ROS, you can look at the REP103. The x axis is for the movements forward/backwards. So if you move by 1 meter to the left you are at (0;1;0) (if you were at (0;0;0)).
3. No, the resolution sets the size of the cells of the occupancygrid. So if you have a resolution of 0.01 it means your map will be created with cells of side 1cm. (e.g. if you have a map of 10 meters by 10 meters with that resolution you would have 10⁶ cells in the map : calculated with the formula map_width/resolution * map_length/resolution). But that doesn't means that all the coordinates are rounded to the resolution, the coordinates depends of the movement of base_link accroding to odom (thanks to the tf) and cells with simply keep a value if there is an obstacle or not (and if it's unknown). So you simply have to tell ROS the coordinates you want.
more

So for the 1), does it mean that at the start of the gmapping, the coordinate system of map will start at (0;0;0)?

( 2018-10-18 02:04:23 -0500 )edit

Yes but if you move the robot before creating the map frame (i.e. launching gmapping) then its first pose according to map won't be (0;0;0).

( 2018-10-18 02:14:56 -0500 )edit

@Delb, okay thank you for the detailed answer, now I understood. So the origin reads from the odom.

( 2018-10-18 02:29:27 -0500 )edit