ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

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

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

Will Chamberlain gravatar image

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

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

The Using Python tf tutorial and the Indigo Python API give

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

and

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 https://github.com/ros/geometry/tree/...

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

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

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

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

Comments

thx!!! I'm looking lookupTransform implementation for a lot of time. Do you know where is lookupTransform c++ implementation?

sebasan gravatar image sebasan  ( 2021-06-23 19:15:17 -0500 )edit

@sebasan is this what you're looking for? https://github.com/ros/geometry/blob/...

jarvisschultz gravatar image jarvisschultz  ( 2021-06-24 21:12:09 -0500 )edit

@jarvisschultz no, isn't. I'm looking for equation implementation in lookupTransforfunction. I read about this function that interpolate between the two nearest frames (in time sense) and isn't a simple frame translation + rotation. Please check [this paper] (http://ros.fei.edu.br/roswiki/attachm... (2f) TePRA2013_Foote / TePRA2013_Foote.pdf) in C. Transform Listening section. Is not clear to me, whats is the real implementation. I cant'n make a code with the same behavior.

I have /odo to /base_link transform, and /map to /odo of gmapping node. If I compute:

T_base_link=T_odo+T_map

is different than:

T_base_link_lt obtenied from lookupTransform(/map,/base_link, now)

I sorry for my english. I hope had been clear.

sebasan gravatar image sebasan  ( 2021-06-25 18:40:50 -0500 )edit

@sebasan Sounds to me like maybe your particular question would be best asked as a new question.

jarvisschultz gravatar image jarvisschultz  ( 2021-06-27 16:09:20 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2017-03-07 05:56:20 -0500

Seen: 4,625 times

Last updated: Mar 07 '17