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

What is setCreateTimerInterface in the TF2 library for?

asked 2021-02-23 21:13:39 -0500

M@t gravatar image

I'm currently working on setting up a TransformListener in ROS2, using the TF2 API. I notice that when creating the TF buffer object, existing ROS2 libraries that use this library also call the setCreateTimerInterface function.

This is the typical code used:

tf_buffer_ = std::make_shared<tf2_ros::Buffer>(rclcpp_node_->get_clock());
auto timer_interface = std::make_shared<tf2_ros::CreateTimerROS>(

And here are two examples of this in use:

However the ROS2 Foxy API doesn't describe this function at all (see bottom of this page), if it is necessary, or why the TF2 buffer needs this in ROS2 when it wasn't present in ROS1. It's also not explained on the ROS2 TF2 tutorial page.

Is someone with better knowledge of this source code able to explain what the timer interface is for and how it works?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-02-23 21:37:41 -0500

tfoote gravatar image

You can see where it's useful slightly above:


This timer interface allows the buffer to register for regular callbacks from the node to test for the availability of the transform. This allows the buffer to fulfill it's asynchronous query without requiring starting its own thread(s).

edit flag offensive delete link more


Ah I see. The Rviz node also shows an option for setting the buffer to use it's own dedicated thread. Does setting this to true simply make the transform lookup faster?

M@t gravatar image M@t  ( 2021-02-24 21:23:46 -0500 )edit

No that's independently spinning a thread to subscribe to incoming topics which does not cross over to the timer interface.

tfoote gravatar image tfoote  ( 2021-02-25 16:05:29 -0500 )edit

Question Tools



Asked: 2021-02-23 21:13:39 -0500

Seen: 413 times

Last updated: Feb 23 '21