This commit is contained in:
Alvin-lyq 2026-05-07 14:04:11 +08:00
parent 2de676ef8a
commit cf512e711e

View File

@ -111,6 +111,8 @@ class pl_node : public rclcpp::Node
} }
else if (is_start == 1 && msg->task_status == 0) else if (is_start == 1 && msg->task_status == 0)
{ {
// 先设置 is_start=0防止定时器在 pthread_join 阻塞期间继续发布 RUNNING 状态
is_start = 0;
thread_exit_flag = 1; // 设置线程退出标志 thread_exit_flag = 1; // 设置线程退出标志
LOG_INFO("请求线程退出..."); LOG_INFO("请求线程退出...");
@ -118,7 +120,6 @@ class pl_node : public rclcpp::Node
pthread_join(pl_thread_t, NULL); pthread_join(pl_thread_t, NULL);
LOG_INFO("线程已正常退出"); LOG_INFO("线程已正常退出");
is_start = 0;
task_status = TaskStatus::COMPLETED; task_status = TaskStatus::COMPLETED;
} }
else if (is_start == 1 && msg->task_status == 1 && task_status == TaskStatus::COMPLETED) else if (is_start == 1 && msg->task_status == 1 && task_status == TaskStatus::COMPLETED)