After implementing the madgwick algorithm on it, I noticed that the accelerometer, the gyros and the magnetometer were not lining up. The resulting coordinate system wasn't even direct.
The following code corrects the results of the accelerometer and gyro :
acc,gyr,mag=(self.imu2.getMotion9())
acc[0],acc[1]=-acc[1],-acc[0]
gyr[2]=-gyr[2]
gyr[0], gyr[1] = gyr[1], gyr[0]
Now, for the acc. and the gyro. : the z axis points toward the ground, x follows the arrow on the PCB and y is such that the coordinate system is orthogonal direct.
I don't know how to check if the magnetometer is aligned, but after calibrating it (and correcting the acc and gyro), the madgwick algorithm gave me the right pitch, roll and yaw, with very good performances
After implementing the madgwick algorithm on it, I noticed that the accelerometer, the gyros and the magnetometer were not lining up. The resulting coordinate system wasn't even direct.
The following code corrects the results of the accelerometer and gyro :
Now, for the acc. and the gyro. : the z axis points toward the ground, x follows the arrow on the PCB and y is such that the coordinate system is orthogonal direct.
I don't know how to check if the magnetometer is aligned, but after calibrating it (and correcting the acc and gyro), the madgwick algorithm gave me the right pitch, roll and yaw, with very good performances