# Obtain velocity by using accelerometer data

I have an accelerometer sensor, which obviously measures acceleration along the $$x$$, $$y,$$ and $$z$$ axes.What I would like to do is to obtain the velocity along these axes by using the accelerometer readings. I have thought the following procedure:

1. Get the accelerometer readings

2. Filter the data by some kind of filter (Lowpass, moving average etc)

3. Select a small time interval of the order $$\text{Δt} = 0.01\text{sec}$$

4. Use the velocity formula $$v = v_0 + a\cdot\Delta t$$

5. Update $$v_0$$ at each time step by using the previous calculated value $$v$$

I would really appreciate any thought on how precise this procedure would be or even any suggestion that would improve it. The goal is to obtain the velocity along the $$x$$, $$y$$, and $$z$$ by using the accelerometer data.

• another issue: how do you tell apart acceleration measurements due to angular velocity, vs due to d/dt of linear velocity? you could attack that issue with multiple accelerometers to cancel the components due to rotation, or a combination of accelerometers and angular rate sensors Nov 10, 2021 at 15:58
• another issue: what is the initial condition for the integration? you would get cumulative change in velocity (which is still very useful) Nov 10, 2021 at 15:59
• You could cheat the issue of cumulative error a little, in some systems, if you can assume the actual long term average velocity and acceleration are zero (or 1g for a_z). Thus having a reference point to calibrate away DC acceleration error component. Would still need copious calibration, but at least you wouldn't have the infinite velocity error at DC. Nov 10, 2021 at 16:07

First of all a couple of pointers:

• Essentially what you are proposing is integration.
• Whether the result is acceptable that is depended on the problem specifications.

Now, some details on the main problems:

1. Numerical integration and rounding error over a long period of time: The fact that you are using a filter (any filter for that matter) will not remove small rounding errors and (at the end of the day) numerical differences from the actual value. This will create the problem that eventually, after a (not so long time), a significant difference with the raw data will occur.

2. Orientation of accelerometer: I don't know the exact problem you are trying to apply (I've worked with this on human gait and it was a nightmare), but even a slight tilt or a wobble during the motion of the accelerometer will cause the readings of the accelerometer to be pointing to a direction different from the global xyz. So again, after a while the error accumulates and you seem to have a higher velocity.

There are ways to partially rectify this (e.g. using a gyroscope and rotating the local axis of the accelerometer to the global axis, or using a Kalman filter for the velocity if you have another method of measurement), however, --at least to my knowledge-- it is not feasible to get an accurate measurement of velocity only from acceleration measurements.

• "Kalman filter for the velocity if you have another method of measurement". Which one would be this method ? If I have a gyro and an accelerometer and use a Kalman filter I know I can estimate the rotation angles, angular velocity (in a fixed frame since gyro gives it in sensor frame) but how to obtain linear velocity if I measure linear acceleration and angular velocity both I sensor frame ? Nov 10, 2021 at 15:13
• The way I proposed the Kalman filter, is e.g. if you had a GPS system. I assume that the GPS would be able to take an update of the speed over larger distances (and its quite accurate), and between updates you'd use the accelerometer. So in essense you need two measurements for the velocity (one fast and not so accurate, and one slower but more trustworthy). The gyroscope has nothing to do with the Kalman filter, although you could use it to mitigate the error with the orientation of the sensor (if it is significant).. Nov 10, 2021 at 15:40