mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 04:13:33 +08:00
Commander: execute pre arm check with preflight checks
This commit is contained in:
committed by
Daniel Agar
parent
aa575d6af0
commit
3b3d8b9942
@@ -68,9 +68,12 @@ transition_result_t ArmStateMachine::arming_state_transition(vehicle_status_s &s
|
||||
&& !(status.hil_state == vehicle_status_s::HIL_STATE_ON)
|
||||
&& (_arm_state != vehicle_status_s::ARMING_STATE_IN_AIR_RESTORE)) {
|
||||
|
||||
if (!PreFlightCheck::preflightCheck(mavlink_log_pub, status, status_flags, control_mode, true, true, time_since_boot)
|
||||
|| !PreFlightCheck::preArmCheck(mavlink_log_pub, status_flags, control_mode, safety_button_available, safety_off,
|
||||
arm_requirements, status)) {
|
||||
if (!PreFlightCheck::preflightCheck(mavlink_log_pub, status, status_flags, control_mode,
|
||||
true, // report_failures
|
||||
true, // prearm
|
||||
time_since_boot,
|
||||
safety_button_available, safety_off,
|
||||
arm_requirements)) {
|
||||
feedback_provided = true; // Preflight checks report error messages
|
||||
valid_transition = false;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,9 @@ static constexpr unsigned max_mandatory_baro_count = 1;
|
||||
|
||||
bool PreFlightCheck::preflightCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &status,
|
||||
vehicle_status_flags_s &status_flags, const vehicle_control_mode_s &control_mode,
|
||||
bool report_failures, const bool prearm, const hrt_abstime &time_since_boot)
|
||||
bool report_failures, const bool prearm, const hrt_abstime &time_since_boot,
|
||||
const bool safety_button_available, const bool safety_off,
|
||||
const arm_requirements_t &arm_requirements)
|
||||
{
|
||||
report_failures = (report_failures && !status_flags.calibration_enabled);
|
||||
|
||||
@@ -226,6 +228,8 @@ bool PreFlightCheck::preflightCheck(orb_advert_t *mavlink_log_pub, vehicle_statu
|
||||
failed = failed || !modeCheck(mavlink_log_pub, report_failures, status);
|
||||
failed = failed || !cpuResourceCheck(mavlink_log_pub, report_failures);
|
||||
failed = failed || !parachuteCheck(mavlink_log_pub, report_failures, status_flags);
|
||||
failed = failed || !preArmCheck(mavlink_log_pub, status_flags, control_mode,
|
||||
safety_button_available, safety_off, arm_requirements, status, report_failures);
|
||||
|
||||
/* Report status */
|
||||
return !failed;
|
||||
|
||||
@@ -56,6 +56,14 @@ public:
|
||||
PreFlightCheck() = default;
|
||||
~PreFlightCheck() = default;
|
||||
|
||||
struct arm_requirements_t {
|
||||
bool arm_authorization = false;
|
||||
bool esc_check = false;
|
||||
bool global_position = false;
|
||||
bool mission = false;
|
||||
bool geofence = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Runs a preflight check on all sensors to see if they are properly calibrated and healthy
|
||||
*
|
||||
@@ -83,20 +91,9 @@ public:
|
||||
**/
|
||||
static bool preflightCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &status,
|
||||
vehicle_status_flags_s &status_flags, const vehicle_control_mode_s &control_mode,
|
||||
bool reportFailures, const bool prearm, const hrt_abstime &time_since_boot);
|
||||
|
||||
struct arm_requirements_t {
|
||||
bool arm_authorization = false;
|
||||
bool esc_check = false;
|
||||
bool global_position = false;
|
||||
bool mission = false;
|
||||
bool geofence = false;
|
||||
};
|
||||
|
||||
static bool preArmCheck(orb_advert_t *mavlink_log_pub, const vehicle_status_flags_s &status_flags,
|
||||
const vehicle_control_mode_s &control_mode, const bool safety_button_available, const bool safety_off,
|
||||
const arm_requirements_t &arm_requirements, vehicle_status_s &status,
|
||||
bool report_fail = true);
|
||||
bool reportFailures, const bool prearm, const hrt_abstime &time_since_boot,
|
||||
const bool safety_button_available, const bool safety_off,
|
||||
const arm_requirements_t &arm_requirements);
|
||||
|
||||
private:
|
||||
static bool sensorAvailabilityCheck(const bool report_failure,
|
||||
@@ -138,4 +135,8 @@ private:
|
||||
static bool sdcardCheck(orb_advert_t *mavlink_log_pub, bool &sd_card_detected_once, const bool report_fail);
|
||||
static bool parachuteCheck(orb_advert_t *mavlink_log_pub, const bool report_fail,
|
||||
const vehicle_status_flags_s &status_flags);
|
||||
static bool preArmCheck(orb_advert_t *mavlink_log_pub, const vehicle_status_flags_s &status_flags,
|
||||
const vehicle_control_mode_s &control_mode, const bool safety_button_available, const bool safety_off,
|
||||
const arm_requirements_t &arm_requirements, vehicle_status_s &status,
|
||||
const bool report_fail);
|
||||
};
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
bool PreFlightCheck::preArmCheck(orb_advert_t *mavlink_log_pub, const vehicle_status_flags_s &status_flags,
|
||||
const vehicle_control_mode_s &control_mode, const bool safety_button_available, const bool safety_off,
|
||||
const arm_requirements_t &arm_requirements, vehicle_status_s &status, bool report_fail)
|
||||
const arm_requirements_t &arm_requirements, vehicle_status_s &status, const bool report_fail)
|
||||
{
|
||||
bool prearm_ok = true;
|
||||
|
||||
@@ -227,6 +227,5 @@ bool PreFlightCheck::preArmCheck(orb_advert_t *mavlink_log_pub, const vehicle_st
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return prearm_ok;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user