11#include < gtest/gtest.h>
22#include " behaviortree_cpp/bt_factory.h"
33#include " test_helper.hpp"
4+ #include " behaviortree_cpp/loggers/bt_cout_logger.h"
45
56using BT::NodeStatus;
67using std::chrono::milliseconds;
78
8- static const char * reactive_xml_text = R"(
9+ TEST (Reactive, RunningChildren)
10+ {
11+
12+ static const char * reactive_xml_text = R"(
913<root BTCPP_format="4" >
1014 <BehaviorTree ID="MainTree">
1115 <ReactiveSequence>
@@ -24,9 +28,6 @@ static const char* reactive_xml_text = R"(
2428</root>
2529)" ;
2630
27-
28- TEST (Reactive, RunningChildren)
29- {
3031 BT::BehaviorTreeFactory factory;
3132 std::array<int , 6 > counters;
3233 RegisterTestTick (factory, " Test" , counters);
@@ -56,3 +57,41 @@ TEST(Reactive, RunningChildren)
5657}
5758
5859
60+ TEST (Reactive, Issue587)
61+ {
62+ // TestA should be executed only once, because of the variable "test"
63+
64+ static const char * reactive_xml_text = R"(
65+ <root BTCPP_format="4" >
66+ <BehaviorTree ID="Example A">
67+ <Sequence>
68+ <Script code="test := false"/>
69+ <ReactiveSequence>
70+ <RetryUntilSuccessful name="Retry 1" num_attempts="-1" _skipIf="test ">
71+ <TestA name="Success 1" _onSuccess="test = true"/>
72+ </RetryUntilSuccessful>
73+ <RetryUntilSuccessful name="Retry 2" num_attempts="5">
74+ <AlwaysFailure name="Failure 2"/>
75+ </RetryUntilSuccessful>
76+ </ReactiveSequence>
77+ </Sequence>
78+ </BehaviorTree>
79+ </root>
80+ )" ;
81+
82+ BT::BehaviorTreeFactory factory;
83+ std::array<int , 2 > counters;
84+ RegisterTestTick (factory, " Test" , counters);
85+
86+ auto tree = factory.createTreeFromText (reactive_xml_text);
87+ BT::StdCoutLogger logger (tree);
88+
89+ // for(int i=0; i<5; i++)
90+ {
91+ tree.tickWhileRunning ();
92+ }
93+
94+ ASSERT_EQ (counters[0 ], 1 );
95+ }
96+
97+
0 commit comments