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