Halt the running branch before starting another asynchronous action - #1217
Open
Quchaosheng wants to merge 1 commit into
Open
Quchaosheng wants to merge 1 commit into
Quchaosheng wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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