Skip to content

Commit

Permalink
Merge pull request #130 from hofmannmarkus0/fix/timer-execution
Browse files Browse the repository at this point in the history
fix Timers not being invoked when using ActionClients or ActionServer within the same node
  • Loading branch information
hoffmann-stefan authored Apr 15, 2024
2 parents 40adb43 + 7b94df8 commit bbf949f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions rcldotnet/RCLdotnet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,17 @@ public static void SpinOnce(Node node, long timeout)
WaitSetAddGuardCondition(waitSetHandle, guardCondition.Handle);
}

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);
Expand All @@ -1231,11 +1242,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)
{
Expand Down

0 comments on commit bbf949f

Please sign in to comment.