From 2de8f53ae2ab9a15ba06d5d0ec1782d796683489 Mon Sep 17 00:00:00 2001 From: Sucan126 <632190820@qq.com> Date: Tue, 9 Sep 2025 14:33:33 +0800 Subject: [PATCH] Refactor switch state handling in CustomRobot::processOacCmd method. Updated logic to store the toggled state in a variable before passing it to SwitchSet, improving code clarity and maintainability. --- src/custom_robot.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/custom_robot.cpp b/src/custom_robot.cpp index 7616922..fa205a4 100644 --- a/src/custom_robot.cpp +++ b/src/custom_robot.cpp @@ -271,7 +271,8 @@ bool CustomRobot::processOacCmd(const std::string& cmd, const nlohmann::json& me } LOG_INFO("Current switch state: " + std::string(currentEnable ? "true" : "false")); // switch to opposite state - return controller_->SwitchSet(!currentEnable); + bool enable = !currentEnable; + return controller_->SwitchSet(enable); } else if (cmd == "SwitchGet") { bool enable = false;