0
$\begingroup$

Rosanswers logo

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 ?

Originally posted by stevemartin on ROS Answers with karma: 361 on 2018-10-18

Post score: 3

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.

With that in mind, to answer your questions :

  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.

Originally posted by Delb with karma: 3907 on 2018-10-18

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by stevemartin on 2018-10-18:
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)?

Comment by Delb on 2018-10-18:
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).

Comment by stevemartin on 2018-10-18:
@Delb, okay thank you for the detailed answer, now I understood. So the origin reads from the odom.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.