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

How can I create a timer in ros2?

asked 2022-11-10 08:06:38 -0500

Ima gravatar image

Hi, I want to publish ROS messages with a non-periodic frequency. I see that rclcpp::create_wall_timer() uses a constant period for calling the callback function, which is not what I want. Is there a way to do this? Thanks in advance!

edit retag flag offensive close merge delete


Why would you do that? Can you please explain your use case in the question?

ravijoshi gravatar image ravijoshi  ( 2022-11-11 03:27:37 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2022-11-11 14:10:54 -0500

duck-development gravatar image

Every time when you call


A message is published.

You could write a while true loop with thead sleep to get you a periodic behavior.

edit flag offensive delete link more


Thanks for the reply!

Ima gravatar image Ima  ( 2022-11-18 03:42:51 -0500 )edit

Question Tools



Asked: 2022-11-10 08:06:38 -0500

Seen: 156 times

Last updated: Nov 11 '22