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:
@@ -43,10 +43,9 @@ CustomRobot::~CustomRobot() {
|
||||
controller_.reset();
|
||||
}
|
||||
|
||||
if (low_controller_) {
|
||||
low_controller_->shutdown();
|
||||
low_controller_.reset();
|
||||
}
|
||||
// 屏蔽与low_controller_相关的代码
|
||||
// low_controller_ = std::make_unique<LowController>();
|
||||
// low_controller_->initialize();
|
||||
|
||||
if (rsc_) {
|
||||
rsc_.reset();
|
||||
@@ -71,8 +70,9 @@ bool CustomRobot::initialize() {
|
||||
controller_ = std::make_unique<Controller>();
|
||||
controller_->initialize();
|
||||
|
||||
low_controller_ = std::make_unique<LowController>();
|
||||
low_controller_->initialize();
|
||||
// 屏蔽与low_controller_相关的代码
|
||||
// low_controller_ = std::make_unique<LowController>();
|
||||
// low_controller_->initialize();
|
||||
|
||||
navigation_ = std::make_unique<Navigation>();
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user