6

I need to obtain the velocity of an android device, based on the accelerometer values. I made a code that allows me to get the accelerometer values, and then I calculate the velocity, using the formula: v = v0 + at. (vector calculation)

My problem is that my velocity only increases and never decreases. I think the problem is that the device never gets an negative acceleration.

Can you help me with this?

nunolourenco
  • 699
  • 2
  • 8
  • 18

3 Answers3

6

Obtaining velocity from the accelerometers might not be possible (forget reliable) because at constant speed there will be no acceleration (other than gravity). You might be better off obtaining GPS location data and their associated time samples and computing velocity by distance over time.

maerics
  • 151,642
  • 46
  • 269
  • 291
  • 1
    Well, the problem is that I am trying to apply a dead reckoning technic to compensate a temporary GPS failure. So, when I start obtaining the values from the accelerometer I don't have GPS connection. I know i will have a cumulative error, and I know that the values are not reliable, but its an academic work, just to check that its possible. – nunolourenco Apr 20 '10 at 00:24
  • Here is my example http://maephv.blogspot.com/2011/10/android-computing-speed-and-distance.html – Maep Oct 26 '11 at 03:22
4

Are you subtracting out the force of gravity? The device is always accelerating -- even if it is just sitting on your desk, it is accelerating at 9.8 m/s^2 away from the center of the Earth.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
1

You can use a combination of the accelerometer and the digital compass, in phones that have them, to determine a speed and direction as mentioned in this post.

If all you need to do is determine if the person is walking, all you need is the accelerometer. Just process its output for foot steps.

There are plenty of tutorials on the web for detecting foot steps with an accelerometer.

There an app note here: http://www.analog.com/library/analogDialogue/archives/41-03/pedometer.html that gives a decent mathematical background and an example algorithm. Its of course up to you to extract the math and rewrite it for Android (the example code is written in C). I don't currently know of an open source android library with a footstep detection algorithm.

If you implement something, I would like to get the code, don't forget to post back the results.

Community
  • 1
  • 1
Pentium10
  • 204,586
  • 122
  • 423
  • 502