From e0eee6340d37ba2b3e5e770ecbfb0089934207ab Mon Sep 17 00:00:00 2001 From: Jacob Moore Date: Tue, 17 Dec 2024 09:33:51 -0700 Subject: [PATCH] added error checking for RC F axis selection --- src/command_manager.cpp | 19 ++++++++++++++++++- src/mixer.cpp | 5 +++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/command_manager.cpp b/src/command_manager.cpp index 663ae048..ed1bc4ff 100644 --- a/src/command_manager.cpp +++ b/src/command_manager.cpp @@ -99,7 +99,12 @@ void CommandManager::init_failsafe() case Y_AXIS: multirotor_failsafe_command_.Fy.value = failsafe_thr_param; break; + case Z_AXIS: + multirotor_failsafe_command_.Fz.value = failsafe_thr_param; + break; default: + RF_.comm_manager_.log(CommLinkInterface::LogSeverity::LOG_WARNING, + "Invalid RC F axis. Defaulting to z-axis."); multirotor_failsafe_command_.Fz.value = failsafe_thr_param; break; } @@ -130,7 +135,14 @@ void CommandManager::interpret_rc(void) rc_command_.Fy.value = RF_.rc_.stick(RC::STICK_F); rc_command_.Fz.value = 0.0; break; - default: // RC F = Z axis + case Z_AXIS: + rc_command_.Fx.value = 0.0; + rc_command_.Fy.value = 0.0; + rc_command_.Fz.value = RF_.rc_.stick(RC::STICK_F); + break; + default: + RF_.comm_manager_.log(CommLinkInterface::LogSeverity::LOG_WARNING, + "Invalid RC F axis. Defaulting to z-axis."); rc_command_.Fx.value = 0.0; rc_command_.Fy.value = 0.0; rc_command_.Fz.value = RF_.rc_.stick(RC::STICK_F); @@ -232,7 +244,12 @@ bool CommandManager::do_throttle_muxing(void) case Y_AXIS: selected_channel = MUX_FY; break; + case Z_AXIS: + selected_channel = MUX_FZ; + break; default: + RF_.comm_manager_.log(CommLinkInterface::LogSeverity::LOG_WARNING, + "Invalid RC F axis. Defaulting to z-axis."); selected_channel = MUX_FZ; break; } diff --git a/src/mixer.cpp b/src/mixer.cpp index a274eef0..ec954c30 100644 --- a/src/mixer.cpp +++ b/src/mixer.cpp @@ -661,7 +661,12 @@ void Mixer::mix_multirotor() case Y_AXIS: throttle_command = commands.Fy; break; + case Z_AXIS: + throttle_command = commands.Fz; + break; default: + RF_.comm_manager_.log(CommLinkInterface::LogSeverity::LOG_WARNING, + "Invalid RC F axis. Defaulting to z-axis."); throttle_command = commands.Fz; break; }