mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 03:03:33 +08:00
commander: skip all mag checks if SYS_HAS_MAG is 0
This commit is contained in:
@@ -88,38 +88,40 @@ bool PreFlightCheck::preflightCheck(orb_advert_t *mavlink_log_pub, vehicle_statu
|
|||||||
|
|
||||||
/* ---- MAG ---- */
|
/* ---- MAG ---- */
|
||||||
if (checkSensors) {
|
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;
|
int32_t sys_has_mag = 1;
|
||||||
param_get(param_find("SYS_HAS_MAG"), &sys_has_mag);
|
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 */
|
bool prime_found = false;
|
||||||
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);
|
|
||||||
|
|
||||||
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)) {
|
/* check all sensors individually, but fail only for mandatory ones */
|
||||||
prime_found = true;
|
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 {
|
int32_t device_id = -1;
|
||||||
if (required) {
|
|
||||||
failed = true;
|
if (magnometerCheck(mavlink_log_pub, status, i, !required, device_id, report_fail)) {
|
||||||
mag_fail_reported = true;
|
|
||||||
|
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 */
|
/* check if the primary device is present */
|
||||||
if (!prime_found) {
|
if (!prime_found) {
|
||||||
if (reportFailures && !failed) {
|
if (reportFailures && !failed) {
|
||||||
|
|||||||
Reference in New Issue
Block a user