10

I am trying to implement a fitness app that can keep track of the running speed and running distance in Android.

It looks like I can either use GPS or Accelerometer to calculate these information.

Since a runner may put his phone in hand, on the shoulder or in his pocket, my first intuition is to use GPS to get locations and calculate running speed and running distance. But recently someone telled me that I can also use Accelerometer also does that.

My question is: In Android, which approach is better to calculate running speed and running distance, GPS or Accelerometer?

user4157124
  • 2,809
  • 13
  • 27
  • 42
Evan_HZY
  • 984
  • 5
  • 17
  • 34

4 Answers4

7

I suspect that pedometers are based on accelerometers because accelerometers are cheaper than GPS to use. in fact I think a lot of pedometers don't even try to measure distance. just acceleration jolts which equal steps. and then if they give you a distance measurement, it's by multiplying detected steps by a guessed or average step size.

GPS (if you are in an area where it works!) will do a very good measurement of distance. Even with a very cheap GPS receiver. All being basically OK, you should expect start and end positions to within 10m, and so for a 1km travel, you have 20m of uncertianty, which is 2% total distance uncertianty. This uncertianty goes down linearly with distance travelled (ie a 2km run will have 1% uncertianty, 4 km run will have 0.5% uncertianty, etc) the issues here will be with your realtime displays (GPS position jumps from satellite switching giving massive speed values, or immediate loss of signal giving a loss of all immediately displayable data)

I think that with a good accelerometer, starting from stopped you can continually integrate the signal to get speed, and continually integrate that result to get distance... I am just unsure what kind of accelerometer quality you get in any given phone? you may need to filter for noise or even garbage data.. And you also need to consider what accuracy it has. 20% accuracy in your sensor would make for a very bad distance tracker. So you might have to work with step counting and step size guesstimates.

perhaps a combination of both could work?

I'd be tempted to use the accelerometer data (either integrating or step counting depending on what will always work) to track speed and distance in short timeframe, then with much longer timeframe, generalised GPS data could be used to correct or scale that data from the accelerometer. Especially if you filtered/blocked GPS data based on uncertianty measurement at any given time.

Julian Higginson
  • 547
  • 4
  • 12
  • I'd add that GPS gets weird results sometimes, e.g. reporting a maximum speed of 40km/h when _running_, so the accelerometer might be better for measuring speed. – Gabi Purcaru Jun 20 '12 at 09:09
  • Since people normally doesn't move linearly, the uncertainty in the distance calculated with GPS data will be much more. – Foreever Dec 16 '13 at 08:35
4

Adding to what Julian said ... Normally GPS doesn't work under the roofs therefore for indoor gyms it will not work. Theoretically GPS signals are not bothered by clouds but when I was working on my GPS application, I had experience of unavailability of GPS signals in really bad weather (this might not be your case as no one will go on jogging in thunder storm :D) Agreeing with Julian, you should use both GPS and accelerometer to build a reliable app for every condition.

ABH
  • 3,391
  • 23
  • 26
  • yeah, bad weather gets in the way of GPS reception. Even tree leaves cause big errors with precise RTK systems due to multipath reflections. – Julian Higginson Mar 29 '12 at 06:23
  • 2
    GPS RF signals are actually beneath the noise floor in the radio spectrum, so the fact that GPS works at all is amazing and the result of a lot of hardcore physics nerds with a lot of realllllly good maths. :-) – Julian Higginson Mar 29 '12 at 06:30
3

The best results are obtained by using both of them, through sensor fusion. See:

Android accelerometer accuracy (Inertial navigation)

You will have accuracy problems if you just use either the GPS or a pedometer algorithm.

Community
  • 1
  • 1
Ali
  • 56,466
  • 29
  • 168
  • 265
2

All pedometers I know are based on accelerometers. I guess, GPS is not precise enough for this stuff. It may say "no motion" while you did some steps, it's also dependent on the area you are trying to use it.

iehrlich
  • 3,572
  • 4
  • 34
  • 43