0

I'm currently working on a health/fitness application that is supposed to track the instantaneous speed of the user during an exercise (running, biking, whatever ...). The application must be able to give real-time instructions, so the speed must be as accurate as possible and refreshed quite frequently.

I already have found a good tutorial here, in which the current speed is calculated using distance and time, and averaged with the 3 previously calculated speeds. This seems to do the job if I change some defines, but the entire code is kind of complex for something so simple. Also, I know that CLLocation class has a speedattribute that delivers the same information.

So my question is : Which way is the most accurate to get an instantaneous speed ? Or in other words, is CLLocation's speed attribute enough for this kind of usage ?

Thanks !

2 Answers2

0

From Apple Reference

speed
The instantaneous speed of the device in meters per second.

@property(readonly, NS_NONATOMIC_IPHONEONLY) CLLocationSpeed speed
Discussion
This value reflects the instantaneous speed of the device in the direction of its current heading. A negative value indicates an invalid speed. Because the actual speed can change many times between the delivery of subsequent location events, you should use this property for informational purposes only.

Special Considerations
In iOS, this property is declared as nonatomic. In OS X, it is declared as atomic.

Availability
Available in OS X v10.7 and later.
Declared In
CLLocation.h

Does not sound like Apple considers it to be accurate. Nor is it.

EDIT -- Here's a related question same problem and some suggestions.

Community
  • 1
  • 1
Gary Walker
  • 8,831
  • 3
  • 19
  • 41
  • Indeed, I did not notice the related question. Apple reference seemed to me really vague about this point, that's why I prefer asking. Thanks for your answer – Clément Casu Sep 18 '13 at 14:21
  • Used to do a bunch of work with GPS on phones. GPS on phones is not accurate at all when the GPS chip is not moving, its starts bouncing around randomly, maybe up to a mile from the actual location when sitting still. – Gary Walker Sep 18 '13 at 14:26
  • Lots of things can interfere with GPS accuracy. It may be accurate, it may not. Does not matter if you set GPS Accuracy to AccuracyBest it may still be completely bogus, that is why instantaneous values are advisory. See http://precisiontracking.com.au/blog/factors-affecting-gps-accuracy/ for details re: the source of errors, with positional errors, you will have corresponding instantaneous speed errors. – Gary Walker Sep 18 '13 at 22:19
0

The best value you can get is the GPS speed. So make sure you have set GPS to AccuracyBest and read the CLLocation speed attribute.

The slower you move the inacurate it is, like an all GPS devices. For automotive typical velocity you can expect 0.1 km/h accuracy.

AlexWien
  • 28,470
  • 6
  • 53
  • 83