@@ -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,75 @@ 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}" waypoint_statuses_id="waypoint_statuses"/>
163+ </BehaviorTree>
164+ </root>)" ;
165+
166+ tree_ = std::make_shared<BT::Tree>(factory_->createTreeFromText (xml_txt, config_->blackboard ));
167+
168+ // create new goal and set it on blackboard
169+ nav_msgs::msg::Goals poses;
170+ poses.goals .resize (4 );
171+ poses.goals [0 ].pose .position .x = 0.0 ;
172+ poses.goals [0 ].pose .position .y = 0.0 ;
173+
174+ poses.goals [1 ].pose .position .x = 0.5 ;
175+ poses.goals [1 ].pose .position .y = 0.0 ;
176+
177+ poses.goals [2 ].pose .position .x = 1.0 ;
178+ poses.goals [2 ].pose .position .y = 0.0 ;
179+
180+ poses.goals [3 ].pose .position .x = 2.0 ;
181+ poses.goals [3 ].pose .position .y = 0.0 ;
182+
183+ config_->blackboard ->set (" goals" , poses);
184+
185+ // create waypoint_statuses and set it on blackboard
186+ std::vector<nav2_msgs::msg::WaypointStatus> waypoint_statuses (poses.goals .size ());
187+ for (size_t i = 0 ; i < waypoint_statuses.size () ; ++i) {
188+ waypoint_statuses[i].goal = poses.goals [i];
189+ waypoint_statuses[i].index = i;
190+ }
191+ config_->blackboard ->set (" waypoint_statuses" , waypoint_statuses);
192+
193+ // tick until node succeeds
194+ while (tree_->rootNode ()->status () != BT::NodeStatus::SUCCESS) {
195+ tree_->rootNode ()->executeTick ();
196+ }
197+
198+ // check that it removed the point in range
199+ nav_msgs::msg::Goals output_poses;
200+ EXPECT_TRUE (config_->blackboard ->get (" goals" , output_poses));
201+
202+ EXPECT_EQ (output_poses.goals .size (), 2u );
203+ EXPECT_EQ (output_poses.goals [0 ], poses.goals [2 ]);
204+ EXPECT_EQ (output_poses.goals [1 ], poses.goals [3 ]);
205+
206+ // check the waypoint_statuses
207+ std::vector<nav2_msgs::msg::WaypointStatus> output_waypoint_statuses;
208+ EXPECT_TRUE (config_->blackboard ->get (" waypoint_statuses" , output_waypoint_statuses));
209+ EXPECT_EQ (output_waypoint_statuses.size (), 4u );
210+ EXPECT_EQ (output_waypoint_statuses[0 ].waypoint_status , nav2_msgs::msg::WaypointStatus::COMPLETED);
211+ EXPECT_EQ (output_waypoint_statuses[1 ].waypoint_status , nav2_msgs::msg::WaypointStatus::COMPLETED);
212+ EXPECT_EQ (output_waypoint_statuses[2 ].waypoint_status , nav2_msgs::msg::WaypointStatus::PENDING);
213+ EXPECT_EQ (output_waypoint_statuses[3 ].waypoint_status , nav2_msgs::msg::WaypointStatus::PENDING);
214+ }
215+
147216int main (int argc, char ** argv)
148217{
149218 ::testing::InitGoogleTest (&argc, argv);
0 commit comments