kck
kck

Reputation: 163

Get distance and velocity from discrete accelerometer data

I know there has been a number of questions and answers on this topic, but none of them has helped me to understand how to approach the problem. So my set-up is: I have accelerometer data (clean from the gravity part), and I'd like to calculate from the given sample velocity and distance. The data is discrete, say, dt = 20ms, and acc = [...] is the array with samples. I understand that I need to integrate the array to get velocity, but the integration gives me a single values, doesn't it?

velocity = scipy.integrate.simps(acc, dx=dt)

How do I use this value to get the distance afterwards?

Upvotes: 0

Views: 6579

Answers (1)

Julien Goupy
Julien Goupy

Reputation: 165

a = dv / dt

ie

a x dt = dv

Integration :

a[i](t[i+1] - t[i]) = v[i+1] - v[i]

ie

v[i+1] = a[i](t[i+1] - t[i]) + v[i]

After computing v, you can compute x :

x[i+1] = v[i](t[i+1] - t[i]) + x[i]

Upvotes: 3

Related Questions