From 3a209734de8d9bde0c6fbeb0c41c5a7bec882050 Mon Sep 17 00:00:00 2001 From: Sucan126 <632190820@qq.com> Date: Tue, 30 Sep 2025 16:38:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(robot):=20=E6=B7=BB=E5=8A=A0=E7=9B=91?= =?UTF-8?q?=E6=8E=A7=E6=A8=A1=E5=9D=97=E5=88=B0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在自定义机器人中添加Monitor模块,用于监控机器人状态。包括在头文件中添加Monitor成员变量声明,在实现文件中添加初始化和资源释放逻辑。 --- include/custom_robot.hpp | 2 ++ src/custom_robot.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/custom_robot.hpp b/include/custom_robot.hpp index 47c823e..ed31a91 100644 --- a/include/custom_robot.hpp +++ b/include/custom_robot.hpp @@ -6,6 +6,7 @@ #include "mqtt.hpp" #include "navigation.hpp" #include "recharge.hpp" +#include "monitor.hpp" // #include "low_controller.hpp" #include @@ -59,6 +60,7 @@ private: std::unique_ptr rsc_; std::unique_ptr mqttClient_; std::unique_ptr recharge_; + std::unique_ptr monitor_; CustomConfig config_; std::atomic running_; diff --git a/src/custom_robot.cpp b/src/custom_robot.cpp index 6961330..50e6910 100644 --- a/src/custom_robot.cpp +++ b/src/custom_robot.cpp @@ -66,6 +66,10 @@ CustomRobot::~CustomRobot() { recharge_.reset(); } + if (monitor_) { + monitor_.reset(); + } + try { unitree::robot::ChannelFactory::Instance()->Release(); LOG_INFO("ChannelFactory released"); @@ -94,6 +98,9 @@ bool CustomRobot::initialize() { recharge_ = std::make_unique(); recharge_->Init(); + monitor_ = std::make_unique(); + monitor_->initialize(); + if (!initializeMqtt()) { LOG_ERROR("Failed to initialize MQTT client"); return false;