mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 00:03:34 +08:00
ekf2: use explicit flags instead of bitmask position
This prevents bitmask mismatch when a new flag is inserted
This commit is contained in:
@@ -174,12 +174,20 @@ void Ekf::fuseMag(const Vector3f &mag)
|
||||
for (uint8_t index = 0; index <= 2; index++) {
|
||||
_mag_test_ratio(index) = sq(_mag_innov(index)) / (sq(math::max(_params.mag_innov_gate, 1.0f)) * _mag_innov_var(index));
|
||||
|
||||
if (_mag_test_ratio(index) > 1.0f) {
|
||||
const bool innov_check_fail = (_mag_test_ratio(index) > 1.0f);
|
||||
|
||||
if (innov_check_fail) {
|
||||
all_innovation_checks_passed = false;
|
||||
_innov_check_fail_status.value |= (1 << (index + 3));
|
||||
}
|
||||
|
||||
if (index == 0) {
|
||||
_innov_check_fail_status.flags.reject_mag_x = innov_check_fail;
|
||||
|
||||
} else if (index == 1) {
|
||||
_innov_check_fail_status.flags.reject_mag_y = innov_check_fail;
|
||||
|
||||
} else {
|
||||
_innov_check_fail_status.value &= ~(1 << (index + 3));
|
||||
_innov_check_fail_status.flags.reject_mag_z = innov_check_fail;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user