ICM20948 correcting the rotation axis of the gyroscope

Hi, I am using the ICM20948 9DoF motion sensor breakout on my Pi2Go-Mk2 robot and I would like to be able to correct the rotation axis of the gyroscope. I think I should be able to use the accelerometer data of it to do that. As the πŸ€– robot is a cart, which is always plane (or how do you say that?, in the same horizontal level on 2 wheels and a ball), I get fixed readings for the accelerometer: X = 1.00 Y = 0.05 Z= 0.00 (stationary, of course).

I could be lazy and try to adjust the breakout (using an extender) so the Y-reading is also 0.00 , but how would I do this in Python code? My aim is to have the robot make rotations in degrees Β° as exactly as possible. It is pretty accurate already, but if I make a few 90Β° rotations, I can see that there is a deviation. I think this is because of the orientation.

πŸ€– Any help or ideas are much appreciated! πŸ‘

Well, considering that:
-1- I am not that interested in the mathematical details of the gyroscope
-2- I just like the robot to make accurate, reproducible, turns

A correction factor will do fine! This is an even more lazy option, but it works and that’s what counts in the end πŸ˜‰.