modeCheck: add warning when RC enabled but not present

This commit is contained in:
Matthias Grob 2023-03-07 19:55:01 +01:00 committed by Beat Küng
parent 898c0ae5a8
commit 132e9d2439
3 changed files with 11 additions and 5 deletions

View File

@ -246,6 +246,8 @@ public:
void armingCheckFailure(NavModes required_modes, HealthComponentIndex component, uint32_t event_id,
const events::LogLevels &log_levels, const char *message);
void clearArmingBits(NavModes modes);
/**
* Clear can_run bits for certain modes. This will prevent mode switching and trigger failsafe if the
* mode is being run.
@ -302,8 +304,6 @@ private:
NavModes reportedModes(NavModes required_modes);
void clearArmingBits(NavModes modes);
NavModes getModeGroup(uint8_t nav_state) const;
friend class HealthAndArmingChecks;

View File

@ -144,6 +144,10 @@ void ModeChecks::checkAndReport(const Context &context, Report &reporter)
}
if (reporter.failsafeFlags().manual_control_signal_lost && reporter.failsafeFlags().mode_req_manual_control != 0) {
const bool rc_disabled = (_param_com_rc_in_mode.get() == 4);
NavModes nav_modes = rc_disabled ? (NavModes)reporter.failsafeFlags().mode_req_manual_control : NavModes::None;
events::LogLevel log_level = rc_disabled ? events::Log::Error : events::Log::Warning;
/* EVENT
* @description
* Connect and enable stick input or use autonomous mode.
@ -151,10 +155,11 @@ void ModeChecks::checkAndReport(const Context &context, Report &reporter)
* Sticks can be enabled via <param>COM_RC_IN_MODE</param> parameter.
* </profile>
*/
reporter.armingCheckFailure((NavModes)reporter.failsafeFlags().mode_req_manual_control,
reporter.armingCheckFailure(nav_modes,
health_component_t::remote_control,
events::ID("check_modes_manual_control"),
events::Log::Critical, "No manual control input");
log_level, "No manual control input");
reporter.clearArmingBits((NavModes)reporter.failsafeFlags().mode_req_manual_control);
reporter.clearCanRunBits((NavModes)reporter.failsafeFlags().mode_req_manual_control);
}

View File

@ -49,6 +49,7 @@ private:
void checkArmingRequirement(const Context &context, Report &reporter);
DEFINE_PARAMETERS_CUSTOM_PARENT(HealthAndArmingCheckBase,
(ParamBool<px4::params::COM_ARM_MIS_REQ>) _param_com_arm_mis_req
(ParamBool<px4::params::COM_ARM_MIS_REQ>) _param_com_arm_mis_req,
(ParamInt<px4::params::COM_RC_IN_MODE>) _param_com_rc_in_mode
);
};