AP_Compass: only magcal detected compasses

inflight compass learning with COMPASS_LEARN=3 was not working with
less than 3 compasses, as the force_use parameter was preventing
skipping compasses. This fixes it to calibate all detected compasses
that have USE enabled
This commit is contained in:
Andrew Tridgell 2022-01-17 07:55:36 +11:00
parent e0d1fd11ee
commit 3f2a72f9db
1 changed files with 2 additions and 2 deletions

View File

@ -521,12 +521,12 @@ MAV_RESULT Compass::mag_cal_fixed_yaw(float yaw_deg, uint8_t compass_mask,
// Rotate into body frame using provided yaw
field = dcm.transposed() * field;
for (uint8_t i=0; i<COMPASS_MAX_INSTANCES; i++) {
for (uint8_t i=0; i<get_count(); i++) {
if (compass_mask != 0 && ((1U<<i) & compass_mask) == 0) {
// skip this compass
continue;
}
if (!force_use && !use_for_yaw(i)) {
if (_use_for_yaw[Priority(i)] == 0 || (!force_use && !use_for_yaw(i))) {
continue;
}
if (!healthy(i)) {