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.
This commit is contained in:
2025-09-22 19:50:39 +08:00
parent 20d75ca377
commit 4cce0b69c8
2 changed files with 53 additions and 47 deletions

View File

@@ -5,7 +5,7 @@
#include "logger.hpp" #include "logger.hpp"
#include "mqtt.hpp" #include "mqtt.hpp"
#include "navigation.hpp" #include "navigation.hpp"
#include "low_controller.hpp" // #include "low_controller.hpp"
#include <memory> #include <memory>
#include <atomic> #include <atomic>
@@ -47,7 +47,7 @@ public:
private: private:
std::string generateRandomClientId() const; std::string generateRandomClientId() const;
std::unique_ptr<Controller> controller_; std::unique_ptr<Controller> controller_;
std::unique_ptr<LowController> low_controller_; // std::unique_ptr<LowController> low_controller_;
std::unique_ptr<Navigation> navigation_; std::unique_ptr<Navigation> navigation_;
std::unique_ptr<unitree::robot::go2::RobotStateClient> rsc_; std::unique_ptr<unitree::robot::go2::RobotStateClient> rsc_;
std::unique_ptr<MqttClient> mqttClient_; std::unique_ptr<MqttClient> mqttClient_;

View File

@@ -43,10 +43,9 @@ CustomRobot::~CustomRobot() {
controller_.reset(); controller_.reset();
} }
if (low_controller_) { // 屏蔽与low_controller_相关的代码
low_controller_->shutdown(); // low_controller_ = std::make_unique<LowController>();
low_controller_.reset(); // low_controller_->initialize();
}
if (rsc_) { if (rsc_) {
rsc_.reset(); rsc_.reset();
@@ -71,8 +70,9 @@ bool CustomRobot::initialize() {
controller_ = std::make_unique<Controller>(); controller_ = std::make_unique<Controller>();
controller_->initialize(); controller_->initialize();
low_controller_ = std::make_unique<LowController>(); // 屏蔽与low_controller_相关的代码
low_controller_->initialize(); // low_controller_ = std::make_unique<LowController>();
// low_controller_->initialize();
navigation_ = std::make_unique<Navigation>(); navigation_ = std::make_unique<Navigation>();
navigation_->Init(); navigation_->Init();
@@ -124,10 +124,11 @@ bool CustomRobot::start() {
return false; return false;
} }
if (!low_controller_->start()) { // 屏蔽与low_controller_相关的代码
LOG_ERROR("Failed to start low-level controller"); // if (!low_controller_->start()) {
return false; // LOG_ERROR("Failed to start low-level controller");
} // return false;
// }
running_ = true; running_ = true;
LOG_INFO("CustomRobot started successfully"); 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) bool CustomRobot::processLowCmd(const std::string& cmd, const nlohmann::json& message)
{ {
if (!low_controller_) // 屏蔽与low_controller_相关的代码
{ // if (!low_controller_)
LOG_ERROR("LowController not initialized"); // {
return false; // 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;
// }
try // 临时返回false直到重新实现功能
{ LOG_WARN("LowController functionality is currently disabled");
if (cmd == "requestAutoCharge")
{
if (!message.contains("param") || !message["param"].contains("enable"))
{
LOG_ERROR("requestAutoCharge cmd missing 'enable' parameter");
return false; 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;
}
} }
bool CustomRobot::processOacCmd(const std::string& cmd, const nlohmann::json& message) { bool CustomRobot::processOacCmd(const std::string& cmd, const nlohmann::json& message) {