-
Notifications
You must be signed in to change notification settings - Fork 680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't restart SequenceStar on halt #329
Don't restart SequenceStar on halt #329
Conversation
I think you are correct and it is a bug. Thanks a lot for taking the time to add unit tests too!! I hope not too many people were relying on this buggy behavior. |
thanks |
Question on this new behavior. In ROS2 navigation2, when a navigation is canceled, all of the behavior tree nodes are 'halted'. The assumption is that by halting all of the nodes, the behavior tree is reset and can be called again. Given this behavior, what is the proper method for truly resetting all behavior tree nodes? |
@tgreier I think a normal Sequence node will do what you are looking for (ticking consecutive nodes without going back for as long as the node is running, and then ticking from start after the node has been reset/halted). |
@Affonso-Gui Thank you, yes I agree that will solve my specific issue. But, is there a way to reset all behavior tree nodes without destroying and recreating the behavior tree instance? |
@facontidavide I tend to agree with @tgreier assuming my intepretation of "halt" is correct in BT language (@miccol, thoughts?). When I call halt, I expect the behavior tree to reset all of the nodes' states (as it does now), that includes the control flow nodes. So I think idx should be set back to zero, why would the control flow nodes be some special case relative to the other nodes? The The memory of a "star" node is for intra-execution, I don't think having memory inter-execution is sensible (or if there are inter-execution states, blackboard may be a good choice). When Edit: This does actually cause a regression in our BT's in Nav2 https://github.com/ros-planning/navigation2/blob/main/nav2_bt_navigator/behavior_trees/navigate_to_pose_w_replanning_goal_patience_and_recovery.xml |
Hi, I would also reset the index after a halt. I usually use the Sequence Node when I need a node with memory. Coupling an action with its "success condition" (when possible) helps skip actions that are not required to be re-executed. |
Why and in which context are you using SequenceStar? What is your motivating example? |
If I have a BT with some After this PR, it breaks that behavior by not resetting the node to be ticked next so it no longer starts with the first child like it would in a "fresh" start of the tree, which Also moreover that I think you knew this was incorrect initially when you developed it. This is a behavior Nav2 relies on so that we can execute multiple navigation tasks using the same tree. I don't really see the sensibility in this PR change. tl;dr: I strongly encourage you to revert this PR, I don't see any reason why |
My main motivation for this change was:
However, I do agree with the following.
Hopefully state management has also become easier with the new version 4.0. On the other hand, the Overall I agree with reverting this, but I would also like to have a more detailed documentation entry on this behavior. |
Yeah, I ran into alot of pages on google with deadlinks to BT.CPP's website, I'm not sure what's up with that. For your other points, I think those are situations perhaps that need some different designs in your BT to handle. I could give you some off the cuff suggestions, but obviously I don't know alot about your situation so they may be off base. I would strongly argue though that relying on a non-resetting SequenceStar child counter between executions is the wrong (and very fragile) thing to do. 2 suggestions though:
🥳 🎆 |
Thanks for the insights. Currently I am using a version of the 1st approach (custom control node), but having a condition guard for initialization code also seems nice. A little more clarification, though, just in case.
My main use case was not to retain states across different executions, but across possible action shifts ("interruptions") within the same execution. More concretely, to avoid re-execution of completed actions when the In my particular case, I would only tick the tree until the root returned |
Taking a quick look into the Nav2 package, it seems like you are focusing more on the explicit calls to the This makes me wonder if it would be the case to simply overwride the |
@facontidavide can this be reverted? |
reverted |
Thanks! Do you know when you might run a release to get this out into binary format? |
This might need some discussion, but I am pretty sure it's a bug.
The problem:
SequenceStar resets progress when halted https://github.com/BehaviorTree/BehaviorTree.CPP/blob/master/src/controls/sequence_star_node.cpp#L77
So in reactive formulations such as the example image below (also used in the documentation), if the battery check fails during GoTo=B, GoTo=A will be re-executed in the next sequence tick. Since we are using SequenceStar to avoid repeating actions which have already returned SUCESS, the execution should be resumed from GoTo=B even after halted.