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
154
154
return *this ;
155
155
}
156
156
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
+
157
172
~Tree ();
158
173
159
174
Blackboard::Ptr rootBlackboard ();
Original file line number Diff line number Diff line change @@ -28,7 +28,6 @@ class ConditionNode : public LeafNode
28
28
// Do nothing
29
29
virtual void halt () override final
30
30
{
31
- // just in case, but it should not be needed
32
31
setStatus (NodeStatus::IDLE);
33
32
}
34
33
Original file line number Diff line number Diff line change @@ -80,8 +80,6 @@ class TreeNode
80
80
81
81
NodeStatus status () const ;
82
82
83
- void setStatus (NodeStatus new_status);
84
-
85
83
// / Name of the instance, not the type
86
84
const std::string& name () const ;
87
85
@@ -153,6 +151,9 @@ class TreeNode
153
151
virtual BT::NodeStatus tick () = 0;
154
152
155
153
friend class BehaviorTreeFactory ;
154
+ friend class DecoratorNode ;
155
+ friend class ControlNode ;
156
+ friend class Tree ;
156
157
157
158
// Only BehaviorTreeFactory should call this
158
159
void setRegistrationID (StringView ID)
@@ -162,6 +163,8 @@ class TreeNode
162
163
163
164
void modifyPortsRemapping (const PortsRemapping& new_remapping);
164
165
166
+ void setStatus (NodeStatus new_status);
167
+
165
168
private:
166
169
const std::string name_;
167
170
Original file line number Diff line number Diff line change @@ -169,7 +169,6 @@ struct CoroActionNode::Pimpl
169
169
{
170
170
coroutine::routine_t coro;
171
171
std::atomic<bool > pending_destroy;
172
-
173
172
};
174
173
175
174
Original file line number Diff line number Diff line change @@ -61,8 +61,7 @@ NodeStatus TimeoutNode::tick()
61
61
if (!aborted && child ()->status () == NodeStatus::RUNNING)
62
62
{
63
63
child_halted_ = true ;
64
- child ()->halt ();
65
- child ()->setStatus (NodeStatus::IDLE);
64
+ haltChild ();
66
65
}
67
66
});
68
67
}
You can’t perform that action at this time.
0 commit comments