Yaw drifting in loiter mode version 4.1.0-dev EK3

Hello everyone,

We performed a couple flights yesterday using the 4.1.0-dev and the drone started to spin in loiter mode. It does not look like a bad compass since we had flown on that terrain several times. It looks more as the loiter mode control after there were a disturbance in yaw, started to command it to keep on spinning on that direction. We were using EK3. As it can be seen below, the pilot did not command yaw while the drone rotates (RCIN.C4 remains at 1500), and the yaw started to deviate (XKF1.Yaw, yellow) before the controller of the loiter mode (ATT.DesYaw, purple) commanded it to keep on rotating on that direction making everything worse.

Please find the log in the link below:

This happened at the end of the flight. I also noticed a bad variance until the IMU0 yaw aligned using the GPS:

Any idea why the loiter mode control did not command the yaw to correct the drifting?

It’s a bug, and it needs fixing. I see this as well. @rmackay9 @priseborough FYI

It looks like a motor issue to me. We can see motor 3 (front left) jumps to it’s maximum

… and the vehicle rotates forward and left (towards the failing motor)

The yaw rotation is not commanded. the desired yaw (in red) is being dragged behind the actual yaw (in green). The attitude controller never lets the yaw target be more than 10degrees or so from the actual. This is a safety precaution.

@andyp1per, I don’t think this is related to the issue you’ve found with non-compass drifting.

Thank you for your replies @rmackay9 and @andyp1per ! I was not aware about the 10 deg restriction for the setpoint. Indeed, in another flight it showed a similar behavior, but this time it triggered the potential thrust loss(3) message after some seconds:

On this flight it also drifted in a similar way in loiter mode, and it did not stop when we moved back to altitude hold:

Please find the log in the link below:

What can be producing the drone to command such a huge value to the motor 3? Today we performed about 5 flights with the same drone using the Copter 4.0.7 version in loiter mode and it performed perfectly, so it may not be a hardware issue since we did not change the hardware at all. The yaw drifting looks like a consequence of the controller thinking it needs to increase the speed of motor 3 since it happens just after it commands the high value as you pointed out:

Again, this only happens in loiter mode. Today, we also tried only flying in altitude hold and flow hold and we did not see anything similar.

The high motor output is most likely a natural result of the vehicle trying to maintain its attitude. I would be very surprised if the problem is software although anything is possible especially when using “latest” which has not been trough any beta testing.

I think it is most likely hardware and it will happen in 4.0.x as well.

I’d stick with the stable releases if possible. We will start beta testing of 4.1.0 in the next month or so but it is difficult for us to provide support for unreleased software.

Thank you for your help @rmackay9! I did switch to the master branch because I am very interested in the lane switch feature of the EK3 which as I understand it is only available in the master branch. Tomorrow, I will try flying in loiter mode with another drone to make sure it is not a hardware issue.

1 Like


Great stuff.

Yes, 4.1 has lots of improvements to the EKF including “affinity”, lane switching and sensor source selection. It should be a very significant release for AP.

You were right @rmackay9 , there was a problem with the ESCs. Now the drone is flying perfectly.

1 Like