diff --git a/src/controller.cpp b/src/controller.cpp index c686d5f..b338d46 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -73,7 +73,14 @@ bool Controller::stop() { bool Controller::StandUp() { LOG_INFO("Standing up"); try { - return sc_ && sc_->StandUp() == 0; + if (!sc_) { + LOG_ERROR("SportClient not initialized"); + return false; + } + + int32_t result = sc_->StandUp(); + LOG_INFO("StandUp API returned: " + std::to_string(result)); + return result == 0; } catch (const std::exception& e) { LOG_ERROR("Stand up failed: " + std::string(e.what())); return false; @@ -83,7 +90,14 @@ bool Controller::StandUp() { bool Controller::StandDown() { LOG_INFO("Standing down"); try { - return sc_ && sc_->StandDown() == 0; + if (!sc_) { + LOG_ERROR("SportClient not initialized"); + return false; + } + + int32_t result = sc_->StandDown(); + LOG_INFO("StandDown API returned: " + std::to_string(result)); + return result == 0; } catch (const std::exception& e) { LOG_ERROR("Stand down failed: " + std::string(e.what())); return false; @@ -93,7 +107,14 @@ bool Controller::StandDown() { bool Controller::Sit() { LOG_INFO("Sitting"); try { - return sc_ && sc_->Sit() == 0; + if (!sc_) { + LOG_ERROR("SportClient not initialized"); + return false; + } + + int32_t result = sc_->Sit(); + LOG_INFO("Sit API returned: " + std::to_string(result)); + return result == 0; } catch (const std::exception& e) { LOG_ERROR("Sit failed: " + std::string(e.what())); return false; @@ -103,7 +124,14 @@ bool Controller::Sit() { bool Controller::Damp() { LOG_INFO("Damping"); try { - return sc_ && sc_->Damp() == 0; + if (!sc_) { + LOG_ERROR("SportClient not initialized"); + return false; + } + + int32_t result = sc_->Damp(); + LOG_INFO("Damp API returned: " + std::to_string(result)); + return result == 0; } catch (const std::exception& e) { LOG_ERROR("Damp failed: " + std::string(e.what())); return false; @@ -114,11 +142,14 @@ bool Controller::RecoveryStand() { LOG_INFO("Executing recovery stand"); try { - if (sc_) { - int32_t result = sc_->RecoveryStand(); - return result == 0; + if (!sc_) { + LOG_ERROR("SportClient not initialized"); + return false; } - return false; + + int32_t result = sc_->RecoveryStand(); + LOG_INFO("RecoveryStand API returned: " + std::to_string(result)); + return result == 0; } catch (const std::exception& e) { LOG_ERROR("Recovery stand failed: " + std::string(e.what())); return false; @@ -127,7 +158,14 @@ bool Controller::RecoveryStand() { bool Controller::StopMove() { try { - return sc_ && sc_->StopMove() == 0; + if (!sc_) { + LOG_ERROR("SportClient not initialized"); + return false; + } + + int32_t result = sc_->StopMove(); + LOG_INFO("StopMove API returned: " + std::to_string(result)); + return result == 0; } catch (const std::exception& e) { LOG_ERROR("Stop move failed: " + std::string(e.what())); return false; @@ -136,7 +174,14 @@ bool Controller::StopMove() { bool Controller::BalanceStand() { try { - return sc_ && sc_->BalanceStand() == 0; + if (!sc_) { + LOG_ERROR("SportClient not initialized"); + return false; + } + + int32_t result = sc_->BalanceStand(); + LOG_INFO("BalanceStand API returned: " + std::to_string(result)); + return result == 0; } catch (const std::exception& e) { LOG_ERROR("Balance stand failed: " + std::string(e.what())); return false; @@ -145,7 +190,14 @@ bool Controller::BalanceStand() { bool Controller::Dance1() { try { - return sc_ && sc_->Dance1() == 0; + if (!sc_) { + LOG_ERROR("SportClient not initialized"); + return false; + } + + int32_t result = sc_->Dance1(); + LOG_INFO("Dance1 API returned: " + std::to_string(result)); + return result == 0; } catch (const std::exception& e) { LOG_ERROR("Dance1 failed: " + std::string(e.what())); return false; @@ -154,7 +206,14 @@ bool Controller::Dance1() { bool Controller::Dance2() { try { - return sc_ && sc_->Dance2() == 0; + if (!sc_) { + LOG_ERROR("SportClient not initialized"); + return false; + } + + int32_t result = sc_->Dance2(); + LOG_INFO("Dance2 API returned: " + std::to_string(result)); + return result == 0; } catch (const std::exception& e) { LOG_ERROR("Dance2 failed: " + std::string(e.what())); return false; @@ -163,7 +222,14 @@ bool Controller::Dance2() { bool Controller::Hello() { try { - return sc_ && sc_->Hello() == 0; + if (!sc_) { + LOG_ERROR("SportClient not initialized"); + return false; + } + + int32_t result = sc_->Hello(); + LOG_INFO("Hello API returned: " + std::to_string(result)); + return result == 0; } catch (const std::exception& e) { LOG_ERROR("Hello failed: " + std::string(e.what())); return false;