File tree Expand file tree Collapse file tree 5 files changed +21
-6
lines changed
include/behaviortree_cpp_v3 Expand file tree Collapse file tree 5 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -154,6 +154,21 @@ struct Tree
154154 return *this ;
155155 }
156156
157+ void haltTree ()
158+ {
159+ // the halt should propagate to all the node if all the nodes
160+ // are implemented correctly
161+ root_node->halt ();
162+ root_node->setStatus (NodeStatus::IDLE);
163+
164+ // but, just in case.... this should be no-op
165+ auto visitor = [](BT::TreeNode * node) {
166+ node->halt ();
167+ node->setStatus (BT::NodeStatus::IDLE);
168+ };
169+ BT::applyRecursiveVisitor (root_node, visitor);
170+ }
171+
157172 ~Tree ();
158173
159174 Blackboard::Ptr rootBlackboard ();
Original file line number Diff line number Diff line change @@ -28,7 +28,6 @@ class ConditionNode : public LeafNode
2828 // Do nothing
2929 virtual void halt () override final
3030 {
31- // just in case, but it should not be needed
3231 setStatus (NodeStatus::IDLE);
3332 }
3433
Original file line number Diff line number Diff line change @@ -80,8 +80,6 @@ class TreeNode
8080
8181 NodeStatus status () const ;
8282
83- void setStatus (NodeStatus new_status);
84-
8583 // / Name of the instance, not the type
8684 const std::string& name () const ;
8785
@@ -153,6 +151,9 @@ class TreeNode
153151 virtual BT::NodeStatus tick () = 0;
154152
155153 friend class BehaviorTreeFactory ;
154+ friend class DecoratorNode ;
155+ friend class ControlNode ;
156+ friend class Tree ;
156157
157158 // Only BehaviorTreeFactory should call this
158159 void setRegistrationID (StringView ID)
@@ -162,6 +163,8 @@ class TreeNode
162163
163164 void modifyPortsRemapping (const PortsRemapping& new_remapping);
164165
166+ void setStatus (NodeStatus new_status);
167+
165168 private:
166169 const std::string name_;
167170
Original file line number Diff line number Diff line change @@ -169,7 +169,6 @@ struct CoroActionNode::Pimpl
169169{
170170 coroutine::routine_t coro;
171171 std::atomic<bool > pending_destroy;
172-
173172};
174173
175174
Original file line number Diff line number Diff line change @@ -61,8 +61,7 @@ NodeStatus TimeoutNode::tick()
6161 if (!aborted && child ()->status () == NodeStatus::RUNNING)
6262 {
6363 child_halted_ = true ;
64- child ()->halt ();
65- child ()->setStatus (NodeStatus::IDLE);
64+ haltChild ();
6665 }
6766 });
6867 }
You can’t perform that action at this time.
0 commit comments