Skip to content

Commit 20ec96e

Browse files
committed
AP_NavEKF3: added in a check for high velocity innovation
if using GPS and our horizontal velocity innovation is high then mark the filter as unhealthy, which causes an arming failure this helps with ArduPilot#29384
1 parent 9fb1e2b commit 20ec96e

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

libraries/AP_NavEKF3/AP_NavEKF3.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,10 @@ bool NavEKF3::pre_arm_check(bool requires_position, char *failure_msg, uint8_t f
11571157
}
11581158
return false;
11591159
}
1160+
// run per-core pre-arm checks
1161+
if (!core[i].pre_arm_check(requires_position, failure_msg, failure_msg_len)) {
1162+
return false;
1163+
}
11601164
}
11611165
return true;
11621166
}

libraries/AP_NavEKF3/AP_NavEKF3_Outputs.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,31 @@ bool NavEKF3_core::healthy(void) const
3232
return true;
3333
}
3434

35+
/*
36+
per-core pre-arm checks. returns false if we fail arming checks, in
37+
which case the buffer will be populated with a failure message
38+
requires_position should be true if horizontal position configuration should be checked
39+
*/
40+
bool NavEKF3_core::pre_arm_check(bool requires_position, char *failure_msg, uint8_t failure_msg_len) const
41+
{
42+
if (requires_position) {
43+
// additional checks when position is required, used by pre-arm checks
44+
const float max_vel_innovation = 2.0;
45+
const float hvel_innovation = sqrtf(sq(innovVelPos[0])+sq(innovVelPos[1]));
46+
if (onGround && PV_AidingMode == AID_ABSOLUTE &&
47+
frontend->sources.useVelXYSource(AP_NavEKF_Source::SourceXY::GPS) &&
48+
hvel_innovation > max_vel_innovation) {
49+
// more than 2 m/s horizontal velocity innovation on the ground
50+
dal.snprintf(failure_msg, failure_msg_len,
51+
"EKF3[%u] vel error %.1f", unsigned(core_index)+1, hvel_innovation);
52+
return false;
53+
}
54+
}
55+
56+
// all OK
57+
return true;
58+
}
59+
3560
// Return a consolidated error score where higher numbers represent larger errors
3661
// Intended to be used by the front-end to determine which is the primary EKF
3762
float NavEKF3_core::errorScore() const

libraries/AP_NavEKF3/AP_NavEKF3_core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,12 @@ class NavEKF3_core : public NavEKF_core_common
464464
// get a yaw estimator instance
465465
const EKFGSF_yaw *get_yawEstimator(void) const { return yawEstimator; }
466466

467+
// per-core pre-arm checks. returns false if we fail arming
468+
// checks, in which case the buffer will be populated with a
469+
// failure message
470+
// requires_position should be true if horizontal position configuration should be checked
471+
bool pre_arm_check(bool requires_position, char *failure_msg, uint8_t failure_msg_len) const;
472+
467473
private:
468474
EKFGSF_yaw *yawEstimator;
469475
AP_DAL &dal;

0 commit comments

Comments
 (0)