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

What is setCreateTimerInterface in the TF2 library for?

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

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>(
    rclcpp_node_->get_node_base_interface(),
    rclcpp_node_->get_node_timers_interface());
tf_buffer_->setCreateTimerInterface(timer_interface);

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
0

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

tfoote gravatar image

You can see where it's useful slightly above:

https://github.com/ros2/geometry2/blo...

or https://docs.ros2.org/foxy/api/tf2_ro...

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

Comments

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 -0600 )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 -0600 )edit

Question Tools

2 followers

Stats

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

Seen: 518 times

Last updated: Feb 23 '21