ros2 / examples

Example packages for ROS 2
Apache License 2.0
691 stars 311 forks source link

Demo for callback-group-level executor concept. #302

Closed ralph-lange closed 3 years ago

ralph-lange commented 3 years ago

Moved PR from ros2/demos to this repository as discussed in https://github.com/ros2/demos/pull/485.

ralph-lange commented 3 years ago

Hi @Karsten1987, I fixed the warnings caused by the line lengths in the CMakeLists.txt. Could you please re-trigger the job on ci.ros2.org?

ralph-lange commented 3 years ago

Converted it to a draft until macOS support is implemented.

ralph-lange commented 3 years ago

Hi @Karsten1987, I tried to add support for macOS - without having any practical C++ experience on this platform. Could you please test and my implementation?

Karsten1987 commented 3 years ago

@ralph-lange the CPU affinity indeed required the threads to the suspended while being configured. The condition variable seemed to have work according to the following output:

 ➭ ros2 run examples_rclcpp_cbg_executor ping_pong
1614233204.026369 [71]   12615970: using network interface en0 (udp/10.0.0.222) selected arbitrarily from: en0, vnic0, vnic1, vboxnet0, en8
[INFO] [1614233204.055699564] [pong_node]: Running experiment from now on for 10 s ...
[INFO] [1614233214.057528441] [ping_node]: High prio path: Sent 988 pings, received 985 pongs.
[INFO] [1614233214.057547680] [ping_node]: High prio path: Average RTT is 27.9 ms.
[INFO] [1614233214.057557175] [ping_node]: Low prio path: Sent 988 pings, received 0 pongs.
[INFO] [1614233214.057563656] [pong_node]: High priority executor thread ran for 9987 ms.
[INFO] [1614233214.057569745] [pong_node]: Low priority executor thread ran for 0 ms.

I could do this without requiring root rights, so maybe that'll also reduce the need for it on Linux.

I further went ahead and refactored the nodes from being compile dependent on the compiler options (ADD_PING, ADD_PONG, ...) into three individual files. I hope you don't mind that I renamed the executables accordingly.

CI:

ralph-lange commented 3 years ago

Great that you got the core pinning for macOS working. However, we have to use separate mutexes for each executor instance. Otherwise, with the current lock mechanism, only one of the two executor instances will eventually run. I'll fix this in the evening.

ralph-lange commented 3 years ago

@Karsten1987, could you please re-trigger the job on ci.ros2.org?

Karsten1987 commented 3 years ago
Karsten1987 commented 3 years ago