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

ROS2 rclcpp_multithreaded_executor example rate issue

asked 2021-02-12 03:52:03 -0500

piri gravatar image

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:

  1. There is something that I miss from the example, or something that must be modified if when I change the timer rate?
  2. 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?
  3. 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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-02-14 15:19:26 -0500

piri gravatar image
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-02-12 03:52:03 -0500

Seen: 317 times

Last updated: Feb 14 '21