File tree Expand file tree Collapse file tree 4 files changed +8
-19
lines changed
include/nav2_behavior_tree Expand file tree Collapse file tree 4 files changed +8
-19
lines changed Original file line number Diff line number Diff line change @@ -85,9 +85,9 @@ class BehaviorTreeEngine
8585
8686 /* *
8787 * @brief Function to explicitly reset all BT nodes to initial state
88- * @param root_node Pointer to BT root node
88+ * @param tree Tree to halt
8989 */
90- void haltAllActions (BT::TreeNode * root_node );
90+ void haltAllActions (BT::Tree & tree );
9191
9292protected:
9393 // The factory that will be used to dynamically construct the behavior tree
Original file line number Diff line number Diff line change @@ -177,10 +177,11 @@ class BtActionServer
177177 /* *
178178 * @brief Function to halt the current tree. It will interrupt the execution of RUNNING nodes
179179 * by calling their halt() implementation (only for Async nodes that may return RUNNING)
180+ * This should already done for all the exit states of the action but preemption
180181 */
181182 void haltTree ()
182183 {
183- tree_.rootNode ()-> halt ();
184+ tree_.haltTree ();
184185 }
185186
186187protected:
Original file line number Diff line number Diff line change @@ -203,7 +203,7 @@ bool BtActionServer<ActionT>::on_cleanup()
203203 plugin_lib_names_.clear ();
204204 current_bt_xml_filename_.clear ();
205205 blackboard_.reset ();
206- bt_->haltAllActions (tree_. rootNode () );
206+ bt_->haltAllActions (tree_);
207207 bt_.reset ();
208208 return true ;
209209}
@@ -281,7 +281,7 @@ void BtActionServer<ActionT>::executeCallback()
281281
282282 // Make sure that the Bt is not in a running state from a previous execution
283283 // note: if all the ControlNodes are implemented correctly, this is not needed.
284- bt_->haltAllActions (tree_. rootNode () );
284+ bt_->haltAllActions (tree_);
285285
286286 // Give server an opportunity to populate the result message or simple give
287287 // an indication that the action is complete.
Original file line number Diff line number Diff line change @@ -90,22 +90,10 @@ BehaviorTreeEngine::createTreeFromFile(
9090
9191// In order to re-run a Behavior Tree, we must be able to reset all nodes to the initial state
9292void
93- BehaviorTreeEngine::haltAllActions (BT::TreeNode * root_node )
93+ BehaviorTreeEngine::haltAllActions (BT::Tree & tree )
9494{
95- if (!root_node) {
96- return ;
97- }
98-
9995 // this halt signal should propagate through the entire tree.
100- root_node->halt ();
101-
102- // but, just in case...
103- auto visitor = [](BT::TreeNode * node) {
104- if (node->status () == BT::NodeStatus::RUNNING) {
105- node->halt ();
106- }
107- };
108- BT::applyRecursiveVisitor (root_node, visitor);
96+ tree.haltTree ();
10997}
11098
11199} // namespace nav2_behavior_tree
You can’t perform that action at this time.
0 commit comments