Rosanswers logo

I am looking for the create_timer function in ros2 but I only find the rclcpp::Node::create_wall_timer.

From my understanding there should be some abstract create_timer function (instead of wall timer) to work optionally with the simulated time. Where is this function?

If that function is not there in ros2, what would be the solution to have some abstract timer that adapts to the wall or to the simulated time?

Originally posted by Pablo Iñigo Blasco on ROS Answers with karma: 2982 on 2020-09-28

Post score: 1


1 Answer 1


Rosanswers logo

There is an rclcpp::create_timer() free function

The trick to a timer that uses simulated time is to pass a clock that uses simulated time to the rclcpp::create_timer() function. The default clock on a node is a ROS clock - meaning it will use simulated time if simulated time is active.

You might also be interested in

Originally posted by sloretz with karma: 3061 on 2020-09-29

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by Pablo Iñigo Blasco on 2020-09-30:
Correct. Thank you. Does anyone know why create_timer is a free function? and Node::create_wall_timer is a member function?

Comment by sloretz on 2020-09-30:
The free function has an advantage in that the same code can be used with both LifecycleNode and Node. There's some talk of making all functions free functions in https://github.com/ros2/rclcpp/issues/1259


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.