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
1717NodeStatus ReactiveSequence::tick ()
1818{
1919 size_t success_count = 0 ;
20- size_t running_count = 0 ;
2120
2221 for (size_t index = 0 ; index < childrenCount (); index++)
2322 {
@@ -33,8 +32,8 @@ NodeStatus ReactiveSequence::tick()
3332 switch (child_status)
3433 {
3534 case NodeStatus::RUNNING: {
36- running_count++;
37-
35+ // just in case, make sure that following children are not
36+ // in RUNNING state too
3837 for (size_t i = index + 1 ; i < childrenCount (); i++)
3938 {
4039 haltChild (i);
@@ -65,11 +64,9 @@ NodeStatus ReactiveSequence::tick()
6564 if (success_count == childrenCount ())
6665 {
6766 resetChildren ();
68-
69- // Skip if ALL the nodes have been skipped
70- return status () == (NodeStatus::RUNNING) ? NodeStatus::SUCCESS : NodeStatus::SKIPPED;
7167 }
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;
7370}
7471
7572} // namespace BT
Original file line number Diff line number Diff line change @@ -93,3 +93,24 @@ TEST(SkippingLogic, SkipSubtree)
9393 ASSERT_EQ (status, NodeStatus::SUCCESS);
9494}
9595
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