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

Confusing tf transforms

asked 2016-03-18 05:59:22 -0500

Mehdi. gravatar image

I have been working a lot with transform matrices these days and the tf nomenclature doesn't make things easier. For tf_echo, the input frames are defined as such:

tf_echo <source_frame> <target_frame>

When using Python and looking up for a transform it is as follows:

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

But what I get are two inverse transforms even though I use the same source_frame and target_frame. Why is that?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2016-03-18 09:27:28 -0500

thebyohazard gravatar image

updated 2016-03-18 09:58:24 -0500

Agreed. This was quite confusing to me also. This has been asked before, but it was hard for me to find the previous question and your question's title is much more likely to be found in future searches methinks.

to Quote tully,

The lookup API is named with respect to transforming data from the source frame into the target frame.

When referring to transform between coordinate frames (transforming the frames, it is the inverse of the transform of data between the two frames)

Depending on the documentation if you're referring to the transform value for the data, or the transform value of the coordinate frames you get the inverse value.

edit flag offensive delete link more


Ah, I see what he is saying. Transform can be a verb and a noun - you transform the data using a transform, err confusing. Oh well, it's not a big problem, we just gotta be careful and make sure to test in simulation first!

Airuno2L gravatar image Airuno2L  ( 2016-03-18 10:59:08 -0500 )edit

answered 2018-02-03 17:40:16 -0500

malharjajoo gravatar image

updated 2018-02-03 18:16:31 -0500

I think what is missing here is a concrete math proof.

I came across this on the coursera website, see this link. Watch from 10:40 till the end.

Read this after watching the above video once -

The video explains how to get source datapoint using the Rotation Matrix. The opposite ( by taking a simple transpose of Rotation matrix ) is true for getting the target data point in the source frame, you have to use the inverse of the Rotation matrix ( Rotation required to convert source to target basis vectors )

Hence it also explains ( taken from the above answer by @tbh )

"When referring to transform between coordinate frames (transforming the frames, it is the inverse of the transform of data between the two frames)"

edit flag offensive delete link more

answered 2016-03-18 07:27:56 -0500

Airuno2L gravatar image

updated 2016-03-18 07:46:53 -0500

Hmm, that is weird. Looking at the python documentation it looks like you're correct:

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

Then, looking at the cpp documentation, the order is the same:

void Transformer::lookupTransform  ( const std::string &  target_frame,  
                                     const std::string &  source_frame,  
                                     const ros::Time &  time,  
                                     StampedTransform &  transform  
                                     )  const 

Get the transform between two frames by frame ID. 
target_frame The frame to which data should be transformed  
source_frame The frame where the data originated  
time The time at which the value of the transform is desired. (0 will get the latest)  
transform The transform reference to fill.

I read that to mean it returns the source_frame described with respect to the target_frame.

But for some reason, the code for the tf_echo tool has this:, target_frameid, ros::Time(), echo_transform);

So it looks like that will definitely provide the inverse of what your python function is providing.

And the documentation for the tf_echo tool says:

tf_echo <source_frame> <target_frame>- Print information about a particular transformation between a source_frame and a target_frame. For example, to echo the transform between /map and /odom: rosrun tf tf_echo /map /odom

This is worded vaguely, the word "between" doesn't indicate direction. If this is the way tf_echo is suppose to work, it should really say something like "this prints the target_frame described with respect to the source_frame". I wonder if this is an error. At a minimum the description should be made more clear.

edit flag offensive delete link more


rosrun tf tf_echo frame_A frame_B delivers the same transform as tf.lookupTransform(frame_A, frame_B) which is really confusing !! I need these transform matrices in order to transfrom back and forth between laser frame and base_link frame.

Mehdi. gravatar image Mehdi.  ( 2016-03-18 07:50:11 -0500 )edit

Wait, I thought you said those two were giving you inverses of each other? Now I'm even more confused haha. The easy work around is to just pick one way and try it, then flip it if you're getting something wrong.

Airuno2L gravatar image Airuno2L  ( 2016-03-18 08:00:37 -0500 )edit

I mean I was putting source_frame in the expected source frame (first parameter for tf echo, second parameter for lookuptransform) and the target_frame also in its expected location, following the documentation. And the resulting transforms do not make sense, unless tf_echo is made to give

Mehdi. gravatar image Mehdi.  ( 2016-03-18 08:02:04 -0500 )edit

the transform FROM target TO source

Mehdi. gravatar image Mehdi.  ( 2016-03-18 08:02:16 -0500 )edit

Question Tools



Asked: 2016-03-18 05:59:22 -0500

Seen: 2,619 times

Last updated: Feb 03 '18