diff --git a/msg/FailsafeFlags.msg b/msg/FailsafeFlags.msg index e67041a57a..b697b7085b 100644 --- a/msg/FailsafeFlags.msg +++ b/msg/FailsafeFlags.msg @@ -17,6 +17,7 @@ uint32 mode_req_offboard_signal uint32 mode_req_home_position uint32 mode_req_wind_and_flight_time_compliance # if set, mode cannot be entered if wind or flight time limit exceeded uint32 mode_req_prevent_arming # if set, cannot arm while in this mode +uint32 mode_req_manual_control uint32 mode_req_other # other requirements, not covered above (for external modes) diff --git a/src/modules/commander/HealthAndArmingChecks/checks/modeCheck.cpp b/src/modules/commander/HealthAndArmingChecks/checks/modeCheck.cpp index 7ae7614819..7f2e981532 100644 --- a/src/modules/commander/HealthAndArmingChecks/checks/modeCheck.cpp +++ b/src/modules/commander/HealthAndArmingChecks/checks/modeCheck.cpp @@ -143,6 +143,21 @@ void ModeChecks::checkAndReport(const Context &context, Report &reporter) reporter.clearCanRunBits((NavModes)reporter.failsafeFlags().mode_req_home_position); } + if (reporter.failsafeFlags().manual_control_signal_lost && reporter.failsafeFlags().mode_req_manual_control != 0) { + /* EVENT + * @description + * Connect and enable stick input or use autonomous mode. + * + * Sticks can be enabled via COM_RC_IN_MODE parameter. + * + */ + reporter.armingCheckFailure((NavModes)reporter.failsafeFlags().mode_req_manual_control, + health_component_t::remote_control, + events::ID("check_modes_manual_control"), + events::Log::Critical, "No manual control input"); + reporter.clearCanRunBits((NavModes)reporter.failsafeFlags().mode_req_manual_control); + } + if (reporter.failsafeFlags().mode_req_other != 0) { // Here we expect there is already an event reported for the failing check (this is for external modes) reporter.clearCanRunBits((NavModes)reporter.failsafeFlags().mode_req_other); diff --git a/src/modules/commander/ModeUtil/mode_requirements.cpp b/src/modules/commander/ModeUtil/mode_requirements.cpp index fc48038867..9314f5ca84 100644 --- a/src/modules/commander/ModeUtil/mode_requirements.cpp +++ b/src/modules/commander/ModeUtil/mode_requirements.cpp @@ -56,19 +56,23 @@ void getModeRequirements(uint8_t vehicle_type, failsafe_flags_s &flags) flags.mode_req_home_position = 0; flags.mode_req_wind_and_flight_time_compliance = 0; flags.mode_req_prevent_arming = 0; + flags.mode_req_manual_control = 0; flags.mode_req_other = 0; // NAVIGATION_STATE_MANUAL + setRequirement(vehicle_status_s::NAVIGATION_STATE_MANUAL, flags.mode_req_manual_control); // NAVIGATION_STATE_ALTCTL setRequirement(vehicle_status_s::NAVIGATION_STATE_ALTCTL, flags.mode_req_angular_velocity); setRequirement(vehicle_status_s::NAVIGATION_STATE_ALTCTL, flags.mode_req_attitude); setRequirement(vehicle_status_s::NAVIGATION_STATE_ALTCTL, flags.mode_req_local_alt); + setRequirement(vehicle_status_s::NAVIGATION_STATE_ALTCTL, flags.mode_req_manual_control); // NAVIGATION_STATE_POSCTL setRequirement(vehicle_status_s::NAVIGATION_STATE_POSCTL, flags.mode_req_angular_velocity); setRequirement(vehicle_status_s::NAVIGATION_STATE_POSCTL, flags.mode_req_attitude); setRequirement(vehicle_status_s::NAVIGATION_STATE_POSCTL, flags.mode_req_local_position_relaxed); + setRequirement(vehicle_status_s::NAVIGATION_STATE_POSCTL, flags.mode_req_manual_control); if (vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING) { setRequirement(vehicle_status_s::NAVIGATION_STATE_POSCTL, flags.mode_req_global_position); @@ -104,6 +108,7 @@ void getModeRequirements(uint8_t vehicle_type, failsafe_flags_s &flags) // NAVIGATION_STATE_ACRO setRequirement(vehicle_status_s::NAVIGATION_STATE_ACRO, flags.mode_req_angular_velocity); + setRequirement(vehicle_status_s::NAVIGATION_STATE_ACRO, flags.mode_req_manual_control); // NAVIGATION_STATE_DESCEND setRequirement(vehicle_status_s::NAVIGATION_STATE_DESCEND, flags.mode_req_angular_velocity); @@ -122,6 +127,7 @@ void getModeRequirements(uint8_t vehicle_type, failsafe_flags_s &flags) // NAVIGATION_STATE_STAB setRequirement(vehicle_status_s::NAVIGATION_STATE_STAB, flags.mode_req_angular_velocity); setRequirement(vehicle_status_s::NAVIGATION_STATE_STAB, flags.mode_req_attitude); + setRequirement(vehicle_status_s::NAVIGATION_STATE_STAB, flags.mode_req_manual_control); // NAVIGATION_STATE_AUTO_TAKEOFF setRequirement(vehicle_status_s::NAVIGATION_STATE_AUTO_TAKEOFF, flags.mode_req_angular_velocity); diff --git a/src/modules/commander/failsafe/framework.cpp b/src/modules/commander/failsafe/framework.cpp index ac318e2602..9ef1a232c1 100644 --- a/src/modules/commander/failsafe/framework.cpp +++ b/src/modules/commander/failsafe/framework.cpp @@ -656,6 +656,7 @@ bool FailsafeBase::modeCanRun(const failsafe_flags_s &status_flags, uint8_t mode (!status_flags.auto_mission_missing || ((status_flags.mode_req_mission & mode_mask) == 0)) && (!status_flags.offboard_control_signal_lost || ((status_flags.mode_req_offboard_signal & mode_mask) == 0)) && (!status_flags.home_position_invalid || ((status_flags.mode_req_home_position & mode_mask) == 0)) && + (!status_flags.manual_control_signal_lost || ((status_flags.mode_req_manual_control & mode_mask) == 0)) && ((status_flags.mode_req_other & mode_mask) == 0); }