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:
@@ -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_;
|
||||||
|
|||||||
@@ -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
|
//
|
||||||
{
|
// try
|
||||||
if (cmd == "requestAutoCharge")
|
// {
|
||||||
{
|
// if (cmd == "requestAutoCharge")
|
||||||
if (!message.contains("param") || !message["param"].contains("enable"))
|
// {
|
||||||
{
|
// if (!message.contains("param") || !message["param"].contains("enable"))
|
||||||
LOG_ERROR("requestAutoCharge cmd missing 'enable' parameter");
|
// {
|
||||||
return false;
|
// LOG_ERROR("requestAutoCharge cmd missing 'enable' parameter");
|
||||||
}
|
// return false;
|
||||||
bool enable = message["param"]["enable"];
|
// }
|
||||||
low_controller_->requestAutoCharge(enable);
|
// bool enable = message["param"]["enable"];
|
||||||
return true;
|
// low_controller_->requestAutoCharge(enable);
|
||||||
}
|
// return true;
|
||||||
else if (cmd == "powerOff")
|
// }
|
||||||
{
|
// else if (cmd == "powerOff")
|
||||||
low_controller_->powerOff();
|
// {
|
||||||
return true;
|
// low_controller_->powerOff();
|
||||||
}
|
// return true;
|
||||||
else
|
// }
|
||||||
{
|
// else
|
||||||
LOG_ERROR("Unknown Low command: %s", cmd.c_str());
|
// {
|
||||||
return false;
|
// LOG_ERROR("Unknown Low command: %s", cmd.c_str());
|
||||||
}
|
// return false;
|
||||||
}
|
// }
|
||||||
catch (const std::exception& e)
|
// }
|
||||||
{
|
// catch (const std::exception& e)
|
||||||
LOG_ERROR("Error executing Low command %s: %s", cmd.c_str(), e.what());
|
// {
|
||||||
return false;
|
// 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) {
|
bool CustomRobot::processOacCmd(const std::string& cmd, const nlohmann::json& message) {
|
||||||
|
|||||||
Reference in New Issue
Block a user