The MPU-9250 has a built in magnetometer which up to now I’ve been ignoring. However while I’m stuck waiting for stuff in the post, I’ve given it more than a seconds thought and it could be useful.
The magnetometer is reading the strength and direction of the local magnetic field, primarily from the Earth’s magnetic north pole. So it can be used for knowing the direction a flight is taking which is useful if the flight is tracking between a series of GPS positions. That aspect is of no interest to me at the moment, but there’s another trick.
Because the output of the magnetometer is a vector of the local magnetic field, it can be used to calculate the absolute quad-frame pitch, roll and yaw angles since take-off – exactly what the integrated gyro is doing short term. But because the magnetometer gives absolute angles based upon an absolute fixed source, the magnetometer angles can be fused with short-term integrated gyro readings to keep them very tightly on the straight and narrow.
Use of a magnetometer as a backup a yaw sensor is common, but I’ve not come across it being used as an absolute pitch, roll and yaw sensor.
There is only one problem I can see, and that’s that metals in the flight area distort the earth’s magnetic field, so some care is needed fusing the readings to ignore any rapid changes that don’t match the gyro integration.
For now though, I’ll just be adding the magnetometer readings into the diagnostics, polling it perhaps once a second just to check the validity of the readings compared to the integrated gyro readings. If that holds out, then this could lead to much longer zero drift flights.