xioTechnologies / Fusion

MIT License
988 stars 237 forks source link

Understanding FusionMatrix gyroscopeMisalignment #65

Closed LazaroFilm closed 1 year ago

LazaroFilm commented 1 year ago

When I rotate my sensor around the Z axis (on a turntable), I get the below graphs which shows some wobble in the roll and pitch with .gain to set to 0.0f to ignore accel input. I think I understand this "wobble" is due to a gyro axis misalignment. I'm trying to understand how the FusionMatrix works, but I'm not quite sure of the method to get the values needed for it. I understand each values is a multiplier to add some of the other axis input in another one, but I don't know how to tell which value and by how much... I've found this article but it hasn't quite helped me that much.

Matrix initial

and zoomed in version to focus on pitch and roll, recorded here are two full rotation so 720deg rotation it was turned by hand on a solid center axle, hence the roughness of the curve. I'm also aware of the gyro drift. I recorded this example right after powering up the IMU, it had not stabilized yet:

Matrix initial zoomed in

xioTechnologies commented 1 year ago

We do not have any tutorials or examples for the calculating a misalignment matrix. The article you linked looks like a good place to start.

On a separate note, I suggest you use the gyroscope offset correct algorithm as demonstrated on line 24 and line 51. Adding these two lines of code will correct for the drift apparent in your plots.

herbertvuijk commented 1 year ago

This guy made a calibration that is very similar to the misalignment matrix used by the xio Fusion algo. It's for an accelerometer though, but I guess the principles are the same.

By the way I found out by testing that you indeed have to do like a 6-orthogonal calibration for the accelerometer as offsets and gains are different in every position. A gyroscope though, seems to have the same offsets regardless of orientation. So I guess you don't really need a misalignment gyromatrix. Instead you can just substract a constant value that you have measured.

Here an example of a calibration matrix (offset, gain, angles):

https://github.com/BasicAirData/Clinometer/blob/master/app/src/main/java/eu/basicairdata/clinometer/CalibrationActivity.java