Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-flight check: add parameter to en/disable mag field strength check #13766

Merged
merged 4 commits into from
Dec 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/modules/commander/Arming/PreFlightCheck/checks/ekf2Check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ bool PreFlightCheck::ekf2Check(orb_advert_t *mavlink_log_pub, vehicle_status_s &
bool present = true;
float test_limit = 1.0f; // pass limit re-used for each test

int32_t mag_strength_check_enabled = 1;
param_get(param_find("COM_ARM_MAG_STR"), &mag_strength_check_enabled);

bool gps_success = true;
bool gps_present = true;

Expand All @@ -65,8 +68,7 @@ bool PreFlightCheck::ekf2Check(orb_advert_t *mavlink_log_pub, vehicle_status_s &
if (status.pre_flt_fail_innov_heading ||
status.pre_flt_fail_innov_vel_horiz ||
status.pre_flt_fail_innov_vel_vert ||
status.pre_flt_fail_innov_height ||
status.pre_flt_fail_mag_field_disturbed) {
status.pre_flt_fail_innov_height) {
if (report_fail) {
if (status.pre_flt_fail_innov_heading) {
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: heading estimate not stable");
Expand All @@ -79,16 +81,22 @@ bool PreFlightCheck::ekf2Check(orb_advert_t *mavlink_log_pub, vehicle_status_s &

} else if (status.pre_flt_fail_innov_height) {
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: height estimate not stable");

} else if (status.pre_flt_fail_mag_field_disturbed) {
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: strong magnetic interference detected");
}
}

success = false;
goto out;
}

if ((mag_strength_check_enabled == 1) && status.pre_flt_fail_mag_field_disturbed) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: strong magnetic interference detected");
}

success = false;
goto out;
}

// check vertical position innovation test ratio
param_get(param_find("COM_ARM_EKF_HGT"), &test_limit);

Expand Down
11 changes: 11 additions & 0 deletions src/modules/commander/commander_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,17 @@ PARAM_DEFINE_FLOAT(COM_ARM_IMU_GYR, 0.25f);
*/
PARAM_DEFINE_INT32(COM_ARM_MAG_ANG, 30);

/**
* Enable mag strength preflight check
*
* Deny arming if the estimator detects a strong magnetic
* disturbance (check enabled by EKF2_MAG_CHECK)
*
* @boolean
* @group Commander
*/
PARAM_DEFINE_INT32(COM_ARM_MAG_STR, 1);

/**
* Enable RC stick override of auto modes
*
Expand Down