6-axis IMU orientation algorithm?

Hey all!

I am trying to make a mini RC plane with an Adafruits ItsyBitsy M4 as the brains and a BMI160 6-axis IMU (almost identical to the LSM6DS3 IMU on the nano33).

My question is, how can I get a reliable orientation out of this?

All I need is an algorithm/function to convert the values to some sort of orientation, preferably one that gives roll, pitch and maybe heading (not necessary) that I can use for self-levelling and other stuff.

Any suggestions would be appreciated!


With a six axis sensor you can get roll and pitch. Relative heading is possible (for a short time), but it will drift.

Popular algorithms are Madgwick, Mahoney or Kalman.

Or just buy an BNO055 orientation sensor, which has its own microprocessor/algorithm.


I have been fiddling with the Mahony algorithm and it seems to work great!

I only really pitch and roll so heading drift doesn't matter.

The reason I am not using a bno055 is because I am maybe going to make a kit and a 6-axis IMU is way cheaper.

Thanks for your help!

Good choice, and good to hear about your progress! When you are ready, please post the code and tell us more about your application and/or any innovations.

Strictly speaking there are only 3 axes, a combination of 3-axis accelerometer and 3-axis gyro is usually described as a 6 DoF sensor (degrees of freedom).