0
$\begingroup$

Rosanswers logo

Dear all,

I would like to put in place a callback each time a new value of a given source frame in a given target frame is available.

You can do this with a listener (waitForTransform() + lookupTransforms()) but I find this is a rather dirty solution. So what I would like to do is use something like a tf::MessageFilter. The problem is tf::MessageFilter does not work for tf2_msgs::TFMessage (the message type for topic /tf).

  1. Any idea of the best practise to do that?
  2. Also, why isn't this the default solution to work with transforms? This is what most people most likely want to do, no?

Thanks,

Antoine.


Originally posted by arennuit on ROS Answers with karma: 955 on 2014-08-14

Post score: 1


Original comments

Comment by NEngelhard on 2014-08-14:
"This is what most people most likely want to do, no?" I'm not sure about that. Some of my tf-sending nodes do that with a frequency of a kHz, but i just need the position maybe once every 20secs when I need the position of a camera. And even in this case, I only need the interpolated position.

Comment by arennuit on 2014-08-14:
@FooBar: Obviously I did not mean everyone had to use the above mentioned method ;) In some situations (like yours) it is clearly not relevant ;)

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I'm pretty sure tf and tf2 do not have methods to do this.

I think the proper way to go about this would be to subscribe directly to the /tf topic and parse it yourself in an appropriate way. I suspect the Buffer classes in tf2 can provide some useful methods for this. You should study the tf2 and tf2_ros APIs carefully.

The trouble with trying to make a generic implementation of a transform callback is that the semantics are not well-defined when there are multiple links between the parent and child frames that are published by different sources at different times.


Originally posted by ahendrix with karma: 47576 on 2014-08-14

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by arennuit on 2014-08-14:
@ahendrix: does that mean that the most widespread use case for tf is using it via a timer (with a period independent from the update rates of the different sources) or with tf::MessageFilter (but on stamped data - unlike tf)?

Comment by ahendrix on 2014-08-14:
The most common use cases I've seen use tf with stamped data; either looking up transforms directly, or via a tf::MessageFilter

Comment by arennuit on 2014-08-14:
Knowing this will help understand best practises (which is where I am at currently). Thanks for your help!

Comment by lalten on 2018-05-14:
@ahendrix: In 2018, is directly subscribing to /tf still the proper way to receive a callback as soon as a specific transform is available?

Comment by kylerlaird on 2018-06-06:
I use the transforms that my INS produces in order to calculate guidance commands. I want updates quickly and efficiently. I ended up subscribing to /tf and checking the transform's child_frame_id. It would be handy to be able to subscribe to changes in specific transforms (like /world to /ins).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.