From 099392d3ca0c96f41178a421e3fccdd2fc3c3458 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 5 Jul 2015 17:27:53 +1000 Subject: [PATCH] AP_Math: don't optimise longitude_scale on faster CPUs it causes problems with replay --- libraries/AP_Math/location.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/AP_Math/location.cpp b/libraries/AP_Math/location.cpp index 9e9bff9aef..758ffffe6b 100644 --- a/libraries/AP_Math/location.cpp +++ b/libraries/AP_Math/location.cpp @@ -37,12 +37,15 @@ float longitude_scale(const struct Location &loc) { static int32_t last_lat; static float scale = 1.0; +#if HAL_CPU_CLASS < HAL_CPU_CLASS_150 + // don't optimise on faster CPUs. It causes some minor errors on Replay if (labs(last_lat - loc.lat) < 100000) { // we are within 0.01 degrees (about 1km) of the // same latitude. We can avoid the cos() and return // the same scale factor. return scale; } +#endif scale = cosf(loc.lat * 1.0e-7f * DEG_TO_RAD); scale = constrain_float(scale, 0.01f, 1.0f); last_lat = loc.lat;