ros2_documentation
ros2_documentation copied to clipboard
Tutorial on the use of timers and publisher callbacks
Hello,
I recently had to migrate a motor driver node in ROS2, where the node:
- subscribes to
Twistmessages from ateleopnode - publishes a
Odometrymessage at a higher frequency than the Twist messages
After searching extensively, I found out that there were not a lot of online examples that had this kind of publish-subscribe with different frequencies, as most examples have subscriber callback functions that publish messages in the body of the function.
My colleagues and I finally found out that we could use a publish method as a timer callback, and I think it could be great to add a tutorial on the use of timers for that, as it is a problem that is fairly common. Here is an example node that I made in order to find solutions to our problem.
Thanks
https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber.html#write-the-publisher-node has an example of using publish in a timer callback. Is that enough of an example?
Yes, it's a good example for using a publish in a timer callback
But what about an example for republishing ?
It's kinda common to have a node that subscribes to some topics and republishes on other topics.
Such kind of republishing node could be part of ros2/demos instead
IMO, I would like to keep examples and demos as simple as possible to how to call or demonstrate ROS 2 APIs or Features, not so much related to how to write the application.