Freeletics Trevor Phillips Jun 3, 2019

iOS GPS Testing and Location Services

Article Summary

Trevor Phillips from Freeletics built a comprehensive GPS testing framework that improved location accuracy from 7% error down to 1.68%. Here's how they systematically validated every improvement.

The Freeletics engineering team needed precise distance tracking for running workouts, so they collected real GPS data from employees, analyzed the noise patterns in iOS CLLocation data, and built a Kalman filter to improve accuracy. They created 54 test scenarios simulating different conditions to validate their approach.

Key Takeaways

Critical Insight

By systematically collecting real data, simulating noise patterns, and applying Kalman filtering, the team reduced GPS tracking errors to under 1.7% in worst case scenarios.

The article includes full Swift implementations of the Kalman filter and the Box-Muller transformation for generating realistic GPS noise.

About This Article

Problem

iPhone GPS data was accurate to about 7.2 meters on average, with a standard deviation of 1.7 meters horizontally. Vertical accuracy averaged 3.6 meters. These gaps caused real problems for Freeletics' running workout tracking, leading to significant distance measurement errors.

Solution

Trevor Phillips' team built a Kalman filter that works with CLLocation objects. The filter predicts position changes based on how much time has passed and the timeUncertainty parameter. It then refines those predictions using the measurement accuracy values from incoming data.

Impact

The Kalman filter cut distance calculation errors down to 0.7% in ideal conditions and 1.68% in the worst case across 54 test runs. Raw GPS data on the same paths produced errors up to 7%, so the filter consistently performed better.