Ask Your Question
2

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

Comments

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
1

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 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...

edit flag offensive delete link more

Comments

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
0

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

3 followers

Stats

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

Seen: 77 times

Last updated: Aug 25