13 #include <gtest/gtest.h> 19 using std::chrono::milliseconds;
29 , condition(
"condition")
30 , action(
"action", milliseconds(100) )
50 , condition_1(
"condition_1")
51 , condition_2(
"condition_2")
52 , action_1(
"action_1", milliseconds(100) )
72 , action(
"action", milliseconds(100) )
73 , condition(
"condition")
98 : root(
"root_fallback")
99 , action_1(
"action_1", milliseconds(100) )
100 , action_2(
"action_2", milliseconds(100) )
101 , condition_1(
"condition_1")
102 , condition_2(
"condition_2")
103 , fal_conditions(
"fallback_conditions")
104 , fal_actions(
"fallback_actions")
108 fal_conditions.
addChild(&condition_1);
109 fal_conditions.
addChild(&condition_2);
131 ASSERT_EQ(NodeStatus::SUCCESS, state);
143 ASSERT_EQ(NodeStatus::RUNNING, state);
150 ASSERT_EQ(NodeStatus::RUNNING, state);
157 condition_1.setBoolean(
false);
158 condition_2.setBoolean(
false);
162 ASSERT_EQ(NodeStatus::RUNNING, state);
163 ASSERT_EQ(NodeStatus::FAILURE, condition_1.status());
164 ASSERT_EQ(NodeStatus::FAILURE, condition_2.status());
165 ASSERT_EQ(NodeStatus::RUNNING, action_1.status());
167 condition_1.setBoolean(
true);
171 ASSERT_EQ(NodeStatus::SUCCESS, state);
172 ASSERT_EQ(NodeStatus::IDLE, condition_1.status());
173 ASSERT_EQ(NodeStatus::IDLE, condition_2.status());
174 ASSERT_EQ(NodeStatus::IDLE, action_1.status());
179 condition_1.setBoolean(
false);
180 condition_2.setBoolean(
false);
184 ASSERT_EQ(NodeStatus::RUNNING, state);
185 ASSERT_EQ(NodeStatus::FAILURE, condition_1.status());
186 ASSERT_EQ(NodeStatus::FAILURE, condition_2.status());
187 ASSERT_EQ(NodeStatus::RUNNING, action_1.status());
189 condition_2.setBoolean(
true);
193 ASSERT_EQ(NodeStatus::SUCCESS, state);
194 ASSERT_EQ(NodeStatus::IDLE, condition_1.status());
195 ASSERT_EQ(NodeStatus::IDLE, condition_2.status());
196 ASSERT_EQ(NodeStatus::IDLE, action_1.status());
204 ASSERT_EQ(NodeStatus::RUNNING, state);
214 ASSERT_EQ(NodeStatus::RUNNING, state);
221 ASSERT_EQ(NodeStatus::RUNNING, state);
230 ASSERT_EQ(NodeStatus::SUCCESS, state);
231 ASSERT_EQ(NodeStatus::IDLE, fal_conditions.status());
232 ASSERT_EQ(NodeStatus::IDLE, condition_1.status());
233 ASSERT_EQ(NodeStatus::IDLE, condition_2.status());
234 ASSERT_EQ(NodeStatus::IDLE, fal_actions.status());
235 ASSERT_EQ(NodeStatus::IDLE, action_1.status());
236 ASSERT_EQ(NodeStatus::IDLE, action_2.status());
241 condition_1.setBoolean(
false);
244 ASSERT_EQ(NodeStatus::SUCCESS, state);
245 ASSERT_EQ(NodeStatus::IDLE, fal_conditions.status());
246 ASSERT_EQ(NodeStatus::IDLE, condition_1.status());
247 ASSERT_EQ(NodeStatus::IDLE, condition_2.status());
248 ASSERT_EQ(NodeStatus::IDLE, fal_actions.status());
249 ASSERT_EQ(NodeStatus::IDLE, action_1.status());
250 ASSERT_EQ(NodeStatus::IDLE, action_2.status());
255 condition_1.setBoolean(
false);
256 condition_2.setBoolean(
false);
259 ASSERT_EQ(NodeStatus::RUNNING, state);
260 ASSERT_EQ(NodeStatus::FAILURE, fal_conditions.status());
261 ASSERT_EQ(NodeStatus::IDLE, condition_1.status());
262 ASSERT_EQ(NodeStatus::IDLE, condition_2.status());
263 ASSERT_EQ(NodeStatus::RUNNING, fal_actions.status());
264 ASSERT_EQ(NodeStatus::RUNNING, action_1.status());
265 ASSERT_EQ(NodeStatus::IDLE, action_2.status());
270 condition_1.setBoolean(
false);
271 condition_2.setBoolean(
false);
274 condition_1.setBoolean(
true);
277 ASSERT_EQ(NodeStatus::RUNNING, state);
278 ASSERT_EQ(NodeStatus::FAILURE, fal_conditions.status());
279 ASSERT_EQ(NodeStatus::IDLE, condition_1.status());
280 ASSERT_EQ(NodeStatus::IDLE, condition_2.status());
281 ASSERT_EQ(NodeStatus::RUNNING, fal_actions.status());
282 ASSERT_EQ(NodeStatus::RUNNING, action_1.status());
283 ASSERT_EQ(NodeStatus::IDLE, action_2.status());
288 condition_1.setBoolean(
false);
289 condition_2.setBoolean(
false);
292 condition_2.setBoolean(
true);
295 ASSERT_EQ(NodeStatus::RUNNING, state);
296 ASSERT_EQ(NodeStatus::FAILURE, fal_conditions.status());
297 ASSERT_EQ(NodeStatus::IDLE, condition_1.status());
298 ASSERT_EQ(NodeStatus::IDLE, condition_2.status());
299 ASSERT_EQ(NodeStatus::RUNNING, fal_actions.status());
300 ASSERT_EQ(NodeStatus::RUNNING, action_1.status());
301 ASSERT_EQ(NodeStatus::IDLE, action_2.status());
306 action_1.setBoolean(
false);
307 action_2.setBoolean(
true);
308 condition_1.setBoolean(
false);
309 condition_2.setBoolean(
false);
314 std::this_thread::sleep_for(std::chrono::milliseconds(500));
317 ASSERT_EQ(NodeStatus::RUNNING, state);
318 ASSERT_EQ(NodeStatus::FAILURE, fal_conditions.status());
319 ASSERT_EQ(NodeStatus::IDLE, condition_1.status());
320 ASSERT_EQ(NodeStatus::IDLE, condition_2.status());
321 ASSERT_EQ(NodeStatus::RUNNING, fal_actions.status());
322 ASSERT_EQ(NodeStatus::FAILURE, action_1.status());
323 ASSERT_EQ(NodeStatus::RUNNING, action_2.status());
BT::AsyncActionTest action_1
BT::AsyncActionTest action
BT::ConditionTestNode condition
BT::ConditionTestNode condition
void setBoolean(bool boolean_value)
BT::AsyncActionTest action_2
~ComplexFallbackWithMemoryTest()
BT::ReactiveFallback root
BT::ConditionTestNode condition_1
BT::ConditionTestNode condition_2
void haltAllActions(TreeNode *root_node)
BT::FallbackNode fal_conditions
BT::AsyncActionTest action_1
BT::FallbackNode fal_actions
void addChild(TreeNode *child)
The method used to add nodes to the children vector.
The ReactiveFallback is similar to a ParallelNode. All the children are ticked from first to last: ...
NodeStatus status() const
BT::AsyncActionTest action
ComplexFallbackWithMemoryTest()
~SimpleFallbackWithMemoryTest()
BT::ConditionTestNode condition_2
virtual BT::NodeStatus executeTick()
The method that should be used to invoke tick() and setStatus();.
The FallbackNode is used to try different strategies, until one succeeds. If any child returns RUNNIN...
SimpleFallbackWithMemoryTest()
BT::ConditionTestNode condition_1
TEST_F(SimpleFallbackTest, ConditionTrue)