Skip to content

Commit

Permalink
added error checking for RC F axis selection
Browse files Browse the repository at this point in the history
  • Loading branch information
JMoore5353 committed Dec 17, 2024
1 parent ff54382 commit e0eee63
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/command_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions src/mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit e0eee63

Please sign in to comment.