Ask Your Question

does tf.TransformListener.lookupTransform return quaternion & position, or translation and rotation?

asked 2017-03-07 05:56:20 -0600

Will Chamberlain gravatar image

updated 2017-03-07 05:57:06 -0600

Does tf.TransformListener.lookupTransform return quaternion & position, or translation and rotation?

The Using Python tf tutorial and the Indigo Python API give

position, quaternion ="/base_link", "/map", rospy.Time())


lookupTransform(target_frame, source_frame, time) -> (position, quaternion)

, but the Writing a tf listener (Python)) tutorial gives

(trans,rot) = listener.lookupTransform('/turtle2', '/turtle1', rospy.Time())

Is there a change between Indigo and Jade or Kinetic from (quat,pos) to (trans,rot)?
Also - where is the source code; can't find it in

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-03-07 08:32:19 -0600

updated 2017-03-07 08:35:58 -0600

All examples you posted are saying the same thing it's just in the first two they use the position variable to store the translational part of the transform and quaternion to store the rotational part of the transform (which is indeed expressed as a quaternion). In the third example they instead use trans and rot for variable names, but the meaning of the data is unchanged. The function is always returning two arguments --- the first is a 3-length tuple of double values representing the x-y-z translation, and the second is a 4-length tuple of doubles representing the rotation as a quaternion (x-y-z-w).

There is official API documentation of tf in Python here. You might also want to look into the tf2 tutorials, specifically the Python listener tutorial. Under the hood, the tf functions now use tf2, and you could be using it directly. During the migration from tf to tf2 there were many behind-the-scenes changes, but I'm unaware of any API changes to tf.

You may have had trouble finding the source code because the Python TransformerROS class inherits from a C++ class compiled with Python.h. In other words, the Python API lookupTransform function is actually located in the pytf.cpp C++ code.

edit flag offensive delete link more

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: 2017-03-07 05:56:20 -0600

Seen: 3,037 times

Last updated: Mar 07 '17