@@ -18,7 +18,6 @@ namespace BT
1818FallbackNode::FallbackNode (const std::string& name, bool make_asynch)
1919 : ControlNode::ControlNode(name, {})
2020 , current_child_idx_(0 )
21- , all_skipped_(true )
2221 , asynch_(make_asynch)
2322{
2423 if (asynch_)
@@ -33,7 +32,7 @@ NodeStatus FallbackNode::tick()
3332
3433 if (status () == NodeStatus::IDLE)
3534 {
36- all_skipped_ = true ;
35+ skipped_count_ = 0 ;
3736 }
3837
3938 setStatus (NodeStatus::RUNNING);
@@ -45,9 +44,6 @@ NodeStatus FallbackNode::tick()
4544 auto prev_status = current_child_node->status ();
4645 const NodeStatus child_status = current_child_node->executeTick ();
4746
48- // switch to RUNNING state as soon as you find an active child
49- all_skipped_ &= (child_status == NodeStatus::SKIPPED);
50-
5147 switch (child_status)
5248 {
5349 case NodeStatus::RUNNING: {
@@ -73,6 +69,7 @@ NodeStatus FallbackNode::tick()
7369 case NodeStatus::SKIPPED: {
7470 // It was requested to skip this node
7571 current_child_idx_++;
72+ skipped_count_++;
7673 }
7774 break ;
7875 case NodeStatus::IDLE: {
@@ -89,7 +86,7 @@ NodeStatus FallbackNode::tick()
8986 }
9087
9188 // Skip if ALL the nodes have been skipped
92- return all_skipped_ ? NodeStatus::SKIPPED : NodeStatus::FAILURE;
89+ return (skipped_count_ == children_count) ? NodeStatus::SKIPPED : NodeStatus::FAILURE;
9390}
9491
9592void FallbackNode::halt ()
0 commit comments