Near crash amidst multiple "EKF yaw reset" messages. Logs inside

Hello, I had a mostly good test session of our aircraft yesterday ( see blog for more information ). But also experienced some extremely erratic flight behavior. This is not the first time, but this time I have both the .tlog and .bin for anyone who would be willing to give it a look-over.

.tlog - begins during VTOL Take off around 15.7 %

0003.bin - VTOL takeoff at at 87 min

The .tlog tells the story pretty well. Basically, while taking off in Q_stabilize, I notice the aircraft is oddly drifting UPWIND. As I ponder this anomaly and gain altitude the plane aggressively changes pitch and takes off on a new course as I attempt to maintain position overhead, meanwhile messages are rolling in:

EKF yaw reset -0.62
EKF yaw reset 2.11
EKF yaw reset -5.48
EKF yaw reset 50.23
EKF yaw reset -105.87
EKF yaw reset 106.13

Eventually it stabilized and I risked transitioning into FBWA then AUTO as I prefer to let the aircraft charge in flight whenever possible. The rest of the flight was uneventful with a very nice Hybrid RTL at the end.

Note: On a typical Q_stabilize takeoff, I only apply throttle and small amount of rudder to face the AC into the wind for transition. In this case, I was much more active on the controls once I noticed the AC was pitching and rolling un-commanded.

Also see here ( 0002.bin @ 37min ) for a very similar episode but in fixed wing mode immediately after switching from FBWA to AUTO. Almost crashed and multiple EKF yaw reset messages then as well.

Any Ideas? Keep in mind this aircraft and very similar versions have flown around 100 hrs. with tons of transitions. The vast majority of the flights are very uneventful despite various tuning issues (see blog)

Extremely curious what I may be doing incorrectly that is causing/contributing to this abnormal behavior.

Thanks for looking,

Ryan

1 Like

thats a 450MB log! Unfortunately someone with a faster internet connection is going to have to look at it for you :slight_smile:
I’d actually be interested if someone tried out plot.dron.ee so giving that a look might be worthwhile.

Yes, unfortunately, if I don’t remember to regularly unplug the batteries or do a reboot_shutdown every landing, the logs get a little large.

hi Ryan,
The problem you have is a large amount of motor interference with your compass. It is so bad that basically the plane has no idea what way it is facing until you have flown in fixed wing mode for a few seconds and the EKF is able to sort out yaw using GPS data. Both of your compasses are bad.
You have a few choices:

  • fix the motor interference by getting the compass away from current sources (eg. wires that carry significant current). That is the right fix.
  • calibrate the compass using log data, so that the calibration takes into account the motor interference. I’ve done that below for your log
  • use the motor interference settings to tell ArduPilot how to compensate the compass for the motor interference

For the 2nd option, I ran a simple log calibrator over your log, and got this:

COMPASS_OFS_X=-177
COMPASS_OFS_Y=72
COMPASS_OFS_Z=35

this compares to the settings you had in the flight which were:

COMPASS_OFS_X=281
COMPASS_OFS_Y=-38
COMPASS_OFS_Z=-19

you can see that on the X axis there is a difference of 458. That is stronger than the earths magnetic field. So you really had no chance of getting good yaw.

I recommend you instead setup a compass that is well away from current sources. You really do need a good compass on a quadplane or you risk getting very bad automatic takeoffs, and if you ever lose GPS lock in flight then the plane won’t be able to come home at all.
Cheers, Tridge

1 Like

One again, thank you for reviewing the log.

I have been working on the compass issue since your first suggested it, (and before) I assumed that compass errors would not (could not?) contribute to the drastic pitch and roll errors, However, after reading up on the (basic) EKF functions on the Dev page I realize that the magnometers influence on attitude and position is not to be taken lightly. To me, the logs seem to show that the “abnormal maneuvers” were likely a result of bad position estimation over bad attitude, and the EKF disagreed with the GPS position so the aircraft aggressively attempted to maneuver to the estimated “good” position?

I have a couple specific questions that might help streamline my efforts to find accurate heading:

  1. What EKF_MAG_CAL parameter is recommended for a Quadplane? I am currently using “0”, should I consider disabling in flight calibrations?

  2. I plan on moving the GPS/Magnometer out to a wingtip for testing next. That is as far away from interference as I can get but still within 3 feet of multiple 1-2 ft runs heavy gauge wires that carry up to 145 A at ~50 volts DC during takeoff. To my under standing he AC power between the ESCs and motors are less likely to cause interference.

I assume the potential magnetic field extends past the wing tips at times during VTOL take off. Considering this, would one consider reducing the EKFs dependence on the magnometer? (EK2_MAG_I_GATE) I notice that this parameter is already on the low end.

Of course I’ll start with simply moving the MAG as far as possible from interference, just curious.

Thanks,

Ryan

I’d recommend to use the default value of 0 for EK2_MAG_CAL.

when you do, note that you should set the X,Y,Z offset of the GPS from CoG (its not a big factor, but might as well). See the GPS_POS_{X,Y,Z} parameters

3 feet is a long way for a mag as the interference drops as distance squared. I’d be very surprised if there is any interference at that distance. It’s easy to test though. Arm on the ground and run up the motors (with props on unfortunately, you need the load) and see if the magnetic field strength shown on the GCS changes.

during takeoff the compass is your only source of yaw correction, so you do need it. You’re getting away with it now as your takeoffs are quite fast, so the gyro drift is small. If you tried to hover for a while it would start drifting off position quite badly and could even crash.

yep! thats the best way

OK, thanks @tridge . I moved compass as suggested and documented it and some other anomalies on the blog: Introducing Hybrid Project

New photo by Ryan Pope

Hi,

you said it is possible to calibrate the compass using log data. Can you explain me how to do this?

Thanks.

Hi

Did you find a solution for this. I’m facing the same issue,
Trying to take off my 7kg VTOL. in Qstablized mode.
When I increase the throttle it gives compass error. And EKF_YAW_RESET . And aircraft badly flips over and wobble on takeoff.
Almost crashed, what should I do??