@@ -39,6 +39,7 @@ class RemovePassedGoalsTestFixture : public ::testing::Test
3939
4040 config_ = new BT::NodeConfiguration ();
4141 transform_handler_ = std::make_shared<nav2_behavior_tree::TransformHandler>(node_);
42+ transform_handler_->activate ();
4243
4344 // Create the blackboard that will be shared by all of the nodes in the tree
4445 config_->blackboard = BT::Blackboard::create ();
@@ -98,7 +99,6 @@ TEST_F(RemovePassedGoalsTestFixture, test_tick)
9899 pose.position .x = 0.25 ;
99100 pose.position .y = 0.0 ;
100101
101- transform_handler_->activate ();
102102 transform_handler_->waitForTransform ();
103103 transform_handler_->updateRobotPose (pose);
104104
@@ -144,6 +144,77 @@ TEST_F(RemovePassedGoalsTestFixture, test_tick)
144144 EXPECT_EQ (output_poses.goals [1 ], poses.goals [3 ]);
145145}
146146
147+ TEST_F (RemovePassedGoalsTestFixture,
148+ test_tick_remove_passed_goals_success_and_output_waypoint_statuses)
149+ {
150+ geometry_msgs::msg::Pose pose;
151+ pose.position .x = 0.25 ;
152+ pose.position .y = 0.0 ;
153+
154+ transform_handler_->waitForTransform ();
155+ transform_handler_->updateRobotPose (pose);
156+
157+ // create tree
158+ std::string xml_txt =
159+ R"(
160+ <root BTCPP_format="4">
161+ <BehaviorTree ID="MainTree">
162+ <RemovePassedGoals radius="0.5" input_goals="{goals}" output_goals="{goals}"
163+ input_waypoint_statuses="{waypoint_statuses}"
164+ output_waypoint_statuses="{waypoint_statuses}"/>
165+ </BehaviorTree>
166+ </root>)" ;
167+
168+ tree_ = std::make_shared<BT::Tree>(factory_->createTreeFromText (xml_txt, config_->blackboard ));
169+
170+ // create new goal and set it on blackboard
171+ nav_msgs::msg::Goals poses;
172+ poses.goals .resize (4 );
173+ poses.goals [0 ].pose .position .x = 0.0 ;
174+ poses.goals [0 ].pose .position .y = 0.0 ;
175+
176+ poses.goals [1 ].pose .position .x = 0.5 ;
177+ poses.goals [1 ].pose .position .y = 0.0 ;
178+
179+ poses.goals [2 ].pose .position .x = 1.0 ;
180+ poses.goals [2 ].pose .position .y = 0.0 ;
181+
182+ poses.goals [3 ].pose .position .x = 2.0 ;
183+ poses.goals [3 ].pose .position .y = 0.0 ;
184+
185+ config_->blackboard ->set (" goals" , poses);
186+
187+ // create waypoint_statuses and set it on blackboard
188+ std::vector<nav2_msgs::msg::WaypointStatus> waypoint_statuses (poses.goals .size ());
189+ for (size_t i = 0 ; i < waypoint_statuses.size () ; ++i) {
190+ waypoint_statuses[i].waypoint_pose = poses.goals [i];
191+ waypoint_statuses[i].waypoint_index = i;
192+ }
193+ config_->blackboard ->set (" waypoint_statuses" , waypoint_statuses);
194+
195+ // tick until node succeeds
196+ while (tree_->rootNode ()->status () != BT::NodeStatus::SUCCESS) {
197+ tree_->rootNode ()->executeTick ();
198+ }
199+
200+ // check that it removed the point in range
201+ nav_msgs::msg::Goals output_poses;
202+ EXPECT_TRUE (config_->blackboard ->get (" goals" , output_poses));
203+
204+ EXPECT_EQ (output_poses.goals .size (), 2u );
205+ EXPECT_EQ (output_poses.goals [0 ], poses.goals [2 ]);
206+ EXPECT_EQ (output_poses.goals [1 ], poses.goals [3 ]);
207+
208+ // check the waypoint_statuses
209+ std::vector<nav2_msgs::msg::WaypointStatus> output_waypoint_statuses;
210+ EXPECT_TRUE (config_->blackboard ->get (" waypoint_statuses" , output_waypoint_statuses));
211+ EXPECT_EQ (output_waypoint_statuses.size (), 4u );
212+ EXPECT_EQ (output_waypoint_statuses[0 ].waypoint_status , nav2_msgs::msg::WaypointStatus::COMPLETED);
213+ EXPECT_EQ (output_waypoint_statuses[1 ].waypoint_status , nav2_msgs::msg::WaypointStatus::COMPLETED);
214+ EXPECT_EQ (output_waypoint_statuses[2 ].waypoint_status , nav2_msgs::msg::WaypointStatus::PENDING);
215+ EXPECT_EQ (output_waypoint_statuses[3 ].waypoint_status , nav2_msgs::msg::WaypointStatus::PENDING);
216+ }
217+
147218int main (int argc, char ** argv)
148219{
149220 ::testing::InitGoogleTest (&argc, argv);
0 commit comments