3
votes

I'm using an IMU (3 axis accelerometer, 3 axis gyro, 3 axis magnetometer), and I want to get the linear acceleration from the accelerometer data. I knew about sensor fusion and the ability to use the gyroscope data (and get orientations) to get the gravity vector, and hence removing its effect from the corresponding axes.

Am I on the right path, and could you help if you can?


after that I'll integrate the acceleration twice to get the position as in following
        CurrentAcceleration[0] = e.Accelerometer[0];
        CurrentAcceleration[1] = e.Accelerometer[1];
        CurrentAcceleration[2] = e.Accelerometer[2];

        //we need to get the linear acceleration instead of the read data !!

        CurrentVelocity[0] += (CurrentAcceleration[0] + PreviousAcceleration[0]) / 2;
        CurrentVelocity[1] += (CurrentAcceleration[1] + PreviousAcceleration[1]) / 2;
        CurrentVelocity[2] += (CurrentAcceleration[2] + PreviousAcceleration[2]) / 2;

        Position[0] += (CurrentVelocity[0] + PreviousVelocity[0]) / 2 ;
        Position[1] += (CurrentVelocity[1] + PreviousVelocity[1]) / 2 ;
        Position[2] += (CurrentVelocity[2] + PreviousVelocity[2]) / 2 ;

        PreviousAcceleration[0] = CurrentAcceleration[0];
        PreviousAcceleration[1] = CurrentAcceleration[1];
        PreviousAcceleration[2] = CurrentAcceleration[2];

        PreviousVelocity[0] = CurrentVelocity[0];
        PreviousVelocity[1] = CurrentVelocity[1];
        PreviousVelocity[2] = CurrentVelocity[2];
1
The code has a couple of errors. Even if you fixed it, it wouldn't work.Ali
I've read some research papers, and found you are right, we need another device to help (something like GPS to correct the error), however the theory is right. anyway thanks for the help, sorry for being late evaluating the answer. Accepted answer.Mokhtar Ashour
Upvoted your question, and I am glad I could help.Ali

1 Answers

3
votes

Won't work.

You cannot get accurate location or even velocity. On the above link you find tips what you actually could do instead.

By the way, this question pops up surprisingly often.