"EKF3 IMU1 MAG0 IN-FLIGHT YAW ALIGNMENT" makes auto yaw when takeoff

There is a auto yaw action by the firmware when takeoff.

It didn’t feel good when take off, see 0:05 flight time in the video “EKF3 IMU1 MAG0 IN-FLIGHT YAW ALIGNMENT”

Is there anyway to fix it? What I’m expecting is a stable take-off, no kind of sudden auto-turn or any kind of like that.

Have you done in-flight magfit calibration as recommended by the ArduPilot documentation and automated in the ArduPilot methodic configurator software?

It has been calibrated by magfit for quite a long time ago. But it has this kind of auto alignment when magfit result applied.

It always does that. Did you takeoff from a metalic platform? Did you transported the drone for a long distance before takeoff?

Ah… … I have checked video just after magfit, there was not that much.

Maybe I have to re-calibrate it and check again. As I did installed digital camera, which needs more power, might have some side effect.

BTW, is it possible just align/update status of yaw, not turn the yaw direction?

Yes, do recalibrate whenever you change the hardware.

It seems out of the range.

EDIT: I think it’s another discussion here: Why magfit's output result is out of parameter range?

You can change EK3_MAG_CAL

I have changed the EK3_MAG_CAL = 2 ( Never).

But still I can see the EKF3 IMU MAG0 ground mag anomally, yaw re-aligned
EKF3 IMU MAG0 inflight yaw alignment complete.

I’m checking the parameter definition here

Right now, I don’t understand which one I should use.

I thought there are three sources for heading fusion:

  1. compass
  2. acc, which has 3-axis
  3. gps heading (in short time)

From what I’m experiecning, I think it might be due to mag issue(There is no large metal or EM filed).

I’m confused that if the heading fusion considers gps?


This determines when the filter will use the 3-axis magnetometer fusion model that estimates both earth and body fixed magnetic field states and when it will use a simpler magnetic heading fusion model that does not use magnetic field states. The 3-axis magnetometer fusion is only suitable for use when the external magnetic field environment is stable.

  • EK3_MAG_CAL = 0 uses heading fusion on ground, 3-axis fusion in-flight, and is the default setting for Plane users.
  • EK3_MAG_CAL = 1 uses 3-axis fusion only when manoeuvring.
  • EK3_MAG_CAL = 2 uses heading fusion at all times, is recommended if the external magnetic field is varying and is the default for rovers.
  • EK3_MAG_CAL = 3 uses heading fusion on the ground and 3-axis fusion after the first in-air field and yaw reset has completed, and is the default for copters.
  • EK3_MAG_CAL = 4 uses 3-axis fusion at all times.
  • EK3_MAG_CAL = 5 uses an external yaw sensor with simple heading fusion. NOTE : Use of simple heading magnetometer fusion makes vehicle compass calibration and alignment errors harder for the EKF to detect which reduces the sensitivity of the Copter EKF failsafe algorithm. NOTE: The fusion mode can be forced to 2 for specific EKF cores using the EK3_MAG_MASK parameter.
  • EK3_MAG_CAL = 6 uses an external yaw sensor with fallback to compass when the external sensor is not available if we are flying. NOTE: The fusion mode can be forced to 2 for specific EKF cores using the EK3_MAG_MASK parameter.

NOTE: limited operation without a magnetometer or any other yaw sensor is possible by setting all COMPASS_USE, COMPASS_USE2, COMPASS_USE3, etc parameters to 0 and setting COMPASS_ENABLE to 0. If this is done, the EK3_GSF_RUN and EK3_GSF_USE masks must be set to the same as EK3_IMU_MASK. A yaw angle derived from IMU and GPS velocity data using a Gaussian Sum Filter (GSF) will then be used to align the yaw when flight commences and there is sufficient movement.

Try this one - it should mean that alignment is already done when you take off

1 Like

OK, I saw the tech-support here: EKF3 IMU0 in-flight yaw alignment complete · Issue #24823 · ArduPilot/ardupilot · GitHub

I’ll apply EK3_MAG_CAL = 4 first. BTW, copter default is 3.

And at the mean time, I will try to know more, but apparently it has something to do with AP_NavEKF3. No that simple to understand.

@andyp1per After setting EK3_MAG_CAL =4 it will rotate some times, but it still will do kind of alignment action.

One more thing to mention: I can’t get magfit work, as Why magfit's output result is out of parameter range?

UPDATE: It seems there is something wrong with mag here: Why home icon is flicking, not locked?

@andyp1per I have got mag/gps issue solved, but it seems still has “IN-FLIGHT-YAW-ALIGNMENT”

Any other parameters that I should try?

I hope system parameters to be aligned, not the actual flight heading in Acro mode.

“IN-FLIGHT-YAW-ALIGNMENT” is a normal informational message, not an error.
This indicates the heading has been adjusted to match the GPS track. Yaw gets affected easily during takeoff due to the high current causing magnetic interference.
If you have a valid current sensor MagFit can really improve the compass calibration.

1 Like

In acro mode, the expectation is that the internal parameters are reset without affecting the actual heading course. Since it’s manual/acro mode and not loiter/stabilize, the system should maintain a steady course and keep the heading as it is being operated.

Yeah I have chatted to Leonard about this before. We think its a bug, but have not had time to look at it. A good fast rate attitude / replay log showing the problem would be helpful I think.

Maybe a photo or 2 showing the build of the craft can sometimes be helpful?

@prsh8ya Currently, it’s pointed to an issue when in Acro mode, which might need some code in AC_AttitudeControl or mode_acro.cpp to get rid of auto yaw action, just reset/align the heading status.

What have you got in mind, please share with us?

UPDATE: I have saw the code, but haven’t tried before I fully understand the difference of yaw alignment with stablize.