tags:

views:

336

answers:

4

Hi.

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?

+2  A: 

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
Yeah I am doing that. and I think that is the 9.8 m/s^2 are applied to the Z component.
nunolourenco
That will only be true if the device is sitting on a desk or other completely horizontal surface.
CommonsWare
Yeah, you are right. As I was only considering that the phone was horizontal I forgot that. Thanks ;)
nunolourenco
+2  A: 

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
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
A: 

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.

Pentium10