mx = -IMU.getMagZ_uT();
my = IMU.getMagX_uT();
mz = IMU.getMagY_uT();
What I cannot do is get any sensible magnetometer output. The documentation suggests that it should be common to the accelerometer orientation. But when poking that into madwick algorithm and rotating the board through 4 cardinal points in the same plane its seems to produce about 80 degrees for 3 of them and 300 degrees for the 4th. The gyro makes the reading initially correct based on the rotation but then it is using the input from the magnetometer to correct it and its obviously producing nonsense.
Is my assumption correct that it should be the same as accelerometer sense? That being the case it must be massively bad calibration. I never really know what a figure of 8 really means when it comes to calibration. Other devices ask me to rotate it several times via x,y,z axes.
Is my assumption correct that it should be the same as accelerometer sense?
Yes, the magnetometer, accel, and gyro all share the same orientation.
Two potential issues I can think of:
I've seen some implementations of Madgwick that assume a certain sensor is being used and take input that does not share an axis system.
Magnetometer calibration is huge. Often the measurement value is less than the error, you absolutely need to get a good estimate of the sensor's bias and scale factor to use the magnetometer data.
In order to get the correct roll and pitch and yaw direction sense I am using the following translation.
IMU.readSensor();
//swap axes ax = -IMU.getAccelZ_mss(); ay = IMU.getAccelX_mss(); az = IMU.getAccelY_mss();
gx = IMU.getGyroZ_rads(); gy = -IMU.getGyroX_rads(); gz = -IMU.getGyroY_rads();
mx = -IMU.getMagZ_uT(); my = IMU.getMagX_uT(); mz = IMU.getMagY_uT();
What I cannot do is get any sensible magnetometer output. The documentation suggests that it should be common to the accelerometer orientation. But when poking that into madwick algorithm and rotating the board through 4 cardinal points in the same plane its seems to produce about 80 degrees for 3 of them and 300 degrees for the 4th. The gyro makes the reading initially correct based on the rotation but then it is using the input from the magnetometer to correct it and its obviously producing nonsense.
Is my assumption correct that it should be the same as accelerometer sense? That being the case it must be massively bad calibration. I never really know what a figure of 8 really means when it comes to calibration. Other devices ask me to rotate it several times via x,y,z axes.