refactor(modeCheck): inline checkArmingRequirement() function

This commit is contained in:
Matthias Grob
2026-04-30 00:10:58 +02:00
parent 2b97e2269b
commit 66af778f7f
2 changed files with 9 additions and 16 deletions
@@ -36,7 +36,15 @@
void ModeChecks::checkAndReport(const Context &context, Report &reporter)
{
if (!context.isArmed()) {
checkArmingRequirement(context, reporter);
if (reporter.failsafeFlags().mode_req_prevent_arming & (1u << context.status().nav_state)) {
/* EVENT
* @description
* Switch to another mode first.
*/
reporter.armingCheckFailure((NavModes)reporter.failsafeFlags().mode_req_prevent_arming, health_component_t::system,
events::ID("check_modes_cannot_takeoff"),
events::Log::Info, "Mode not suitable for arming");
}
}
// Failing mode requirements generally also clear the can_run bits which prevents mode switching and
@@ -181,16 +189,3 @@ void ModeChecks::checkAndReport(const Context &context, Report &reporter)
reporter.clearCanRunBits((NavModes)reporter.failsafeFlags().mode_req_wind_and_flight_time_compliance);
}
}
void ModeChecks::checkArmingRequirement(const Context &context, Report &reporter)
{
if (reporter.failsafeFlags().mode_req_prevent_arming & (1u << context.status().nav_state)) {
/* EVENT
* @description
* Switch to another mode first.
*/
reporter.armingCheckFailure((NavModes)reporter.failsafeFlags().mode_req_prevent_arming, health_component_t::system,
events::ID("check_modes_cannot_takeoff"),
events::Log::Info, "Mode not suitable for arming");
}
}
@@ -46,8 +46,6 @@ public:
void checkAndReport(const Context &context, Report &reporter) override;
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,
(ParamInt<px4::params::COM_RC_IN_MODE>) _param_com_rc_in_mode