File tree Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ namespace BT
17
17
NodeStatus ReactiveSequence::tick ()
18
18
{
19
19
size_t success_count = 0 ;
20
- size_t running_count = 0 ;
21
20
22
21
for (size_t index = 0 ; index < childrenCount (); index++)
23
22
{
@@ -33,8 +32,8 @@ NodeStatus ReactiveSequence::tick()
33
32
switch (child_status)
34
33
{
35
34
case NodeStatus::RUNNING: {
36
- running_count++;
37
-
35
+ // just in case, make sure that following children are not
36
+ // in RUNNING state too
38
37
for (size_t i = index + 1 ; i < childrenCount (); i++)
39
38
{
40
39
haltChild (i);
@@ -65,11 +64,9 @@ NodeStatus ReactiveSequence::tick()
65
64
if (success_count == childrenCount ())
66
65
{
67
66
resetChildren ();
68
-
69
- // Skip if ALL the nodes have been skipped
70
- return status () == (NodeStatus::RUNNING) ? NodeStatus::SUCCESS : NodeStatus::SKIPPED;
71
67
}
72
- throw LogicError (" ReactiveSequence is not supposed to reach this point" );
68
+ // Skip if ALL the nodes have been skipped
69
+ return status () == (NodeStatus::RUNNING) ? NodeStatus::SUCCESS : NodeStatus::SKIPPED;
73
70
}
74
71
75
72
} // namespace BT
Original file line number Diff line number Diff line change @@ -93,3 +93,24 @@ TEST(SkippingLogic, SkipSubtree)
93
93
ASSERT_EQ (status, NodeStatus::SUCCESS);
94
94
}
95
95
96
+ TEST (SkippingLogic, ReactiveSingleChild)
97
+ {
98
+
99
+ static const char * xml_text = R"(
100
+ <root BTCPP_format="4">
101
+ <BehaviorTree ID="Untitled">
102
+ <ReactiveSequence>
103
+ <AlwaysSuccess _skipIf="flag"/>
104
+ </ReactiveSequence>
105
+ </BehaviorTree>
106
+ </root>
107
+ )" ;
108
+
109
+ BT::BehaviorTreeFactory factory;
110
+ auto root_blackboard = BT::Blackboard::create ();
111
+ root_blackboard->set <bool >(" flag" , true );
112
+
113
+ auto tree = factory.createTreeFromText (xml_text, root_blackboard);
114
+
115
+ tree.tickWhileRunning ();
116
+ }
You can’t perform that action at this time.
0 commit comments