Skip to content

Halt the running branch before starting another asynchronous action - #1217

Open
Quchaosheng wants to merge 1 commit into
BehaviorTree:masterfrom
Quchaosheng:fix-reactive-async-halt-order
Open

Quchaosheng wants to merge 1 commit into
BehaviorTree:masterfrom
Quchaosheng:fix-reactive-async-halt-order

Conversation

@Quchaosheng

@Quchaosheng Quchaosheng commented Sep 30, 2026 •

Copy link
Copy Markdown

ReactiveSequence and ReactiveFallback halt the siblings of a child only after that child returned RUNNING. When the new child starts an asynchronous action in its onStart(), the action of the branch that is about to be preempted is still alive, so for a short time two actions run concurrently. With the ROS action wrappers that means that a new goal is sent before the previous one is cancelled, which is the race described in issue #1031.

Let an asynchronous node stop the branches that are still RUNNING right before it transitions out of IDLE, walking up to the root. Parallel is the only control node designed to keep several children running at the same time, so it stops the walk.

To know the ancestors, every node now stores the parent that the parser sets when the children are added to the tree.

This follows the direction invited in #1031 for reworking #93, without the propagateHalt coupling: the async node asks its ancestors to release the other branches, instead of every control node having to know about asynchronous children.

Reproduced with ReactiveSequence[ ReactiveFallback[BatteryOk, GotoCharging], GotoKitchen ]:

before: GotoKitchen:onStart ... GotoCharging:onStart GotoKitchen:onHalted
max concurrent actions = 2
after: GotoKitchen:onHalted GotoCharging:onStart
max concurrent actions = 1

The new test fails without the fix (max concurrent actions 2, halt after start) and passes with it. All 523 tests pass.

Fixes #1031

ReactiveSequence and ReactiveFallback halt the siblings of a child only
after that child returned RUNNING. When the new child starts an
asynchronous action in its onStart(), the action of the branch that is
about to be preempted is still alive, so for a short time two actions run
concurrently. With the ROS action wrappers that means that a new goal is
sent before the previous one is cancelled, which is the race described in
issue BehaviorTree#1031.

Let an asynchronous node stop the branches that are still RUNNING right
before it transitions out of IDLE, walking up to the root. Parallel is
the only control node designed to keep several children running at the
same time, so it stops the walk.

To know the ancestors, every node now stores the parent that the parser
sets when the children are added to the tree.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using ReactiveSequence/ReactiveFallback with multiple async children can cause race conditions

1 participant