Im trying to get as much info on imu design.

I have tried a bno055 in NDOF mode with and without fast cal. and also in ACC-MAG-GYRO mode, really at best it worked in the ndof mode. I used eulerangles.

For an autopilot, I am interested in a stable z axis, meaning pitch and roll, but mainly roll. to keep the craft upright. For now I`m into planes.

When I put the Arduino with an LCD indicating roll pitch and a heading, in my car, I was not vey happy, with quickly losing calibration, showing wrong all the axis. I have now replaced the heading sensol with a hmc5883L, that improved the heading. After reading through some foren, I found that eveybody has those problems.

Then I read about quaternions, and rotation matrixes, to improve stability.

Does someone know how to work with quaternions in a rotation matrix? is it as simple as to update the matrix with fresh w, x, y, and z values comming from the sensor? Or do I have to do some calculations befor I even can use those values to put them into the Matrix.

And then I don`t understand what should happen next. Why do I put those values in the Matrix, what happens after? What I want, is to get Angles theta, phi, psi. I could convert w, x, y, z quats right away, as they come from the sensor.

There is a bno055 library, called quaternion.h, it seems to have everything needed for a rotation matrix using quaternions, to get stable angles at the end. I couldn`t find any codes samples that would interface it though.

An other thing is, maybe it isn`t really necessary to go through all the math required, just to have a few more seconds accurate readings, if I have to use some reset procedure any way.

For example I sure know that the plane is wings level, when the compass changes its trend, same for pitch with an accurate baro sensor. Also groundspeed from gps can be used with gyroscopes, to correct for centrifugal force.

Appreciate any help,