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

In ROS2, is a wall timer connected to a node in a way meaningfull for a user

asked 2018-10-30 08:51:46 -0500

uthinu gravatar image

updated 2018-10-30 09:50:22 -0500

Hi, I need an object (a node) to create a timer in ROS2. I can create any node just in order to call the respective method create_wall_timer , but I would like to have a timer which calls any generic callback not connected to a ROS node. I guess it works like that but you need a node for some technical reasons mentioned here!top... ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-10-30 13:14:13 -0500

William gravatar image

I think my answer on the mailing list you linked is the right one:

You need to have something to wait on the timer (they do not create their own threads or anything) and so you need to add it to an executor. For that reason we create it through the node. It would be possible to have a timer which can be used with an executor and without a node, but that's not currently possible.

If you want a timer that automatically calls the callback without blocking (fire and forget), then you should consider using C++'s async and std::this_thread::sleep_for:

edit flag offensive delete link more


What is exactly an executor? (I have some idea) Is rclcpp an executor? (it has a spin method). Is there some info about this?

Kansai gravatar image Kansai  ( 2020-05-14 00:54:22 -0500 )edit

Question Tools



Asked: 2018-10-30 08:51:46 -0500

Seen: 2,113 times

Last updated: Oct 30 '18