From 2d5f0adba8706c76bb7f96f9fea903fd29f7ef2b Mon Sep 17 00:00:00 2001 From: Misheel Bayartsengel Date: Wed, 27 Nov 2024 16:32:52 +0000 Subject: [PATCH] fix trajectory_executor unit test --- .../test/test_trajectory_executor.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/trajectory_executor/test/test_trajectory_executor.cpp b/trajectory_executor/test/test_trajectory_executor.cpp index c30c65acb0..5b6b271956 100644 --- a/trajectory_executor/test/test_trajectory_executor.cpp +++ b/trajectory_executor/test/test_trajectory_executor.cpp @@ -25,7 +25,7 @@ namespace trajectory_executor { /*! - * \brief Test that the trajectory executor will output the trajectory on + * \brief Test that the trajectory executor will output the trajectory on * the desired topic after receiving a trajectory plan for the Pure Pursuit controller plugin */ TEST(TrajectoryExecutorTest, test_emit_multiple) @@ -53,15 +53,17 @@ namespace trajectory_executor // Spin executor for 2 seconds auto end_time = std::chrono::system_clock::now() + std::chrono::seconds(2); - while(std::chrono::system_clock::now() < end_time){ - executor.spin_once(); + while(std::chrono::system_clock::now() < end_time) { + executor.spin_some(); + if(test_suite_node->msg_count >= 10) break; + rclcpp::sleep_for(std::chrono::milliseconds(100)); } ASSERT_LE(10, test_suite_node->msg_count) << "Failed to receive whole trajectory from TrajectoryExecutor node."; } /*! - * \brief Test that the trajectory executor will output the trajectory on + * \brief Test that the trajectory executor will output the trajectory on * the desired topic after receiving a trajectory plan for the PlatooningControlPlugin controller plugin */ TEST(TrajectoryExecutorTestSuite, test_emit_traj) { @@ -93,7 +95,7 @@ namespace trajectory_executor } ASSERT_GT(test_suite_node->msg_count, 0) << "Failed to receive whole trajectory from TrajectoryExecutor node."; - } + } /*! * \brief Test that the Trajectory Executor properly shuts down if it encounters a trajectory @@ -154,4 +156,4 @@ int main(int argc, char ** argv) rclcpp::shutdown(); return success; -} \ No newline at end of file +}