@@ -18,7 +18,6 @@ namespace BT
18
18
FallbackNode::FallbackNode (const std::string& name, bool make_asynch)
19
19
: ControlNode::ControlNode(name, {})
20
20
, current_child_idx_(0 )
21
- , all_skipped_(true )
22
21
, asynch_(make_asynch)
23
22
{
24
23
if (asynch_)
@@ -33,7 +32,7 @@ NodeStatus FallbackNode::tick()
33
32
34
33
if (status () == NodeStatus::IDLE)
35
34
{
36
- all_skipped_ = true ;
35
+ skipped_count_ = 0 ;
37
36
}
38
37
39
38
setStatus (NodeStatus::RUNNING);
@@ -45,9 +44,6 @@ NodeStatus FallbackNode::tick()
45
44
auto prev_status = current_child_node->status ();
46
45
const NodeStatus child_status = current_child_node->executeTick ();
47
46
48
- // switch to RUNNING state as soon as you find an active child
49
- all_skipped_ &= (child_status == NodeStatus::SKIPPED);
50
-
51
47
switch (child_status)
52
48
{
53
49
case NodeStatus::RUNNING: {
@@ -73,6 +69,7 @@ NodeStatus FallbackNode::tick()
73
69
case NodeStatus::SKIPPED: {
74
70
// It was requested to skip this node
75
71
current_child_idx_++;
72
+ skipped_count_++;
76
73
}
77
74
break ;
78
75
case NodeStatus::IDLE: {
@@ -89,7 +86,7 @@ NodeStatus FallbackNode::tick()
89
86
}
90
87
91
88
// 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;
93
90
}
94
91
95
92
void FallbackNode::halt ()
0 commit comments