ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A

Absolute timers in ROS2

Is it possible to have absolute timers in ROS2? For example if the period is 60sec, I need the timer to trigger when the system clock reads “xx:xx:00”, i.e., on the full minute.

I tried to dig through the source behind rclcpp::Node::create_wall_timer but could not find an answer.

If that is not possible, I would build my own using timerfd_create() and TFD_TIMER_ABSTIME. Any tips on how to integrate that properly with ROS2?

The current implementation of timers in ROS (1 and 2) doesn’t support this feature. Imo this seems to be very specific and I think it is reasonable to implement that on top of the existing API.

You should be able to create a ROS package (or maybe multiple: one for C one for C++?) which provides this additional API. Your API would use “normal” ROS timers and in the first interval adjust the duration to happen at the full minute. Any following timer will then be with a fixed duration.