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” (http://ardupilot.org/dev/docs/ekf2-estimation-system.html)

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: https://drive.google.com/open?id=11ti4M9mnfbrcCDFWAG6Z4Ecf-b3Ukbr7

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.

Thanks,
James

1 Like

Hi James,
It’s a while since you posted on that topic and we encounter similar behaviour.
Have you found the root cause of it?

Kind regards

The root cause of it is incorrect mag calibration and incomplete configuration

Recently I also encounter similar issue. I thought it’s because my FC is too near interference source… But once it reset it’s back to normal

Thanks for the reply.

Just that I get the complete picture.
In-flight yaw alignment happens if the gyro stays steady until a certain threshold altitude while the magnetometer measures a “rotation”.
If there is a discrepancy it will reset the estimation of the kalman filter. The goal behind this is to account for magnetic noise on ground level.
Is that correct?

That means on a grass field we should not see a yaw alignment?

Unfortunately on some of our drones we see that behaviour, would that mean that we have noise on our drone itself?

Thanks!

There is always a “yaw realignment complete” shortly after take-off. That is normal and expected.

1 Like

Correct, in the first 3m after arming and taking off we do not allow the EKF to “trust” the compass very much for heading estimate. This feature was added to prevent the EKF learning a bias on the compass when it is close to magnetic interference on the ground. Examples being things like steel reinforced concrete or other nearby metal objects. However, a bad calibration or other sources of interference (e.g. EMI from high current) can cause the yaw realignment. The fact that you are getting a yaw realignment simply means that your compass heading and EKF heading are misaligned during the take-off and the EKF is doing it’s best to cope with the difference. To understand what the cause is needs some looking through logs.

Hi, thanks for your replies.
Not sure if I got it correctly, but @amilcarlucas says it’s normal and @IAMMATT says it happens if there is interference on ground or from the drone, that means should not happen all the time.
Thanks for elaborating a bit more.
The reason why we ask that we rely for our application on a good heading and we have the feeling, that our yaw does not exactly show the truth

There has to be some source of interference that causes sufficient difference in the mag heading to the EKF heading for the yaw realignment to happen.

The yaw realignment does not “always” happen. A well placed compass, with a good calibration, on a vehicle that is not near any sources of magnetic interference will not trigger the EKF to do a yaw realignment.

When you get to the right height (IIRC it is 3m) when the EKF is no longer allowed to perform the re alignments you will get a message. I think it is something like “yaw realignment complete”. You will always get this message. It is simply saying that we will not do any more realignments from here on out in this flight.

Having yaw realignments is considered normal as it is a feature that is there to help with getting based ground-based interface. So seeing it should not be of concern.

However! I see a lot of logs where the compass is measuring EMI from the vehicle itself. This is usually because people place the compass too close to batteries or high current wires. Therefore it is worth looking through logs to figure out what the source of interference is because it may effect flight performance in other phases of flight (not just the take off).

1 Like