ros2-dotnet / ros2_dotnet

.NET bindings for ROS2
Apache License 2.0
136 stars 54 forks source link

GuardConditions sometimes don't get triggered for Fast DDS #105

Open hoffmann-stefan opened 1 year ago

hoffmann-stefan commented 1 year ago

This was reported to the rcl repository as well, but got closed there as they asked for a minimal example in c/c++ https://github.com/ros2/rcl/issues/989

https://github.com/ros2-dotnet/ros2_dotnet/pull/103 added support for GuardConditions in ros2_dotnet. The rcldotnet_guard_condition example node can reproduce this problem for me reliably on foxy (Ubuntu 20.04), humble and rolling (both Ubuntu 22.04) using the Fast DDS middleware. Using Cyclone DDS there is no problem.

Steps to reproduce

Build the ros2_dotnet workspace as described in the README.md. Do this each in a new terminal, once for rmw_fastrtps_cpp and once for rmw_cyclonedds_cpp:

cd ros2_dotnet_ws/
source install/setup.bash
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
ros2 run rcldotnet_examples rcldotnet_guard_condition
cd ros2_dotnet_ws/
source install/setup.bash
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
ros2 run rcldotnet_examples rcldotnet_guard_condition

Both should print out messages like this indefinitely, see changing timestamps on the output:

ros2 run rcldotnet_examples rcldotnet_guard_condition
RMWIdentifier: rmw_fastrtps_cpp
2023-05-19T17:01:49.6250316+02:00 ThreadId: 1 - Initial trigger of GuardCondition.
2023-05-19T17:01:49.6379550+02:00 ThreadId: 1 - GuardCondition was triggered.
2023-05-19T17:01:50.6401007+02:00 ThreadId: 4 - Triggered GuardCondition.
2023-05-19T17:01:50.6401927+02:00 ThreadId: 1 - GuardCondition was triggered.
2023-05-19T17:01:51.6406326+02:00 ThreadId: 4 - Triggered GuardCondition.
2023-05-19T17:01:51.6406868+02:00 ThreadId: 1 - GuardCondition was triggered.
2023-05-19T17:01:52.6410867+02:00 ThreadId: 4 - Triggered GuardCondition.
2023-05-19T17:01:52.6410960+02:00 ThreadId: 1 - GuardCondition was triggered.
2023-05-19T17:01:53.6415770+02:00 ThreadId: 4 - Triggered GuardCondition.
2023-05-19T17:01:53.6416664+02:00 ThreadId: 1 - GuardCondition was triggered.
2023-05-19T17:01:54.6420948+02:00 ThreadId: 4 - Triggered GuardCondition.

But after some time the example node using Fast DDS stops outputting new log messages. I never saw Cyclone DDS stopping even after running this example for some hours.

If someone wants to help you could try this out on your machine and report back if you can reproduce the issue using both middleware implementations.