DJI Mavic, Air and Mini Drones
Friendly, Helpful & Knowledgeable Community
Join Us Now

Compass error demonstration

sar104

Dic mihi solum facta, domina.
Premium Pilot
Joined
May 27, 2017
Messages
14,458
Reactions
19,469
Location
Los Alamos, NM
Site
www.mavicpilots.com
With compass errors arising from magnetic interference one of the major causes of problems, I thought it might be useful to show a controlled demonstration of how that works.

To recap, when the aircraft is powered up the compass (3-axis magnetometer) reading is used to initialized the IMU yaw value, after which the rate gyros are the primary source of rotation data that are used to update the IMU yaw value. The compass data are only used for low-gain (gradual) corrections for drift and bias in the rate gyro data. As a result, it's important that the IMU yaw is correctly initialized for the FC to know the direction that the aircraft is facing. If the yaw value is substantially incorrect then the FC will apply inappropriate corrections to try to hold position.

In this test, shown in the graph below, I used a small, rare-earth magnet to reverse the magnetic field at the M2P compass (it has only one), so that the compass measured the aircraft heading as north when it was really facing south. The magnet was just a few inches from the aircraft. On power up, the IMU yaw was incorrectly initialized at -46 seconds as approximately north, as expected. At -38 seconds I removed the magnet and, with the spurious magnetic field removed, the compass correctly changed to south. That would normally happen naturally as the aircraft took off and left the (small) area of magnetic interference.

At zero seconds I started the motors to generate a txt log file and establish which IMU was active. The txt OSD_yaw value is identical to the IMU1 yaw value, confirming IMU1 was active.

Note that although the compass and IMU yaw values disagree by around 180°, the IMU yaw value is held steady - that's because the rate gyros haven't detected any rotation. The aircraft reports a compass error but doesn't attempt to resolve the problem. At 33 seconds I rotated the aircraft to face north, as shown correctly by the compass. The rate gyros also detect the 180° rotation and, as a result change the yaw value by that amount to approximately south, even though it's now facing north.


73554

As you might expect, this kind of discrepancy would cause serious problems in any of the P modes, such as P-GPS. If, for example, when the aircraft was facing south but the IMU yaw value was north, the aircraft started to drift south due to a north wind, the FC will attempt to bring it back north. But since the IMU thinks the aircraft is facing north, it will do that by applying forward thrust (negative pitch). Since the aircraft is really facing south, negative pitch will actually push it further south. The FC will respond with more negative pitch, leading to uncontrolled flight to the south.

I'm going to repeat this test with an actual takeoff, but that requires a large flat field so that I can switch the aircraft to ATTI mode once it starts to fly off without worrying about obstacles. I'll post the results of that later. In case anyone else is tempted to try this, do not attempt unless you have ATTI mode programmed as one of the mode switch positions for when the flight goes bad.
 
Last edited:
@sar104 thats a very good explanation of why problems happen if there is magnetic interference on start up.
I have got into the habit of carrying a small pocket compass with me and i use it to align compass north on my take off pad
i hold the compass at waist height and find compass north then i lower it slowly on to the pad and see if there is any change in direction as i move it closer to the ground, if it moves i know there is some magnetic anomaly in the ground.
if all is well i power up the controller and once all is connected and the mav is powered up with GPS lock i check the compass heading in the app to make sure it it pointing to the small north indicator on the radar like display doing it this way may seem tiresome to many people,but for me it is time well spent. just like to add that the mav is placed on the pad facing the north symbol on power up
 
I'm going to repeat this test with an actual takeoff, but that requires a large flat field so that I can switch the aircraft to ATTI mode once it starts to fly off without worrying about obstacles
It’s really fun:cool:
It’s like riding a wild one directional bull full speed!
Now pull back! Not easy to land tho
 
It’s really fun:cool:
It’s like riding a wild one directional bull full speed!
Now pull back! Not easy to land tho

It's going to be fine once it's in ATTI mode, but I want to leave it in P-GPS long enough to demonstrate the extent of the problem. Much too windy today for that test though.
 
So, if you left the bird on the ground with motors running, removed the magnet from effective range of the bird, it would not correct after while, but possibly would if in flight ?
And in flight correction can come far too late to avoid flyaway or crash from reading various threads ?
 
it's important that the IMU yaw is correctly initialized for the FC to know the direction that the aircraft is facing. If the yaw value is substantially incorrect then the FC will apply inappropriate corrections to try to hold position.

Sometimes a message appears at startup saying "do not move aircraft. IMU initializing"
 
But since the IMU thinks the aircraft is facing north, it will do that by applying forward thrust (negative pitch). Since the aircraft is really facing south, negative pitch will actually push it further south. The FC will respond with more negative pitch, leading to uncontrolled flight to the south.

So, if a pilot rushes to takeoff, and the drone is showing a compass error message because of magnetic field disturbance, even though the drone lets the props spool up, there is a good chance that the drone will vier off to where it thinks its supposed to be and may end up in a crash.

I hear so many stories of people starting their motors, and then as soon as the drone breaks ground, it zooms off into something.
 
  • Like
Reactions: Cheech Wizard
@sar104 thats a very good explanation of why problems happen if there is magnetic interference on start up.
I have got into the habit of carrying a small pocket compass with me and i use it to align compass north on my take off pad
i hold the compass at waist height and find compass north then i lower it slowly on to the pad and see if there is any change in direction as i move it closer to the ground, if it moves i know there is some magnetic anomaly in the ground.
if all is well i power up the controller and once all is connected and the mav is powered up with GPS lock i check the compass heading in the app to make sure it it pointing to the small north indicator on the radar like display doing it this way may seem tiresome to many people,but for me it is time well spent. just like to add that the mav is placed on the pad facing the north symbol on power up

This is an interesting experiment. Have you seen the pocket compass needle swing substantially in any of your attempts?
 
  • Like
Reactions: old man mavic
So, if you left the bird on the ground with motors running, removed the magnet from effective range of the bird, it would not correct after while, but possibly would if in flight ?
And in flight correction can come far too late to avoid flyaway or crash from reading various threads ?

No - I've never seen an aircraft recover from a 180° error, or even a 90° error for that matter. Much smaller discrepancies are sometimes resolved by the FC physically rotating the aircraft while keeping the IMU yaw value constant (i.e. ignoring the rate gyro data) until it agrees with the compass. Obviously it cannot do that while on the ground though.
 
So, if a pilot rushes to takeoff, and the drone is showing a compass error message because of magnetic field disturbance, even though the drone lets the props spool up, there is a good chance that the drone will vier off to where it thinks its supposed to be and may end up in a crash.

I hear so many stories of people starting their motors, and then as soon as the drone breaks ground, it zooms off into something.

The aircraft often won't show a compass error while on the ground if the magnetic field is within tolerance. The compass error occurs after takeoff. In this experiment I got the typical "move or calibrate" message after removing the magnet but, unlike the time/distance calibration request that the M2 gives, it did let me start the motors.
 
If you switch to ATTI mode and stabilise the M2, when you switch from ATTI back to P-Mode, would the compass error return? I assume it won't re-initialise? Or once in ATTI mode, don't switch to P-mode until it's landed?
 
So, if a pilot rushes to takeoff, and the drone is showing a compass error message because of magnetic field disturbance, even though the drone lets the props spool up, there is a good chance that the drone will vier off to where it thinks its supposed to be and may end up in a crash.

I hear so many stories of people starting their motors, and then as soon as the drone breaks ground, it zooms off into something.
January 9 2015 @night
What a fight, my eyes got watery and the wind was a buzzing. People everywhere & me on Broadway wrestling something with lights in the sky
Some of us learn the hard way

Read the manual folks thoroughly (again) or suffer sooner or later somehow!
 
If you switch to ATTI mode and stabilise the M2, when you switch from ATTI back to P-Mode, would the compass error return? I assume it won't re-initialise? Or once in ATTI mode, don't switch to P-mode until it's landed?

The discrepancy between the compass and the IMU yaw values doesn't go away when you switch to ATTI - it just stops mattering since the FC is no longer trying to position the aircraft.
 
Lycus Tech Mavic Air 3 Case

DJI Drone Deals

New Threads

Forum statistics

Threads
131,232
Messages
1,561,075
Members
160,184
Latest member
peehead