In-flight yaw realignments causing large yaw errors and crashes

Hi everyone, I am hoping someone will have some insight into a problem I have been facing. In flight yaw realignments seem to be wreaking havoc on a batch of aircraft I am testing. For some reason, about 5 seconds after takeoff, the vehicles experience a yaw reset which causes the new heading to be off by about 15-30 degrees. This causes some severe bowling.

The problem seems to sort itself out if i rotate the craft by 180 degrees and then back again.

I have a feeling this is related to the EK2_MAG_CAL parameter. This parameter is default set to a value of 3 and described as “enables calibration when the first in-air field and yaw reset has completed and is the default for copters” (

It is this initial yaw reset that causes a large error in the yaw estimate, but seems to be fixed by in flight calibration if the vehicle is rotated. Just for reference, the yaw value is correct when on the ground, and correct after some rotation (I am assuming due to in-flight calibration), but will remain incorrect for the entire flight after the initial yaw reset if I do not rotate the craft.

Any thoughts on why this might be? These crafts are autonomous and this issue has already caused 1 crash. I am hoping there is a way for me to preclude the yaw reset in order to have an accurate yaw estimate throughout the entire flight without having to program in a rotation sequence to fix this large yaw error after reset.

I have included some logs. Please see NKF3.IYAW vs ATT.Yaw plot below for a plot of what is going on when the yaw reset occurs. The current yaw value seems to change by the magnitude of IYAW at the moment when a yaw reset occurs. Sometimes a “ground mag anomaly” message occurs simultaneously, but not always.

This particular flight ended in a crash during a precision landing due to bowling. We use precision landing to ensure we always land on the landing platform which is raised above the ground, so small errors in yaw estimate can end catastrophically.

Here is a link to the corresponding log file:

Another example of the yaw reset having a large effect on yaw.

log file:

Final Note: We have other aircraft with nearly identical configurations for which this issue is not present. It seems to be occurring recently in a fresh batch of vehicles. All compasses are calibrated properly and we have calibrated for motor interference as well using the compass-mot calibration. Some vehicles exhibit this problem and others do not, but almost all recent vehicles do.

Configuration Details: Running Copter 3.5.5 on pixhawk 2.1 with DJI S1000 octa-frame with a Here GPS unit on a mast utilizing only the external magnetometer on the here GPS unit.

Any help or advice would be greatly appreciated.


1 Like