From 3a4c1191c0257c62f9e1776213942077d85902d6 Mon Sep 17 00:00:00 2001 From: Alvin-lyq Date: Thu, 7 May 2026 15:38:13 +0800 Subject: [PATCH] pl debug --- src/autonomy/pl/src/pl.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/autonomy/pl/src/pl.cpp b/src/autonomy/pl/src/pl.cpp index e2d34a7..67851e8 100644 --- a/src/autonomy/pl/src/pl.cpp +++ b/src/autonomy/pl/src/pl.cpp @@ -411,9 +411,12 @@ void PL_ProcThread() task_status = TaskStatus::PATH_FINISHED; // 单路径完成 LOG_INFO("设置任务状态为 PATH_FINISHED"); - // 短暂休眠,确保车辆停稳 + // 短暂休眠,确保车辆停稳,同时检查退出标志 LOG_INFO("车辆停稳中..."); - sleep(3); + for (int i = 0; i < 30 && !thread_exit_flag; ++i) + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } continue; } else if (des_pos != -1) @@ -447,7 +450,20 @@ void PL_ProcThread() void* pl_thread(void* args) { (void)args; - sleep(3); + // 等待3秒,但每100ms检查一次退出标志 + for (int i = 0; i < 30 && !thread_exit_flag; ++i) + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + + if (thread_exit_flag) + { + LOG_INFO("pl_thread 收到退出信号,提前退出"); + return NULL; + } + + // 重置最近点索引,允许在新任务上自由搜索 + g_last_road_pos = -1; if (!load_path_file()) {