How it works
A phone’s GPS gives one fix per second, and a 60-foot run lasts two. With the GPS alone, times come out half a second off. The accelerometer measures a hundred times per second, but it drifts and doesn’t know which way is “forward”. TorkeKit combines both and keeps the best of each.
1. Knowing which way is forward
Section titled “1. Knowing which way is forward”The phone can sit any way: upright, flat, tilted toward the driver. AxisCalibration uses the gravity vector to keep only the horizontal part of the acceleration. Then it waits for the first strong push (the launch) and takes that direction as “forward”.
That’s why you don’t need to ask the user to place the phone in a special way. Only that it stays fixed.
2. Combining accelerometer and GPS
Section titled “2. Combining accelerometer and GPS”SpeedFilter is a two-state Kalman filter: the speed and the accelerometer’s bias (the small constant error every sensor has, which grows if the mount is tilted).
- A hundred times per second, it predicts the speed by adding up the acceleration.
- Every time a GPS fix arrives, it corrects the speed and learns the bias, weighing each source by how much it trusts it (the accuracy the GPS reports).
The result is a speed curve as smooth as the accelerometer’s and without drift, like the GPS’s.
3. Reading the run
Section titled “3. Reading the run”RunAnalyzer looks for the launch: one second still, then sustained acceleration. From there it builds the speed and distance curve over time (trace) and reads each mark:
- Distances (60 ft, 1/8, 1/4): the moment the distance crosses the mark, minus the one-foot rollout.
- Speeds (0–100): the moment the speed crosses the value.
- Trap speed: the speed when passing the mark, like the track’s radar.
In real life
Section titled “In real life”- Rigid mount. If the phone shakes or moves, the accelerometer measures the mount, not the car.
RunQualitydetects it (looseMount,phoneMoved). - Open sky. The GPS needs to see satellites. Under a roof or between buildings its accuracy drops (
inaccurateGPS). - A faster GPS helps. Some Android phones give 5 or 10 fixes per second;
snapshot.gpsRatesays how many each phone gives. See Accuracy.