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) {