# inverse transform

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.

edit retag close merge delete

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

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

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.

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

Sort by ยป oldest newest most voted

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 http://wiki.ros.org/tf2_eigen and http://wiki.ros.org/tf2_bullet

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: http://docs.ros.org/en/noetic/api/tf2...

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.

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

Conclusion from the discussion:

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

more