Ask Your Question

Getting odom transform same as RVIZ (Python)

asked 2019-01-31 21:37:53 -0600

JAWDAY gravatar image

Hi, I'm trying to get the XYZ position of the odom frame. In particular I just want the xy position, not fussed about height change (z). As you can see in the picture, only one of the values is close, the others are quite off.

image description

The code I'm using to get the XYZ seen in the console (only relevant lines):

tf_listener = tf.TransformListener()
    (trans, rot) = tf_listener.lookupTransform('/imu_link', '/odom', rospy.Time(0))
except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException):

Also RVIZ Global Fixed Frame was set to Velodyne (Using a Husky with Velodyne sensor).

I'm sure it can't be too difficult but if anyone could show me ow to exactly get the odom-position information that RVIZ is showing, that'd be great

Using Ubuntu 16.04, Kinetic.

edit retag flag offensive close merge delete


All right, could you, please, send us the rqt_graph screenshot of your application? This to see if what are the available transformations and "who" is providing the odom transform.

matheusns gravatar image matheusns  ( 2019-01-31 21:45:42 -0600 )edit

Here is the rqt_graph screenshot, and also output of rosrun tf view_frameshere.

JAWDAY gravatar image JAWDAY  ( 2019-01-31 21:54:50 -0600 )edit

Not 100% sure, but I guess rviz is showing the positions w.r.t. the fixed_frame. Thus, if you want to have the same transforms, maybe try to change the fixed_frame to imu_link to check if the positions then match.

mgruhler gravatar image mgruhler  ( 2019-02-01 01:02:23 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-02-01 03:21:52 -0600

@mgruhler is correct, the values your seeing in RVIZ are the location of the odom frame with respect to the current fixed frame in RVIZ. There is no such thing as an absolute position in the TF system, locations are only described relative to each other, so when you say you want to know the XY position of odom it's important to know what frame you need to know that position in.

For example if you want to know the location of odom in the world frame then you would look up the odom->world transform. This is slightly non-intuitive, because the TF systems returns the transformation between points in the child to parent frame, NOT the pose of the child frame in the parent frame. These two are actually the inverse of each other.

Hope this makes sense.

edit flag offensive delete link more


Awesome, I changed the fixed frame in RVIZ to be imu_link and they returned the same values. Strange, could have sworn I had tried it. Subsequently my code seems to be running as expected now. Thanks all

JAWDAY gravatar image JAWDAY  ( 2019-02-01 03:50:32 -0600 )edit

glad you got it fixed.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-02-01 05:22:15 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-01-31 21:37:53 -0600

Seen: 271 times

Last updated: Feb 01 '19