ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It looks like you're creating the transform publisher and then immediately trying to use it. The trouble with this is that, ROS subscribers take some time to subscribe to a topic after a new publisher comes online, and usually miss the first message on a topic - your delay is compensating for this a bit.

The other problem you're having is that you're only publishing once, and then destrying the publisher when you're done - any nodes that aren't running and subscribed to tf when you publish won't receive the transform.

You've also ignoring the time component of the transforms - tf is designed to handle time-varying transformations, and all frames should be published continuously in order to keep them up to date.

The more standard way to use tf is to set up a persistent tf publisher object, either as a class member variable or a global variable, and then publish transforms at a fixed rate - usually between 10 and 100Hz.

There are a couple of ways you could hide these complexities from your students:

  • Provide a wrapper object which has a publish method and contains a thread which continuously republishes the transform.
  • If you're not publishing moving frames, you could move to tf2 and use the static transform broadcaster. you'll still have to keep the publisher around, but you won't have to publish to it continuously.
  • Have your students use the tf::TransformBoadcaster directly, and provide a helper method to convert from Eigen matrices to tf::Transform objects.