Skip to content

Commit 843f29d

Browse files
committed
Fix GPS recovery - update lastUpdateTime on first reading after signal recovery
When GPS signal is lost and recovered, the position estimator's lastUpdateTime was only being updated on subsequent readings (when isFirstGPSUpdate was false). This caused the GPS validity timeout check to fail on the first reading after recovery, resulting in altitude and distance-to-home values getting stuck at zero. The fix moves the lastUpdateTime update outside the isFirstGPSUpdate check so it is updated on every GPS reading, including the first one after recovery. Fixes iNavFlight#11049
1 parent 579daf1 commit 843f29d

2 files changed

Lines changed: 432 additions & 3 deletions

File tree

src/main/navigation/navigation_pos_estimator.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,13 @@ void onNewGPSData(void)
256256
posEstimator.gps.eph = INAV_GPS_DEFAULT_EPH;
257257
posEstimator.gps.epv = INAV_GPS_DEFAULT_EPV;
258258
}
259-
260-
/* Indicate a last valid reading of Pos/Vel */
261-
posEstimator.gps.lastUpdateTime = currentTimeUs;
262259
}
263260

261+
/* Indicate a last valid reading of Pos/Vel - must be updated even on
262+
* first GPS reading after recovery to prevent position estimate from
263+
* timing out and getting stuck at zero (fixes issue #11049) */
264+
posEstimator.gps.lastUpdateTime = currentTimeUs;
265+
264266
previousLat = gpsSol.llh.lat;
265267
previousLon = gpsSol.llh.lon;
266268
previousAlt = gpsSol.llh.alt;

0 commit comments

Comments
 (0)