You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ ros2 run rcldotnet_examples rcldotnet_guard_condition
Here is the console application that causes this: (logging is was added to rcldotnet in the linked branch)
using System;using System.Threading;using System.Threading.Tasks;using ROS2;namespaceConsoleApplication{publicstaticclassRCLDotnetGuardCondition{staticGuardCondition_guardCondition=null;publicstaticvoidMain(string[]args){
RCLdotnet.Init();varnode= RCLdotnet.CreateNode("guard_condition_example");_guardCondition= node.CreateGuardCondition(GuardConditionTriggered);
Console.WriteLine(RCLdotnet.GetRMWIdentifier());
Console.WriteLine($"ThreadId: {Environment.CurrentManagedThreadId}");
_guardCondition.Trigger();
RCLdotnet.Spin(node);}staticvoidGuardConditionTriggered(){_= TriggerAfterSomeTime();}staticasync Task TriggerAfterSomeTime(){// This is a multiple of the 500ms used in the loop in// RCLdotnet.Spin(). So the guard condition will be triggered nearly// at the same time as the wait times out.await Task.Delay(1000);// This will be called in an background worker thread as console// applications don't have an SynchronizationContext by default.
_guardCondition.Trigger();}}}
Expected behavior
This console application should run forever triggering the guard condition every second.
Actual behavior
After some time the callback for the guard condition dosn't get triggerd -> so no retrigger after one second. (The waitset never signals that the gaurd condition is ready)
I'm not sure if this is a supported pattern to use guard_conditions in combination with waitsets.
Before further investigation I would like to ask if I am doing something wrong while adding guard conditions to rcldotnet? (see this commit: hoffmann-stefan/ros2_dotnet@b7713c5)
I didn't find documentation for this, so if I'm doing someting wrong maybe we can extend the header documentation?
The text was updated successfully, but these errors were encountered:
This repo is for rcl issues, not for rcldotnet.
If you believe an issue in rcldotnet is caused by an issue in rcl, please provide a minimal reproducible example of the bug written in C (or C++) using rcl directly.
Feel free to update the description and reopen or open a new issue when you have that.
Thanks!
Got this working with switching the ROS2 middleware to cyclonedds, so at least my branch for rcldotnet can't be completely wrong.
Was hoping maybe something obvious for people knowing rcl would be found while glimpsing over the linked source code, but It seems that there is no way around a c/c++ minimal example. Though I can't promise when/if I get to this.
As for C# async this should be like c++ promise/features with additional syntactic sugar to avoid callback hell. The code after the Task.Delay continues in a background thread that is managed by the dotnet runtime. Though I don't know exactly which implementation details this has that may interfere with the multi-threading synchronization used by rcl/rmw.
Bug report
Required Info:
Linux Client-291 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
$ apt-cache policy ros-foxy-rcl ros-foxy-rcl: Installed: 1.1.13-1focal.20220209.142931 Candidate: 1.1.13-1focal.20220209.142931 Version table: *** 1.1.13-1focal.20220209.142931 500 500 http://packages.ros.org/ros2/ubuntu focal/main amd64 Packages 100 /var/lib/dpkg/status
Steps to reproduce issue
Using this branch that adds an example to reproduce this run the follwoing command:
https://github.com/hoffmann-stefan/ros2_dotnet/commits/reproduce_gaurd_condition_not_triggerd
Here is the console application that causes this: (logging is was added to
rcldotnet
in the linked branch)Expected behavior
This console application should run forever triggering the guard condition every second.
Actual behavior
After some time the callback for the guard condition dosn't get triggerd -> so no retrigger after one second. (The waitset never signals that the gaurd condition is ready)
Additional information
I'm not sure if this is a supported pattern to use guard_conditions in combination with waitsets.
Before further investigation I would like to ask if I am doing something wrong while adding guard conditions to rcldotnet? (see this commit: hoffmann-stefan/ros2_dotnet@b7713c5)
I didn't find documentation for this, so if I'm doing someting wrong maybe we can extend the header documentation?
The text was updated successfully, but these errors were encountered: