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

commander: skip all mag checks if SYS_HAS_MAG is 0 #13757

Merged
merged 2 commits into from
Dec 18, 2019
Merged
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
44 changes: 23 additions & 21 deletions src/modules/commander/Arming/PreFlightCheck/PreFlightCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,38 +88,40 @@ bool PreFlightCheck::preflightCheck(orb_advert_t *mavlink_log_pub, vehicle_statu

/* ---- MAG ---- */
if (checkSensors) {
bool prime_found = false;

int32_t prime_id = -1;
param_get(param_find("CAL_MAG_PRIME"), &prime_id);

int32_t sys_has_mag = 1;
param_get(param_find("SYS_HAS_MAG"), &sys_has_mag);

bool mag_fail_reported = false;
if (sys_has_mag == 1) {

/* check all sensors individually, but fail only for mandatory ones */
for (unsigned i = 0; i < max_optional_mag_count; i++) {
const bool required = (i < max_mandatory_mag_count) && (sys_has_mag == 1);
const bool report_fail = (reportFailures && !failed && !mag_fail_reported);
bool prime_found = false;

int32_t device_id = -1;
int32_t prime_id = -1;
param_get(param_find("CAL_MAG_PRIME"), &prime_id);

if (magnometerCheck(mavlink_log_pub, status, i, !required, device_id, report_fail)) {
bool mag_fail_reported = false;

if ((prime_id > 0) && (device_id == prime_id)) {
prime_found = true;
}
/* check all sensors individually, but fail only for mandatory ones */
for (unsigned i = 0; i < max_optional_mag_count; i++) {
const bool required = (i < max_mandatory_mag_count) && (sys_has_mag == 1);
const bool report_fail = (reportFailures && !failed && !mag_fail_reported);

} else {
if (required) {
failed = true;
mag_fail_reported = true;
int32_t device_id = -1;

if (magnometerCheck(mavlink_log_pub, status, i, !required, device_id, report_fail)) {

if ((prime_id > 0) && (device_id == prime_id)) {
prime_found = true;
}

} else {
if (required) {
failed = true;
mag_fail_reported = true;
}
}
}
}

if (sys_has_mag == 1) {

/* check if the primary device is present */
if (!prime_found) {
if (reportFailures && !failed) {
Expand Down