As for the flight with the problem - things are not always what they seem at first glance. The FC reported a magnetic heading error at 138 seconds:
and then attitude control failure at 140 seconds:
All typical of a heading problem caused by disagreement between the compass and IMU, and that disagreement clearly occurred. From the IMU data in the txt logs we see this:
and also the expected divergence in predicted position:
Ugly, but not due to a simple compass problem. This was failure of the active IMU - in this case IMU1. Looking at the aircraft quaternions the problem becomes more apparent:
It's not just the quatZ (describing yaw) that goes wrong - X, Y and W from IMU1 all diverge from IMU0. In other words IMU1 loses track of pitch, roll and yaw. The pitch and roll errors cause both the yaw error, because IMU1 now incorrectly interprets the magnetometer data, and is likely the primary cause of the control failure.
To be more specific the IMU1 rate gyro data go bad in all three axes. It looks like a completely out-of-calibration gyro package, but could also perhaps be a processor error. We've seen this a few times now on this forum with the Mavic 2, and it always seems to be IMU1 that goes bad. Or maybe IMU1 is the default IMU and so we don't usual notice when IMU0 loses it.
Either way, I'm not sure I'd trust IMU1, at least not without a couple of successful calibrations and some careful test flights. I suspect there are more clues hidden in the DAT file, but that's what I've found so far.
138.649 : 13503 [L-FDI]NS(0) FUSION(1): fault on , magn_heading_err_large
and then attitude control failure at 140 seconds:
140.049 : 13585 [L-FDI][CTRL]: fault on , horiz_ctrl_fail
All typical of a heading problem caused by disagreement between the compass and IMU, and that disagreement clearly occurred. From the IMU data in the txt logs we see this:
and also the expected divergence in predicted position:
Ugly, but not due to a simple compass problem. This was failure of the active IMU - in this case IMU1. Looking at the aircraft quaternions the problem becomes more apparent:
It's not just the quatZ (describing yaw) that goes wrong - X, Y and W from IMU1 all diverge from IMU0. In other words IMU1 loses track of pitch, roll and yaw. The pitch and roll errors cause both the yaw error, because IMU1 now incorrectly interprets the magnetometer data, and is likely the primary cause of the control failure.
To be more specific the IMU1 rate gyro data go bad in all three axes. It looks like a completely out-of-calibration gyro package, but could also perhaps be a processor error. We've seen this a few times now on this forum with the Mavic 2, and it always seems to be IMU1 that goes bad. Or maybe IMU1 is the default IMU and so we don't usual notice when IMU0 loses it.
Either way, I'm not sure I'd trust IMU1, at least not without a couple of successful calibrations and some careful test flights. I suspect there are more clues hidden in the DAT file, but that's what I've found so far.