Skip to content

Commit

Permalink
Fix enum for COM_RC_IN_MODE in failsafe
Browse files Browse the repository at this point in the history
add enum RcInMode

Signed-off-by: Beniamino Pozzan <beniamino.pozzan@phd.unipd.it>
  • Loading branch information
beniaminopozzan authored and bkueng committed Jun 19, 2023
1 parent 8fe65c6 commit 957a06a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/modules/commander/failsafe/failsafe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,
const bool rc_loss_ignored = rc_loss_ignored_mission || rc_loss_ignored_loiter || rc_loss_ignored_offboard ||
rc_loss_ignored_takeoff || ignore_link_failsafe || _manual_control_lost_at_arming;

if (_param_com_rc_in_mode.get() != int32_t(offboard_loss_failsafe_mode::Land_mode) && !rc_loss_ignored) {
if (_param_com_rc_in_mode.get() != int32_t(RcInMode::StickInputDisabled) && !rc_loss_ignored) {
CHECK_FAILSAFE(status_flags, manual_control_signal_lost,
fromNavDllOrRclActParam(_param_nav_rcl_act.get()).causedBy(Cause::ManualControlLoss));
}
Expand Down Expand Up @@ -382,7 +382,7 @@ void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,

// If manual control loss and GCS connection loss are disabled and we lose both command links and the mission finished,
// trigger RTL to avoid losing the vehicle
if ((_param_com_rc_in_mode.get() == int32_t(offboard_loss_failsafe_mode::Land_mode) || rc_loss_ignored_mission)
if ((_param_com_rc_in_mode.get() == int32_t(RcInMode::StickInputDisabled) || rc_loss_ignored_mission)
&& _param_nav_dll_act.get() == int32_t(gcs_connection_loss_failsafe_mode::Disabled)
&& state.mission_finished) {
_last_state_mission_control_lost = checkFailsafe(_caller_id_mission_control_lost, _last_state_mission_control_lost,
Expand Down
9 changes: 9 additions & 0 deletions src/modules/commander/failsafe/failsafe.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ class Failsafe : public FailsafeBase
Hold_mode = 2,
};

// COM_RC_IN_MODE parameter values
enum class RcInMode : int32_t {
RcTransmitterOnly = 0, // RC Transmitter only
JoystickOnly = 1, // Joystick only
RcAndJoystickWithFallback = 2, // RC And Joystick with fallback
RcOrJoystickKeepFirst = 3, // RC or Joystick keep first
StickInputDisabled = 4 // input disabled
};

static ActionOptions fromNavDllOrRclActParam(int param_value);

static ActionOptions fromGfActParam(int param_value);
Expand Down

0 comments on commit 957a06a

Please sign in to comment.