fix(telemetry): Inconsistent/wrong GPS distance calculation (#4442)

This commit is contained in:
Michael
2023-12-21 19:16:56 +10:00
committed by GitHub
parent c201f93516
commit 587a14361f
2 changed files with 7 additions and 10 deletions
+3 -3
View File
@@ -161,12 +161,12 @@ void TelemetryItem::setValue(const TelemetrySensor &sensor, int32_t val,
#if defined(INTERNAL_GPS)
if (gpsData.fix && gpsData.hdop < PILOTPOS_MIN_HDOP) {
pilotLatitude = gpsData.latitude;
distFromEarthAxis = getDistFromEarthAxis(pilotLatitude);
gps.pilotDistFromEarthAxis = getDistFromEarthAxis(pilotLatitude);
}
#endif
if (!pilotLatitude) {
pilotLatitude = newVal;
distFromEarthAxis = getDistFromEarthAxis(newVal);
gps.pilotDistFromEarthAxis = getDistFromEarthAxis(newVal);
}
gps.latitude = newVal;
setFresh();
@@ -380,7 +380,7 @@ void TelemetryItem::eval(const TelemetrySensor & sensor)
uint32_t result = dist * dist;
angle = abs(gpsItem.gps.longitude - gpsItem.pilotLongitude);
dist = uint64_t(gpsItem.distFromEarthAxis) * angle / 1000000;
dist = uint64_t(gpsItem.gps.pilotDistFromEarthAxis) * angle / 1000000;
result += dist * dist;
// Length on ground (ignoring curvature of the earth)