Ask Your Question

inverse transform

asked 2021-08-18 09:32:10 -0600

gbohus gravatar image

Hi all,

Given two coordinate frames, A and B, I need to use both transforms that go between them for a given timestamp. (These two are obviously inverses of each other.) I could obviously do a lookupTransform for both separately, but that feels suboptimal.

I have been stumbling around geometric_msgs::Transform, tf2::Transform, stamped versions etc, but its a bit of a mess.

Any advice would be appreciated.

edit retag flag offensive close merge delete


Your question is not very clear. Are the coordinate frames static? Why is using tf2 Transform sub-optimal?

kscottz gravatar image kscottz  ( 2021-08-20 13:41:48 -0600 )edit

Yeah, sorry about that.

It's dynamic, otherwise I wouldn't worry about efficiency.

I _think_ that lookupTransform has to do some interpolation on time and perhaps not a trivial one, hence my feeling that it is not fast. (But I might be wrong.) I thought a taking simple inverse of such a small matrix would be quicker. (Which I guess I can also write myself, but I expected to be part of tf/tf2.)

I hope this makes sense.

gbohus gravatar image gbohus  ( 2021-08-22 03:05:11 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2021-08-23 14:18:57 -0600

tfoote gravatar image

In general messages do not have methods on them. It's recommended if you want to do operations on the objects to use a linear math library like bullet or eigen. You'll find that there are packages which provide automatic conversions such at and

The geometry_msgs datatypes also don't provide the operations on objects so if you're going to apply the transform you need to convert it anyway.

As an aside I would also caution against premature optimization. If you're truely using the exact same transform at the exact same time and it will never change the inverse transform is truely correct. However if you're potentially dealing with different timestamps or different frames it may be worth keeping the generality of just looking up the coordinate frames. It's not a very expensive query. Also you can greatly simplify your interface by directly applying the .transform(...)family of methods instead of computing the transform and then manually applying it:

edit flag offensive delete link more


Thanks @tfoote. I am using the exact same timestamp, but it's true, as @kscottz and you both implied, there should not be a major difference in efficiency between asking for both transforms or asking for one and inverting it.

gbohus gravatar image gbohus  ( 2021-08-25 09:52:42 -0600 )edit

answered 2021-08-25 09:53:35 -0600

gbohus gravatar image

Conclusion from the discussion:

There seems to be no such thing, but it would not be very useful anyway.

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: 2021-08-18 09:32:10 -0600

Seen: 77 times

Last updated: Aug 25