Ask Your Question

Calculating velocity from tf

asked 2012-02-04 23:41:08 -0600

jwrobbo gravatar image

updated 2014-01-28 17:11:16 -0600

ngrennan gravatar image

When listening to transforms on tf, is there a way to ask specifically for the one before the latest one? And when you have received a transform, how do you query it for its timestamp?

I have position information being intermittently broadcast onto tf. Because I don't know exactly when this is going to happen I can't ask for a transform with a specific time delay. I would like to ask for the latest two transforms, find the time delay between them and divide by this to give an estimate of velocity.

Any help would be much appreciated!


edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2012-02-06 11:37:37 -0600

tfoote gravatar image

updated 2012-02-06 11:41:22 -0600

As @dlaz mentioned you want to use Transformer::lookupTwist()

If you use a target_time of zero it will give you the latest reading. And if you set a very small averaging_interval to a very small value(less than the minimum time between your tf updates) it will effectively do what you want. This will cause the target time to be the last update. And it will use linear interpolation between the last two updates to compute the other endpoint of the interval.

Note: This will be very noisy data! You are doing discreet differentiation over small time samples, the result will be very biased by noise in the tf positions.

edit flag offensive delete link more

answered 2012-02-05 02:59:41 -0600

updated 2012-02-05 03:03:17 -0600

The standard way to get velocities from TF is with Transformer::lookupTwist(), which will return velocity as a geometry_msgs/Twist. I'm not sure how that will work with your intermittent TF broadcasting though.

edit flag offensive delete link more

answered 2018-02-12 17:30:57 -0600

constructiverealities gravatar image

updated 2018-02-12 17:52:15 -0600

@tfoote So this is a bit older, but I'm running into an Issue with TF2 in that I can't find a substitute function for TFs lookupTwist. Was this dropped from TF2? if so, Oops. It's really useful.

Any tips on how to calculate it myself? I've create a related question here.

edit flag offensive delete link more



Please don't use an answer to ask a question. This isn't a forum. Please create a new question and reference this question.

jayess gravatar imagejayess ( 2018-02-12 17:49:33 -0600 )edit

^ I edited to link to the related question

constructiverealities gravatar imageconstructiverealities ( 2018-02-12 17:53:04 -0600 )edit

This still doesn't align with the Q&A format that we have here. Please delete this answer and you can leave a comment (on your question) referencing this one.

jayess gravatar imagejayess ( 2018-02-12 18:22:37 -0600 )edit

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: 2012-02-04 23:41:08 -0600

Seen: 2,642 times

Last updated: Feb 12 '18