Ask Your Question
1

Callback on transform available

asked 2014-08-14 00:59:28 -0500

arennuit gravatar image

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.

edit retag flag offensive close merge delete

Comments

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

NEngelhard gravatar imageNEngelhard ( 2014-08-14 02:20:18 -0500 )edit

@FooBar: Obviously I did not mean everyone had to use the above mentioned method ;) In some situations (like yours) it is clearly not relevant ;)

arennuit gravatar imagearennuit ( 2014-08-14 02:42:13 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2014-08-14 03:52:58 -0500

ahendrix gravatar image

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.

edit flag offensive delete link more

Comments

@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)?

arennuit gravatar imagearennuit ( 2014-08-14 04:20:43 -0500 )edit
1

The most common use cases I've seen use tf with stamped data; either looking up transforms directly, or via a tf::MessageFilter

ahendrix gravatar imageahendrix ( 2014-08-14 04:28:13 -0500 )edit

Knowing this will help understand best practises (which is where I am at currently). Thanks for your help!

arennuit gravatar imagearennuit ( 2014-08-14 04:46:44 -0500 )edit

@ahendrix: In 2018, is directly subscribing to /tf still the proper way to receive a callback as soon as a specific transform is available?

lalten gravatar imagelalten ( 2018-05-14 05:13:05 -0500 )edit

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

kylerlaird gravatar imagekylerlaird ( 2018-06-06 07:23:05 -0500 )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

1 follower

Stats

Asked: 2014-08-14 00:59:28 -0500

Seen: 529 times

Last updated: Aug 14 '14