mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-29 11:40:28 +08:00
fix(ekf2): map GNSS check param bits to fail status bits explicitly
The published gps_check_fail_flags mask was derived from EKF2_GPS_CHECK with a positional shift, assuming param bit N corresponds to fail status bit N+1. That only holds up to kSpoofed: the fix check sits at param bit 10 but status bit 0, so the shift made param bit 10 (Fix type) publish status bit 11 (jammed), and param bit 11 (Jamming) map to a status bit no check ever sets. With the default EKF2_GPS_CHECK of 2047 the published mask was therefore 4095, which reports a jamming failure even though the jamming check is disabled, while enabling the jamming check published nothing. Map the two layouts one by one in GnssChecks, which owns both, so appending a check to one enum can no longer silently misassign the others. The fix bit is now gated on kFix like every other check, matching how it is already gated when computing whether the checks passed.
This commit is contained in:
1 parent
2c021df812
commit
768d1ce316
3 files changed
+28
-4
No files matched your search
@@ -68,6 +68,30 @@ public:
|
||||
uint16_t value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fail-status flags (gps_check_fail_status_u layout) of the checks enabled by EKF2_GPS_CHECK.
|
||||
* The param bit order (GnssChecksMask) and the status bit order are not parallel, so they are
|
||||
* mapped one by one: a positional shift silently misassigns every check that is appended to
|
||||
* one of the two enums but not the other.
|
||||
*/
|
||||
uint16_t getEnabledChecksFailStatusMask() const
|
||||
{
|
||||
gps_check_fail_status_u mask{};
|
||||
mask.flags.fix = isCheckEnabled(GnssChecksMask::kFix);
|
||||
mask.flags.nsats = isCheckEnabled(GnssChecksMask::kNsats);
|
||||
mask.flags.pdop = isCheckEnabled(GnssChecksMask::kPdop);
|
||||
mask.flags.hacc = isCheckEnabled(GnssChecksMask::kHacc);
|
||||
mask.flags.vacc = isCheckEnabled(GnssChecksMask::kVacc);
|
||||
mask.flags.sacc = isCheckEnabled(GnssChecksMask::kSacc);
|
||||
mask.flags.hdrift = isCheckEnabled(GnssChecksMask::kHdrift);
|
||||
mask.flags.vdrift = isCheckEnabled(GnssChecksMask::kVdrift);
|
||||
mask.flags.hspeed = isCheckEnabled(GnssChecksMask::kHspd);
|
||||
mask.flags.vspeed = isCheckEnabled(GnssChecksMask::kVspd);
|
||||
mask.flags.spoofed = isCheckEnabled(GnssChecksMask::kSpoofed);
|
||||
mask.flags.jammed = isCheckEnabled(GnssChecksMask::kJammed);
|
||||
return mask.value;
|
||||
}
|
||||
|
||||
void resetHard()
|
||||
{
|
||||
_initial_checks_passed = false;
|
||||
@@ -113,7 +137,7 @@ private:
|
||||
kJammed = (1 << 11)
|
||||
};
|
||||
|
||||
bool isCheckEnabled(GnssChecksMask check) { return (_params.check_mask & static_cast<int32_t>(check)); }
|
||||
bool isCheckEnabled(GnssChecksMask check) const { return (_params.check_mask & static_cast<int32_t>(check)); }
|
||||
|
||||
bool runSimplifiedChecks(const gnssSample &gnss);
|
||||
bool runInitialFixChecks(const gnssSample &gnss);
|
||||
|
||||
@@ -406,6 +406,7 @@ public:
|
||||
|
||||
const GnssChecks::gps_check_fail_status_u &gps_check_fail_status() const { return _gnss_checks.getFailStatus(); }
|
||||
const decltype(GnssChecks::gps_check_fail_status_u::flags) &gps_check_fail_status_flags() const { return _gnss_checks.getFailStatus().flags; }
|
||||
uint16_t gps_check_fail_status_enabled_mask() const { return _gnss_checks.getEnabledChecksFailStatusMask(); }
|
||||
|
||||
bool gps_checks_passed() const { return _gnss_checks.passed(); };
|
||||
|
||||
|
||||
@@ -1948,9 +1948,8 @@ void EKF2::PublishStatus(const hrt_abstime ×tamp)
|
||||
_ekf.getOutputTrackingError().copyTo(status.output_tracking_error);
|
||||
|
||||
#if defined(CONFIG_EKF2_GNSS)
|
||||
// only report enabled GPS check failures (the param indexes are shifted by 1 bit, because they don't include
|
||||
// the GPS Fix bit, which is always checked)
|
||||
status.gps_check_fail_flags = _ekf.gps_check_fail_status().value & (((uint16_t)_params->ekf2_gps_check << 1) | 1);
|
||||
// only report enabled GPS check failures
|
||||
status.gps_check_fail_flags = _ekf.gps_check_fail_status().value & _ekf.gps_check_fail_status_enabled_mask();
|
||||
#endif // CONFIG_EKF2_GNSS
|
||||
|
||||
status.control_mode_flags = _ekf.control_status().value;
|
||||
|
||||
Reference in new issue
Block a user