mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 10:26:52 +08:00
ekf2: fix timeout after gps failure (#23346)
This commit is contained in:
@@ -63,7 +63,8 @@ void Ekf::controlGpsFusion(const imuSample &imu_delayed)
|
||||
if (_gps_data_ready) {
|
||||
const gnssSample &gnss_sample = _gps_sample_delayed;
|
||||
|
||||
if (runGnssChecks(gnss_sample) && isTimedOut(_last_gps_fail_us, (uint64_t)_min_gps_health_time_us / 2)) {
|
||||
if (runGnssChecks(gnss_sample)
|
||||
&& isTimedOut(_last_gps_fail_us, max((uint64_t)1e6, (uint64_t)_min_gps_health_time_us / 10))) {
|
||||
if (isTimedOut(_last_gps_fail_us, (uint64_t)_min_gps_health_time_us)) {
|
||||
// First time checks are passing, latching.
|
||||
_gps_checks_passed = true;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -136,7 +136,7 @@ TEST_F(EkfGpsTest, resetToGpsVelocity)
|
||||
|
||||
_ekf->set_in_air_status(true);
|
||||
_ekf->set_vehicle_at_rest(false);
|
||||
_sensor_simulator.runSeconds(5.2); // required to pass the checks
|
||||
_sensor_simulator.runSeconds(1.2); // required to pass the checks
|
||||
_sensor_simulator.runMicroseconds(dt_us);
|
||||
|
||||
// THEN: a reset to GPS velocity should be done
|
||||
|
||||
@@ -68,6 +68,7 @@ public:
|
||||
|
||||
TEST_F(EkfMagTest, fusionStartWithReset)
|
||||
{
|
||||
_ekf->set_min_required_gps_health_time(5e6);
|
||||
// GIVEN: some meaningful mag data
|
||||
const float mag_heading = M_PI_F / 3.f;
|
||||
const float incl = 63.1f;
|
||||
@@ -84,11 +85,10 @@ TEST_F(EkfMagTest, fusionStartWithReset)
|
||||
EXPECT_FALSE(_ekf_wrapper.isIntendingMag3DFusion());
|
||||
|
||||
EXPECT_EQ(_ekf_wrapper.getQuaternionResetCounter(), initial_quat_reset_counter + 1);
|
||||
|
||||
// AND WHEN: GNSS fusion starts
|
||||
_ekf_wrapper.enableGpsFusion();
|
||||
_sensor_simulator.startGps();
|
||||
_sensor_simulator.runSeconds(11);
|
||||
_sensor_simulator.runSeconds(6);
|
||||
|
||||
// THEN: the earth mag field is reset to the WMM
|
||||
EXPECT_EQ(_ekf_wrapper.getQuaternionResetCounter(), initial_quat_reset_counter + 2);
|
||||
|
||||
Reference in New Issue
Block a user