I do not have access to my code at the moment,  but what I had done
was use the readings from the orientation sensor to calculate the
vector that points in the direction of the acceleration due to
gravity.  You just need to do some simple trigonometry to get the x,
y, and z components of that vector, then you can subtract that from
your acceleration vector.


~clark

On Apr 1, 10:29 pm, Gaizka <[email protected]> wrote:
> I am trying to write a simple app that calculates velocity based on
> the current acceleration (between sampling times).
> I have no problem obtaining the device’s acceleration from the
> accelerometer, nor calculating the velocity based on the reading.
> My question has to do with how to compensate for the fact that gravity
> (or the normal to gravity) is always part of the force exerted on the
> device.
> In other words if we were in space (or in microgravity), the device
> would have 0 acceleration on each axis when at rest. Moving the
> device, would show the corresponding acceleration and thus a simple
> calculation would derive the velocity.
> I read something about a Kalman filter to either low-pass or high-pass
> filter the change of acceleration.
> The only conclusion from that information was to use a high-pass
> filter to recognize the gravity vector then subtract that vector from
> the total acceleration vector.
> Does anyone have any sample code that shows how to account for gravity
> to obtain the net acceleration vector (once gravity is removed)?
> Maybe I am looking at this from the wrong reference frame…
> Should I instead use the GPS to obtain locations and calculate an
> average velocity based on distance over time?
> Maybe a combination of both?
> TIA
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to