Transforming acceleration from the body frame to the inertial frame using the Madgwick Filter

I just learnt Arduino a couple of weeks ago and my goal currently is to obtain position from accelerometer and gyroscope data. To do this, I am using quaternions, which I obtained through the Madgwick filter. These are the steps that I am trying to follow:

  1. Get accelerometer and gyroscope raw data.
  2. Input them in the Madgwick filter to get quaternions.
  3. Calculate rotation matrix from quaternions.
  4. Implement the rotation matrix to the body-frame acceleration in order to obtain the inertial-frame acceleration.
  5. Double integrate the inertial-frame acceleration to get position.

However, as I read in Madgwick's paper, the filter fusion algorithm outputs an estimated orientation of the sensor frame relative to the Earth frame. On the other hand, I am looking for the orientation relative to the inertial frame. Is there any way to do this such as convert the gyroscope data from body frame to inertial frame before inserting it to the Madgwick filter or transform the quaternions from body frame to inertial frame?

I am hoping someone could point me to clear resources on this sort of problem, or explain the procedure, and would be deeply grateful for any assistance.

Integrating an accelerometer to get position has all sorts of issues , a knock will
Make it think it’s accelerated off somewhere .

Some fancy named stuff in your post !

Sadly, that won't work. The question comes up at least once a week on this forum, and no one has to my knowledge reported success.

For an explanation of just one of the major problems (subtracting the estimated gravity vector), see this blog post.

A company I worked for years ago tried doing this with a laser scanner to eliminate the tracker and it was painful to say the least. How much accuracy are you looking to obtain?

Gyroscopes drift too.
It would be useful to know a bit more about the project and what you are attempting to do - there may be other ways ..

Probably needs a Turbo Encabulator

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.