From 347f9807948198f02a01ceadf843a325adb9be91 Mon Sep 17 00:00:00 2001 From: lyq Date: Mon, 9 Feb 2026 13:50:34 +0800 Subject: [PATCH] format task node --- .../task_manager/src/task_manager_main.cpp | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/communication/task_manager/src/task_manager_main.cpp b/src/communication/task_manager/src/task_manager_main.cpp index b95a8fa..4921000 100644 --- a/src/communication/task_manager/src/task_manager_main.cpp +++ b/src/communication/task_manager/src/task_manager_main.cpp @@ -359,32 +359,39 @@ int handleMqttMessage(char* topicName, int topicLen, MQTTClient_message* message void try_subscribe_task_topic() { - if (!identity_ready.load()) { + if (!identity_ready.load()) + { LOG_DEBUG("[TASK] Identity not ready, skipping subscribe"); return; } - if (mqtt_topic_sub_task.empty()) { + if (mqtt_topic_sub_task.empty()) + { LOG_DEBUG("[TASK] MQTT topic not configured, skipping subscribe"); return; } - if (!mqtt_manager.isConnected()) { + if (!mqtt_manager.isConnected()) + { LOG_DEBUG("[TASK] MQTT not connected, skipping subscribe"); subscribed.store(false); // 确保下次可以重试 return; } - if (subscribed.load()) { + if (subscribed.load()) + { LOG_DEBUG("[TASK] Already subscribed, skipping"); return; } LOG_INFO("[TASK] subscribe MQTT topic: %s", mqtt_topic_sub_task.c_str()); bool success = mqtt_manager.subscribe(mqtt_topic_sub_task, 0); - if (success) { + if (success) + { subscribed.store(true); LOG_INFO("[TASK] Subscribe successful"); - } else { + } + else + { LOG_ERROR("[TASK] Subscribe failed, will retry later"); subscribed.store(false); // 订阅失败,允许重试 } @@ -442,7 +449,8 @@ class TaskManagerNode : public rclcpp::Node vid = msg->vid; identity_ready.store(!vid.empty()); - if (!identity_ready.load()) { + if (!identity_ready.load()) + { LOG_WARN("[TASK] Invalid VID received: %s", msg->vid.c_str()); return; }