Accelerometer - acceleration value help

I have a problem with the return value of accelerometer.

What is the unit of value returned? The help file shows that it is in Gs.

I guess: 1 G = 9,81 m/s². Is it correct or the unit is in feets?


1G = 9.81 m/s^2 = 386 inches/s^2 = 32.2 feet/s^2

You can convert it to whatever unit you want (the value returned by the WPILib routines is in G).


I have other problem…

I get the acceleration value (in G) and convert it for m/s². After this signal is integrated to obtain the velocity and do another integration to get the distance, but on the second integration the velocity never returns to 0 and as consequence the distance value continues raising.

I want to know how can I fix this problem or some ideia to stop the velocity integration.

Any idea?

you don’t stop moving…
your distance has no vector, victor. So your robot is tracking it’s forward motion, as if it is moving in a line… so even if you turn your program thinks your going in the same line. This could be corrected by assigning a angle to the distance, which could get very complex…

This is a very common problem with integration - what happens when the average value is NOT zero? Well, the integrator output just keeps growing and growing…

There’s an excellent chance that your accelerometer has a small amount of offset error. It’s unavoidable.

The only way to eliminate the growing error is to “de-drift” the offset error by folding in and “subtracting” a true heading/position sensor somewhere in the calculations (eg a magnetic compass or horizon sensor).

There is one other way - use a highpass filter on your accelerometer output. Unfortunately, you’ll never reliably measure DC accelerations (eg measurement of pitch/roll tilt) without that DC measurement.


You can’t do much about the constantly-increasing distance. You see the same thing with the gyro: it has a little bit of error in it, so the robot constantly drifts a little bit. You can work on your integration routines to make them a bit more accurate, but you’ll always have that little error.

To fix it:
-If you ever have a point where you KNOW the robot isn’t moving (encoder speed on a freely turning wheel = 0), then you can zero out the velocity and start integrating from there again
-Use encoders on a free wheel to track distance, rather than accelerometers. Encoders do not require any integration, and so have much less error. According to QA responses, you are allowed having an unpowered wheel touch the ground that isn’t a rover wheel, so long as it does not add substantial grip for acceleration or braking.