Help needed with yaw drift

I have a weird problem with my yaw drifting and I’m not sure why it happens.

I recently installed a couple of RM3100 magnetometers on the arms of a large hex (12kg without payload), configured them as the highest priority magnetometers (leaving the internal one as the third priority). The symptom that I found is that while the drone is on the ground the yaw keeps drifting: it usually picks a direction to drift toward and then it goes. Remarkably linear. The rate is about one degree per second, and it drifts 20-30 seconds at a time, then it slows down, then sometimes stops, and sometimes it goes backwards.

Have a look at the attached picture - for most of the time in the picture (in the middle) the drone is on the ground and not moving. Weirdly enough both the desired yaw and the “measured yaw” (based on the ATT dataflash log) are drifting in tandem (while the drone actually stays still). In case you wonder, the two changes in the desired yaw are the disarm and arm commands (in between it was disarmed).

Initially I feared that it’s the magnetometers: being both on the arms and under the RC antennas they are bound to have noise. However, we twisted the power wires going to through the arms to the motors, and the magnetometer is in the null of the antenna. Looking at magnetic fields during this time, they do not change (at all). Furthermore, we tried the compass-motor calibration and the interference was minimal (for our flying current of about 40A we had about 10-15% interference, well below the 30% where we need to worry about). Furthermore, the compas-motor tool seems to say that not much can be done to the compasses (I think).

What I suspect is happening is that this drone just had a … let’s call it a rough landing. OK, it was a crash, and that might have messed up the first z-axis gyroscope. Checking the log, it does show that gyroscope 0 has a constant bias with respect to gyroscopes 1 and 2. It kind of makes sense that if it thinks it constantly turns, then the integral of that turn will change the yaw linearly.

However, when I looked (a bit - both online and in Mission Planner) on how to disable gyroscope 0 (or even change the priorities) I was unable to find how to do it. I can’t physically disconnect it since it’s in the autopilot itself (a cube orange).

Other potential relevant information: immediately after an in-flight calibration of yaw the drone flew beautifully. Then we put it on a test stand and tested the compass-motor tool. Then flew it again and it started drifting, toilet-bowling in LOITER, and throwing compass errors like crazy in flight (even in ALT-HOLD). BTW, the drift also happens in flight: when the drone should stay put (hands off of the yaw) it keeps slowly (but visibly) drifting in yaw.

So, for questions:

  1. is there a decent way of disabling one of the gyroscopes (to see if that’s the problem)?
  2. is there some other “known” cause for constant drift in yaw?
  3. anything else you think it’s worth trying?

BTW, the compass-fit tool shows that the two RM3100 magnetometers on the arms are far superior to the internal magnetometer on the cube-orange (the error is 3-4 times larger on the internal magnetometer).

Thank you for the help,
Mihai

In case anybody has the inclination to see a log, here is a relatively short one - all in ALT-HOLD. In the middle for about a minute the drone is landed and the yaw is happily drifting (two separate rates here):

I double checked the gyroscopes in this log and they don’t seem to fit my story with the broken gyroscope. Besides, the EKF was supposed to detect and correct such a bias, so I’m not sure if the broken gyroscope story “holds water”.

But then, what messes up the EKF?

Any ideas are welcome!
Mihai

The compass calibrations are all out somewhat

Y and Z axis are probably fixable with Magfit, but X axis is quite wrong even after calibration

There is some accelerometer drift, but it’s only small. The flight controller would probably benefit from doing the temperature calibration procedure - let’s see if that helps.
https://ardupilot.org/copter/docs/common-imutempcal.html

Carefully check the orientation of all the compass units.
Can you do another flight with yaw in one position, and yaw and circles over a wider area, even a figure-8 if you can.

If you do not want to install python to run the imu temperature calibration then use the methodic configurator. It provides the same functionality in a gui with a progress bar.

Thank you for looking Shawn.

I’m not sure what to do about the magnetometers other than to move them away from the arms. It’s that or the calibration sucks. I think that the flight I posted was after I did an “in flight” calibration. Is that “inferior” to the other two options? Is one calibration “better” (as in producing a better final result) than others?

Also, can you tell when the calibration went well and when it did not (especially at the field)? Looking at the graphs you posted, it does seem that x axis is seriously off.

The magnetometers are mounted on the side arms (it’s a hex x) pointing directly forward, but I’m not sure if the orientation parameters are correctly set - as far as I figured out they are “automatically” set by the calibration procedure. I guess it could automatically set them wrongly :frowning:

Thanks,
Mihai

Lucas,

what is the Python script that you mention? I’m desperate enough to try everything :slight_smile:
Mihai

No need for any python script.

Use ArduPilot methodic configurator software and it will guide through a sequence of field-proven steps that guarantee a working vehicle if you follow the instructions to the letter.