Acceleration to Displacement

1.1k views Asked by At

I'm doing an experimental program. I've a smartphone fixed on the car dashboard with a support, during the travel I read from an application some value from inertial sensor.

Precisely I read, Accelerometer Data Time (at fixed interval) of each registration in seconds.

So now I would want to pass from vertical acceleration to vertical displacement, to do this I should do a double integration.

I tried the Euler method. From initial condition like:

v0=0.v0=0 this is initial velocity at time zero.

x0=0.x0=0 this is initial position at time zero.

define,

deltaT=registrationinterval.deltaT=registrationinterval (in my case 0,04s)

then for each registration made, I do:

vi=vi−1+ayi∗deltaT.vi=vi−1+ayi∗deltaT

xi=xi−1+vi∗deltaT.xi=xi−1+vi∗deltaT

where i represents the current, and i-1 precedent.

But the chart that I get is not very realistic, in fact both the speed and the displacement are only grow, instead the effect that I had to get is that the vertical displacement came out as something similar to the acceleration graph.

Given that applying this procedure, I also a high error, it is possible that the graph is only growing, and I do not see any kind of vertical oscillation?

I also read the Kalman filter can be applied in advance to clean the signal, could be a solution?

Or should I change the method of integration and switch to the Euler from Runge Kutta? (The last, however, I have not the slightest idea of ​​how it could be set).

Or someone know an algorithm that can be help me?

Here there is an example of the data registered if can be helpful:

1

There are 1 answers

0
Adrian McCarthy On

Both Euler and Runge Kutta are numerical integrators. One may be more precise than the other, depending on they types of equations you're integrating, but both should give the same quantitative result. If one gives you an ever-increasing speed and the other doesn't, then you have a bug.

I think this is more of a physics problem than a programming problem.

From the data, it looks like the vertical accelerometer data includes the acceleration due to gravity, which is about 9.8 m/s^2 at the surface of the earth. Of course, your car is supported by the road, so it's not actually accelerating down.

The equations you're using assume that there are no other forces at play, so they correctly indicate that the car's speed and position would be constantly growing (as if you'd dropped the car from a helicopter). But there are other forces at play (the road pushing up on the tires), so you have to find a way to model those forces.

One thing you could do is average the first few measurements as a baseline (which should come out close to 9.8 m/s^2), and subtract that value off the subsequent readings. As the car moves up and down the hills, the sensor values will vary with respect to the baseline, and those differences are what you care about.

That's a fine first approximation. But when you go up or down a hill, the phone is no longer level with respect to the gravitational field, so part of the gravitational force will be reflected in the horizontal sensor. For precise results, you'll need to account for that.