@@ -250,6 +250,70 @@ TEST_F(RemoveInCollisionGoalsTestFixture,
250250 EXPECT_EQ (output_waypoint_statuses[3 ].waypoint_status , nav2_msgs::msg::WaypointStatus::SKIPPED);
251251}
252252
253+ TEST_F (RemoveInCollisionGoalsTestFixture,
254+ test_tick_remove_in_collision_goals_find_matching_waypoint_fail)
255+ {
256+ // create tree
257+ std::string xml_txt =
258+ R"(
259+ <root BTCPP_format="4">
260+ <BehaviorTree ID="MainTree">
261+ <RemoveInCollisionGoals service_name="/global_costmap/get_cost_global_costmap"
262+ input_goals="{goals}" output_goals="{goals}"
263+ cost_threshold="253"
264+ input_waypoint_statuses="{waypoint_statuses}"
265+ output_waypoint_statuses="{waypoint_statuses}"/>
266+ </BehaviorTree>
267+ </root>)" ;
268+
269+ tree_ = std::make_shared<BT::Tree>(factory_->createTreeFromText (xml_txt, config_->blackboard ));
270+
271+ // create new goal and set it on blackboard
272+ nav_msgs::msg::Goals poses;
273+ poses.goals .resize (4 );
274+ poses.goals [0 ].pose .position .x = 0.0 ;
275+ poses.goals [0 ].pose .position .y = 0.0 ;
276+
277+ poses.goals [1 ].pose .position .x = 0.5 ;
278+ poses.goals [1 ].pose .position .y = 0.0 ;
279+
280+ poses.goals [2 ].pose .position .x = 1.0 ;
281+ poses.goals [2 ].pose .position .y = 0.0 ;
282+
283+ poses.goals [3 ].pose .position .x = 2.0 ;
284+ poses.goals [3 ].pose .position .y = 0.0 ;
285+
286+ config_->blackboard ->set (" goals" , poses);
287+
288+ // create waypoint_statuses and set it on blackboard
289+ std::vector<nav2_msgs::msg::WaypointStatus> waypoint_statuses (poses.goals .size ());
290+ for (size_t i = 0 ; i < waypoint_statuses.size () ; ++i) {
291+ waypoint_statuses[i].waypoint_pose = poses.goals [i];
292+ waypoint_statuses[i].waypoint_index = i;
293+ }
294+ // inconsistency between waypoint_statuses and poses
295+ waypoint_statuses[3 ].waypoint_pose .pose .position .x = 0.0 ;
296+
297+ config_->blackboard ->set (" waypoint_statuses" , waypoint_statuses);
298+
299+ // tick until node is not running
300+ tree_->rootNode ()->executeTick ();
301+ while (tree_->rootNode ()->status () == BT::NodeStatus::RUNNING) {
302+ tree_->rootNode ()->executeTick ();
303+ }
304+
305+ // check that it failed and returned the original goals
306+ EXPECT_EQ (tree_->rootNode ()->status (), BT::NodeStatus::FAILURE);
307+ nav_msgs::msg::Goals output_poses;
308+ EXPECT_TRUE (config_->blackboard ->get (" goals" , output_poses));
309+
310+ EXPECT_EQ (output_poses.goals .size (), 4u );
311+ EXPECT_EQ (output_poses.goals [0 ], poses.goals [0 ]);
312+ EXPECT_EQ (output_poses.goals [1 ], poses.goals [1 ]);
313+ EXPECT_EQ (output_poses.goals [2 ], poses.goals [2 ]);
314+ EXPECT_EQ (output_poses.goals [3 ], poses.goals [3 ]);
315+ }
316+
253317TEST_F (RemoveInCollisionGoalsTestFixture, test_tick_remove_in_collision_goals_fail)
254318{
255319 // create tree
0 commit comments