# Gslam /tf coordinate problems

So I am using gmapping slam_gmapping base:=scan with rosstage and things are going nicely. (I am using rviz). There are two questions which I am sure are nooby, but I can't find the answers anywhere.

(I am putting the frames inside () because I am not sure how else to signify the difference)

1) The first problem is /tf (base_footprint) and /tf (base_link) and /tf (base_laser_link) all give me a believable value of 7.9, .83 (I let the robot move in a straight line for a little bit). However, if I am reading the gslam tutorial correctly, I should be using /tf (/map) for the transform in the map space. It is giving me the following values -0.004988, -0.01188 The size of the map is 4000,4000 and the resolution is .05. But I am not sure how to tranform these values into real world values.

2) I am hoping that the answer for the first question will answer the second one, but I am given an occupancy grid for a map that is 4000 X 4000 I need to be able to translate Slam coordinates (or real world coordinates) into this discrete space. Is this the same transfer function as the /tf(/map)?

Thank

~BM

edit retag close merge delete

If this reposted I am sorry, my web-browser did something stupid.
( 2011-04-23 15:10:20 -0500 )edit

Sort by » oldest newest most voted

Hello,

I'm not sure if I fully understand what you want to do. In a typical case, you should have a main robot frame, say base_link, that should represent your robot. The transformation map->base_link gives you the position of the robot (in meters) from the origin of the map.

This origin is fixed in the yaml file you use to initialize map_server (see section 2.2). It is a bit tricky, as the origin is in fact the bottom left pixel of the map picture.

To know how far your robot moved from its position of origin in the map, you need to store the first transform map->base_link and use it as your "zero".

Hope it helps

Raph

more

Okay /map (the occupancy grid) is starting in the middle of the map (2000,2000) of a 4k X 4k grid. That was the piece I was confused about, I should be able to use the resolution of the map and translate meter position into index offset for the occupancy grid. The only trick is I am going to have to translate back from the occupancy grid to the real world when I write my motion planner but I will cross that bridge when I get there.

Thanks for the help, BM

more

Sure, the relationship between meters/cells is quite easy to find. keep us posted on your progress! :)
( 2011-04-26 01:34:53 -0500 )edit

Why the sequence numbers are zero. I try to build an occupancy map of 4k*4k grid and resolution is .05. But the map generated is an empty map. All the laser messages are properly published and tf tree seems to be ok.And no transform from [/GrndTruth] to frame[/map] and no transform from [/base_GrndTruth to frame[/map]. You can view the question in details http://answers.ros.org/question/94671/error-in-creating-2d-global-map-of-the-environment/

( 2013-11-13 18:19:27 -0500 )edit

here is the echo dump of my /tf

transforms:

header:

seq: 0

stamp:

secs: 266

nsecs: 200000000

transform:

translation:

x: 0.05

y: 0.0

z: 0.15

rotation:
x: 0.0
y: 0.0
z: 0.0
w: 1.0


transforms:

header:

seq: 0

stamp:

secs: 266

nsecs: 200000000

frame_id: /base_footprint

transform:

translation:

x: 0.0

y: 0.0

z: 0.0

rotation:

x: 0.0

y: 0.0

z: 0.0

w: 1.0


transforms:

header:

seq: 0

stamp:

secs: 266

nsecs: 200000000

frame_id: /odom

child_frame_id: /base_footprint

transform:

translation:

x: 0.0

y: -0.0

z: 0.0

rotation:

x: 0.0

y: 0.0

z: 0.0

w: 1.0


transforms:

header:

seq: 0

stamp:

secs: 266

nsecs: 200000000

frame_id: /map

child_frame_id: /odom

transform:

translation:

x: -0.0

y: -0.0

z: -0.0

rotation:

x: 0.0

y: 0.0

z: 0.0

w: 1.0


transforms:

header:

seq: 0

stamp:

secs: 266

nsecs: 200000000

frame_id: /map

child_frame_id: /odom

transform:

translation:

x: -0.0

y: -0.0

z: -0.0

rotation:

x: 0.0

y: 0.0

z: 0.0

w: 1.0


aplogize for the format...I can never get these things to work.
The point is base_frame says its 0,0 which is believable. I just don't know how to transfer the base_frame into the occupancy grid coordinates. Sorry if I am missing something here.

Thanks again, BM

more

Okay I think I get that, thanks by the way. So the map is 4000 X 4000 occupancy ... I need to find the index where the robot is. So do I take the maps resolution and that is how I would find the array index for the robot? I think (thanks to your previous answer) I can get the relative coordinates which I need. But I don't know exactly how to transfer that into the occupancy grid space. For that matter I don't even know what indexes gslam starts making the map. (I would assume somewhere in the middle).

more