From 4cce0b69c871e0b533b8001df917a3639cfb2ab3 Mon Sep 17 00:00:00 2001 From: Sucan126 <632190820@qq.com> Date: Mon, 22 Sep 2025 19:50:39 +0800 Subject: [PATCH] refactor(custom_robot): Disable LowController functionality temporarily - Commented out all references to LowController in custom_robot.hpp and custom_robot.cpp to disable its functionality. - Added warning log in processLowCmd to indicate that LowController functionality is currently disabled until re-implementation. --- include/custom_robot.hpp | 4 +- src/custom_robot.cpp | 96 +++++++++++++++++++++------------------- 2 files changed, 53 insertions(+), 47 deletions(-) diff --git a/include/custom_robot.hpp b/include/custom_robot.hpp index d8b7c3c..076b16b 100644 --- a/include/custom_robot.hpp +++ b/include/custom_robot.hpp @@ -5,7 +5,7 @@ #include "logger.hpp" #include "mqtt.hpp" #include "navigation.hpp" -#include "low_controller.hpp" +// #include "low_controller.hpp" #include #include @@ -47,7 +47,7 @@ public: private: std::string generateRandomClientId() const; std::unique_ptr controller_; - std::unique_ptr low_controller_; + // std::unique_ptr low_controller_; std::unique_ptr navigation_; std::unique_ptr rsc_; std::unique_ptr mqttClient_; diff --git a/src/custom_robot.cpp b/src/custom_robot.cpp index 5ebb37e..5ab545d 100644 --- a/src/custom_robot.cpp +++ b/src/custom_robot.cpp @@ -43,10 +43,9 @@ CustomRobot::~CustomRobot() { controller_.reset(); } - if (low_controller_) { - low_controller_->shutdown(); - low_controller_.reset(); - } + // 屏蔽与low_controller_相关的代码 + // low_controller_ = std::make_unique(); + // low_controller_->initialize(); if (rsc_) { rsc_.reset(); @@ -71,8 +70,9 @@ bool CustomRobot::initialize() { controller_ = std::make_unique(); controller_->initialize(); - low_controller_ = std::make_unique(); - low_controller_->initialize(); + // 屏蔽与low_controller_相关的代码 + // low_controller_ = std::make_unique(); + // low_controller_->initialize(); navigation_ = std::make_unique(); navigation_->Init(); @@ -124,10 +124,11 @@ bool CustomRobot::start() { return false; } - if (!low_controller_->start()) { - LOG_ERROR("Failed to start low-level controller"); - return false; - } + // 屏蔽与low_controller_相关的代码 + // if (!low_controller_->start()) { + // LOG_ERROR("Failed to start low-level controller"); + // return false; + // } running_ = true; LOG_INFO("CustomRobot started successfully"); @@ -295,41 +296,46 @@ void CustomRobot::processCmd(const nlohmann::json& message) { bool CustomRobot::processLowCmd(const std::string& cmd, const nlohmann::json& message) { - if (!low_controller_) - { - LOG_ERROR("LowController not initialized"); - return false; - } - - try - { - if (cmd == "requestAutoCharge") - { - if (!message.contains("param") || !message["param"].contains("enable")) - { - LOG_ERROR("requestAutoCharge cmd missing 'enable' parameter"); - return false; - } - bool enable = message["param"]["enable"]; - low_controller_->requestAutoCharge(enable); - return true; - } - else if (cmd == "powerOff") - { - low_controller_->powerOff(); - return true; - } - else - { - LOG_ERROR("Unknown Low command: %s", cmd.c_str()); - return false; - } - } - catch (const std::exception& e) - { - LOG_ERROR("Error executing Low command %s: %s", cmd.c_str(), e.what()); - return false; - } + // 屏蔽与low_controller_相关的代码 + // if (!low_controller_) + // { + // LOG_ERROR("LowController not initialized"); + // return false; + // } + // + // try + // { + // if (cmd == "requestAutoCharge") + // { + // if (!message.contains("param") || !message["param"].contains("enable")) + // { + // LOG_ERROR("requestAutoCharge cmd missing 'enable' parameter"); + // return false; + // } + // bool enable = message["param"]["enable"]; + // low_controller_->requestAutoCharge(enable); + // return true; + // } + // else if (cmd == "powerOff") + // { + // low_controller_->powerOff(); + // return true; + // } + // else + // { + // LOG_ERROR("Unknown Low command: %s", cmd.c_str()); + // return false; + // } + // } + // catch (const std::exception& e) + // { + // LOG_ERROR("Error executing Low command %s: %s", cmd.c_str(), e.what()); + // return false; + // } + + // 临时返回false,直到重新实现功能 + LOG_WARN("LowController functionality is currently disabled"); + return false; } bool CustomRobot::processOacCmd(const std::string& cmd, const nlohmann::json& message) {