From 84aa569a377b85d032d6463ef137f28c4e1b2bc8 Mon Sep 17 00:00:00 2001 From: Markus Hofmann Date: Thu, 11 Apr 2024 14:37:53 +0200 Subject: [PATCH 1/2] fix Timers not being invoked when using ActionClients or ActionServers within the same node --- rcldotnet/RCLdotnet.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/rcldotnet/RCLdotnet.cs b/rcldotnet/RCLdotnet.cs index e52c03f5..080c7a39 100644 --- a/rcldotnet/RCLdotnet.cs +++ b/rcldotnet/RCLdotnet.cs @@ -1221,6 +1221,14 @@ public static void SpinOnce(Node node, long timeout) WaitSetAddGuardCondition(waitSetHandle, guardCondition.Handle); } + // Add timers to WaitSet before action clients and servers. + // As ActionClient and ActionServer also register timers internally, + // the order of adding them to the WaitSet has to match the execution order + foreach (var timer in node.Timers) + { + WaitSetAddTimer(waitSetHandle, timer.Handle); + } + foreach (var actionClient in node.ActionClients) { WaitSetAddActionClient(waitSetHandle, actionClient.Handle); @@ -1231,11 +1239,6 @@ public static void SpinOnce(Node node, long timeout) WaitSetAddActionServer(waitSetHandle, actionServer.Handle); } - foreach (var timer in node.Timers) - { - WaitSetAddTimer(waitSetHandle, timer.Handle); - } - bool ready = Wait(waitSetHandle, timeout); if (!ready) { From 7b94df8115440855947d4c849947a583132f3c2b Mon Sep 17 00:00:00 2001 From: Stefan Hoffmann Date: Mon, 15 Apr 2024 09:40:19 +0200 Subject: [PATCH 2/2] reword comment about order of adding waitables The old comment only mentioned times, but this applies to the other waitables as well. --- rcldotnet/RCLdotnet.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rcldotnet/RCLdotnet.cs b/rcldotnet/RCLdotnet.cs index 080c7a39..eeefea8a 100644 --- a/rcldotnet/RCLdotnet.cs +++ b/rcldotnet/RCLdotnet.cs @@ -1221,14 +1221,17 @@ public static void SpinOnce(Node node, long timeout) WaitSetAddGuardCondition(waitSetHandle, guardCondition.Handle); } - // Add timers to WaitSet before action clients and servers. - // As ActionClient and ActionServer also register timers internally, - // the order of adding them to the WaitSet has to match the execution order foreach (var timer in node.Timers) { WaitSetAddTimer(waitSetHandle, timer.Handle); } + // Action clients and servers need to be registerd after all the + // others that are handled by + // RCLdotnetDelegates.native_rcl_wait_set_*_ready methods, as + // they track indexes of the given waitables. Adding action + // clients and action servers before will get those indexes + // mixed up. foreach (var actionClient in node.ActionClients) { WaitSetAddActionClient(waitSetHandle, actionClient.Handle);