ROS2 rclcpp_multithreaded_executor example rate issue
Hello,
I'm trying to use and understand something more about ROS2 multi-thread executor, how it works and now it must properly used. Now I'm trying to reproduce and modify this example
https://github.com/ros2/examples/blob...
from examples packages. If I compile that code as it is, everything works well, and the topic publish rate is about 2Hz as expected. If I try to modify the period in the create_wall_timer methods from 500ms to 50ms I got a variable frequency of the topic in a range between 10 to 17Hz.
Looking to MultiThreadedExecutor doc
http://docs.ros2.org/dashing/api/rclc...
I saw that it's possible to specify the number of thread required as argument for the constructor. I tried to specify 2 and the example seems to publish at a constant rate of 20Hz. So I tried to change again the rate at 5ms, and again I got a variable topic rate; once I specified 1 as the thread argument number everything run well again.
So my questions are:
- There is something that I miss from the example, or something that must be modified if when I change the timer rate?
- How MultiThreadedExecutor must be initialized? If I don't specify the number of threads is it able to understand the number of callback group and timer autonomously?
- If I've correctly initialized both the timer and the executor, why this behavior changing the rate?
I'm using Linux 5.8.0-41-generic #46~20.04.1-Ubuntu.
Thanks
Alessio