3

Is there a way to get the velocity without GPS in Android? I don't need the accurate values.

flypen
  • 2,515
  • 4
  • 34
  • 51

1 Answers1

2

Well, sort of, but you will need to do alot of processing..

You can make frequent accelerometer readings and integrate the values once to get velocity. This won't get you an accurate starting velocity but after a while it will probably work (unless you start when the phone is driving along in a car). See also this post.

Now, some pseudo code:

We start at t=0 and measure acceleration in all three axis.

a = get_acceleration()

vx = vx + a.x - gravity.x;
vy = vy + a.y - gravity.y;
vz = vz + a.z - gravity.z;

After doing this for a few seconds, the sum of all the acceleration values (if you sample frequently, ie, 50Hz) should be velocity. You will also need to work out which way up your device is and therefore how much of the acceleration components you are reading is due to gravity and compensate.

Community
  • 1
  • 1
IanNorton
  • 7,145
  • 2
  • 25
  • 28
  • It sounds good. But it's a little complicated. Maybe using GPS is the best way to get velocity in mobile platforms. – flypen Feb 12 '12 at 08:38
  • 1
    Also there's the basic physics problem that even if you could sample perfectly (and the phone's orientation didn't change), you don't know the velocity of your frame of reference (ie you have no way of knowing don't know if you were moving at constant velocity when you started sampling). – John Carter Feb 12 '12 at 09:14
  • Another problem is that error gets bigger and bigger as the time passes - small deviations add up to big difference unless you have the way to normalize every now and then. – johndodo May 20 '12 at 17:51