MAVLINKGPS

Mag Interference

The Compass Problem

ArduPilot relies on a Magnetometer (Compass) to know which way is North.

  • Outdoors: The Earth's magnetic field is clean.
  • Indoors: Steel beams, rebar, and high-current electrical wiring warp the magnetic field.
  • Result: The "North" vector spins as you fly past a pillar. The EKF becomes confused, rotates the velocity vector, and causes the drone to fly sideways ("Toilet Bowling").

Solution 1: Gaussian Sum Filter (GSF)

You can fly completely without a compass by letting the EKF "learn" heading from movement.

Configuration

  1. Disable Compass: COMPASS_ENABLE = 0 (or COMPASS_USE = 0 for all instances).
  2. Enable GSF: EK3_SRC1_YAW = 8 (GSF).

The Flight Procedure

The GSF cannot determine heading while sitting on the ground. It needs Velocity to calculate Course.

  1. Arm & Takeoff: You must take off in AltHold (non-GPS mode). Do not try Loiter yet.
  2. Align: Fly forward briskly for 5-10 meters.
  3. Lock: The EKF will observe that the GPS velocity vector aligns with the IMU accelerometer vector. It "snaps" the heading to the correct value.
  4. Loiter: Once the "EKF Yaw Alignment" message appears (or you see the heading snap on the GCS), you can switch to Loiter.

Solution 2: External Yaw (GPS Yaw)

If MAVLink GPS provides a valid heading (e.g., from Visual Odometry or a Dual-Antenna setup):

  • Config: EK3_SRC1_YAW = 2 (GPS).
  • Benefit: The heading is valid instantly on the ground. No "alignment flight" needed.

Source Code Reference