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

Compass error demonstration

I was referring to the IMU_ATTI(0):Yaw-magYaw field. Thanks, all makes sense now.

Oh right - from the DAT file. Yes - that should be equal to the declination, because the FC adds the local computed declination to the magnetic yaw.
 
  • Like
Reactions: Gryphon962
Long time ago I had very erratic behaviour once with my MP when taking off from the backyard. I took off from grass but there’s a (reinforced!) concrete small terrace near about 5ft or 1,5 m from the take-off point. No compass error until AFTER takeoff and crazy drifting followed immediately, any steering input made it worse. (And I am a very experienced rc pilot) This must have been the start of the fatal flyaways I have read about many times, I @*$#-ed myself !! However, I was able to bring it back and landed. After checking, I discovered that I was still too close to the concrete. Since then, wherever I fly, I always go into the main>Advanced>sensors>compass settings to check for interference before arming and NEVER had a problem since.

Although the compass / imu discrepancies don’t appear until after takeoff, you can predict it by checking the above setting page. You want to see only a small green dot in the interference bars .
Mandatory check for MP, and I think personally that this prevents many, many problems.
 
  • Like
Reactions: old man mavic
Great read @sar104 , I have on my preflight checklist to go to Settings>Advanced Settings>Sensor State>Check IMU and Compass.

I've never had a disruption on my flights so no idea on how it looks when there a magnetic interference in place (other than expect a red line of some sort), would you be so kind to show us a screenshot of what it looks like when the magnet is near?

That was trickier to do than I expected since the magnetic interference level shown in the app doesn't appear to be recorded in the logs. I ended up having to synchronize a screen recording with the DAT file. Anyway, below is a graph showing the three orthogonal components of the magnetic field as detected by the magnetometers, as I manipulated the ambient magnetic field. The parameters displayed are the overall field strength, and the deduced magnetic yaw. Across the top is the compass status as shown in the app (example screens below), which can take the levels "Excellent" (green, 0 - 300), "Good" (yellow, 300 - 500), "Poor" (red, > 500) and "Abnormal" (unrelated to interference level). The aircraft was stationary and facing south (180°)

By inspection, at least in this test, it appears that the interference level is directly related to the magnetic field strength, with green being in the range 1200 - 1800 (unknown units) and zero interference at 1500.

74309

Note that in the 150 - 160 seconds range the field strength is almost exactly nominal, and interference was in the green until something killed the solution and the aircraft reported abnormal compass data. It immediately went back to green when I removed the applied field.

Also note, for those of you who rely on the interference level to decide if there is magnetic interference, that for several periods the interference level was comfortably in the green but the measured yaw was significantly wrong - the same situation that I created in the previous flight test. You cannot rely on the interference level - the only reliable test is that the direction arrow is correctly aligned relative to north.

74315

This is a green status with the value so small that you cannot see the color - I adjusted the applied field to give the aircraft an exactly nominal magnetic field strength (1500).

74312

74310

74313

74316

Abnormal compass data screen
 
That was trickier to do than I expected since the magnetic interference level shown in the app doesn't appear to be recorded in the logs. I ended up having to synchronize a screen recording with the DAT file. Anyway, below is a graph showing the three orthogonal components of the magnetic field as detected by the magnetometers, as I manipulated the ambient magnetic field. The parameters displayed are the overall field strength, and the deduced magnetic yaw. Across the top is the compass status as shown in the app (example screens below), which can take the levels "Excellent" (green, 0 - 300), "Good" (yellow, 300 - 500), "Poor" (red, > 500) and "Abnormal" (unrelated to interference level). The aircraft was stationary and facing south (180°)

By inspection, at least in this test, it appears that the interference level is directly related to the magnetic field strength, with green being in the range 1200 - 1800 (unknown units) and zero interference at 1500.

View attachment 74309

Note that in the 150 - 160 seconds range the field strength is almost exactly nominal, and interference was in the green until something killed the solution and the aircraft reported abnormal compass data. It immediately went back to green when I removed the applied field.

Also note, for those of you who rely on the interference level to decide if there is magnetic interference, that for several periods the interference level was comfortably in the green but the measured yaw was significantly wrong - the same situation that I created in the previous flight test. You cannot rely on the interference level - the only reliable test is that the direction arrow is correctly aligned relative to north.

View attachment 74315

This is a green status with the value so small that you cannot see the color - I adjusted the applied field to give the aircraft an exactly nominal magnetic field strength (1500).

View attachment 74312

View attachment 74310

View attachment 74313

View attachment 74316

Abnormal compass data screen
You didn't exactly say so but the green magnetometer interference range corresponds to the acceptable magMod range for the P3. And 1500 is the exact middle of that range. This makes it all the more likely that magnetic interference is just field strength.

But, I'm curious about abnormal compass reading in the [150 - 160] secs interval. I was speculating that it was related to measured vs expected inclination.
 
You didn't exactly say so but the green magnetometer interference range corresponds to the acceptable magMod range for the P3. And 1500 is the exact middle of that range. This makes it all the more likely that magnetic interference is just field strength.

But, I'm curious about abnormal compass reading in the [150 - 160] secs interval. I was speculating that it was related to measured vs expected inclination.

That would be my guess too, but it will take some more testing to confirm. It would be much easier if the field vectors could be monitored in real time without perturbing the field seen by the compass.
 
For those wishing to hack their M2 to support ATTI mode, the following has been adapted from material originally published by Paul Aitken of DroneU.
What you will need to Hack your Mavic 2?

  1. DJI Assistant 2 Version 1.1.2 installed (an archived Windows version is located here: DJI_Assistant2_Installer_v1.1.2_20170527.zip)
  2. Mavic 2 Pro or Mavic 2 Zoom (Note: M2 Enterprise is locked and cannot be hacked)
  3. USB C cable
  4. Computer (Mac or Windows)

Now watch Paul's video: https://youtu.be/rRE9_ydEWBY

The instructions in the video above show how to complete the task on an Apple Mac. If you are want to accomplish the same on a Windows platform, there are additional steps and you will need to follow these instructions instead:


Installing DJI Assistant 2 Version 1.1.2 on Windows 8 or 10

NOTE: Installing DJI Assistant Version 1.1.2 on Windows 8 or 10 will require you to boot into “safe mode”. This is because the 2 drivers needed are not, or not properly signed, and Windows 8 and 10 won’t allow installation when running in “normal” mode

To get into Windows safe mode and disable the driver signing requirement you need to do the following:


1. Right-click the Start menu and select Settings.

2.
Next click Update & Security.

3.
Then click on Recovery.

4.
Click the Restart Now button under Advanced Startup.

5.
Then click Troubleshoot.

6.
Next select Advanced options.

7.
Select the text See more recovery options.

8.
After that select Start-up Settings.

9.
Now click on Restart.

10.
In the resultant Startup Settings screen press 7 or F7 to disable driver signature enforcement.


Here is a video that shows how to do that: https://www.youtube.com/watch?v=yrW7YesPMKY

Install the DJI Assistant v1.1.2 as usual, the driver installation will display some pop-ups and will install, after which you are able to use DJI Assistant. Once the software is installed you can use it like any other program and “safe mode” is only needed during the installation phase, so after installation restart the PC to run it back in “normal” mode again. The unsigned drivers will now work in normal mode.

In Windows, before you run DJI Assistant 2 you will need to perform the first 6 steps to set it up for debug mode:

1. Locate and open the folder where DJI Assistant 2 is installed

2. Go into the AppFiles folder

3. Locate the main.js file

4. Open it with Notepad++

5. Delete the “//” in front of line 113. It should now read as follows: mainWindow.webContents.openDevTools()

6. Save the file (this step may need administrator permissions to save)

7. Start the DJI Assistant 2 and follow along with the process in Paul's video at the top of the post using the information in the following steps; however note that because of the previous 6 steps, debug will already be on and you won’t need to press the iOS Command+Option+I key combination as instructed by Paul in the video

8. In the right hand debug Window, click on the Resources tab (you might need to press >> to scroll to the right to find it)

9. Expand Local Storage in the left pane

10. Click on file:// entry

11. Find the debug Key, double click on the “0” Value next to it and change this to “1

12. Now change the debug_enabled Key’s Value from false to true

13. Click X on the top of the pane to close the debug window

14. Connect your drone via the USB cable, power it up, and click on the Mavic icon when it appears in the pane

15. From the resultant list of options in the left pane, scroll down and select Parameters
16. Type “mode” into the Filter field

17. The resultant list of fswitch_selection……mode[x] parameters are for the 3 Remote/Smart Controller switch positions; Mode[0] = Tripod mode (12), Mode[1] = Sport mode (8), Mode[2] = Position mode (7).

18. Double click on to reassign any one of the mode position settings with a new value of “3” to set that switch position to Atti mode. Note that you can always press the Reset button under the Operation column on the right of the pane to restore back to the factory settings, or Read to re-read the current contents from the drone if you accidently change the wrong parameter.

19. Press the Enter key

20. Click on the top left DJI icon on the DJI Assistant window to Exit out and save the settings.

Hope this little “hack” helps.
 
  • Like
Reactions: sar104
When the compass is off its rockers and you are mid flight. the effect feels like the drone is attacked by a bird ad it goes to all directions wildly.

The controls are not resonding well either. To get the drone back and establish controll again:

Press the return home button, this will override the compass and the drone returns to normal flight and will return home, you can cancel the RTH and take manual control (which I prefer) to fly back.

if it happens again, perform the above steps again.
 
When the compass is off its rockers and you are mid flight. the effect feels like the drone is attacked by a bird ad it goes to all directions wildly.

The controls are not resonding well either. To get the drone back and establish controll again:

Press the return home button, this will override the compass and the drone returns to normal flight and will return home, you can cancel the RTH and take manual control (which I prefer) to fly back.

if it happens again, perform the above steps again.

In the interest of accuracy in this thread I'm going to have to point out that this is incorrect. While the flight characteristics with significant compass and yaw errors can be a bit like that, pressing the RTH button has absolutely no effect, and does not override the compass. The flight problems are occurring because the FC is attempting to navigate or hold position based on an incorrect understanding of which direction it is facing, and instructing it to return home doesn't help. Furthermore, it would have to use the compass to return home anyway.

Controlled flight will only be restored if
  1. The FC resolves the compass error, which is what the tests reported here happens only with the Mavic 2, at least currently;
  2. The FC switches to ATTI mode, which often doesn't occur fast enough;
  3. The pilot manually selects ATTI mode.
I would not be surprised if all future models are programmed the same as the M2 on this issue, and it would be perfectly possible to change the firmware on older models to support IMU yaw reset after takeoff in the event of compass/IMU yaw disagreement.
 
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 what is the "safe" discrepancy then? Recently I noticed a read arrow difference of maybe 15 degrees from the actual drone direction, and having read enough crash stories here decided to move to another place (and did compass calibration for reasons I don't recall). That together aligned the arrow direction with the actual device direction, and the flight was successful, but the question still remains - is 5, 10 or 15 degrees ok or not really?
 
So what is the "safe" discrepancy then? Recently I noticed a read arrow difference of maybe 15 degrees from the actual drone direction, and having read enough crash stories here decided to move to another place (and did compass calibration for reasons I don't recall). That together aligned the arrow direction with the actual device direction, and the flight was successful, but the question still remains - is 5, 10 or 15 degrees ok or not really?

I've seen flight records with disagreements of 20° or so that did not cause uncontrolled flight, although I suspect that the handling was sub-optimal. At 45° you definitely see problems. Anything around 90° leads to the classic toilet bowl flight, while 180° produces linear runaway. I've always worked on the principle that if I can see the discrepancy on the screen then I'm not launching from that point - I would have done what you did.

Again though - note that the Mavic 2 appears to be immune to magnetic interference at takeoff because it simply resets the IMU yaw (maybe always - maybe just if there is a disagreement - I can't tell which) after takeoff.
 
  • Like
Reactions: Elvis44
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.


View attachment 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.
Something i just noticed my landing pad has a metal
Ring in it. Found it using a compass
 
Something i just noticed my landing pad has a metal
Ring in it. Found it using a compass
so has mine and every other folding spring type made,but it is fine wire and does not seem to effect the compass in the drone when you place it in the middle of the pad
 
Does anyone recall a Mavic 2 with a compass error? I've looked back over all the Mavic 2 events that I've examined from this forum, and I cannot find a single instance of a Mavic 2 exhibiting a compass error under any firmware version, so I suspect that this method was implemented right from the start. I wonder if that was also one of the reasons for going to a single compass. If that's the case then it is turning out to be a very robust solution to a relatively common problem.
Here's a screenshot of Compass Error experienced :07 after takeoff. This flight maxed out the ability to record the event. The job entailed two adjacent stack inspections with rooftop launches. Compass Interference was displayed on every roof launch. Compass calibrations were difficult to successfully perform w/so much metal nearby and did not remedy the Interference warning for takeoff. Interference warnings cleared with around 10' of altitude.At one particular spot also received Compass Error immediately followed by Compass Interference banners on the OSD approximately :07 into the flight. Flew in this condition for 4 minutes without any handling issues and finished the inspection. Exhaust stack steel and plant infrastructure most certainly caused the condition. Flight was two weeks ago with the latest firmware all around.

Screen Shot 2019-06-04 at 8.38.47 PM.png
 
Here's a screenshot of Compass Error experienced :07 after takeoff. This flight maxed out the ability to record the event. The job entailed two adjacent stack inspections with rooftop launches. Compass Interference was displayed on every roof launch. Compass calibrations were difficult to successfully perform w/so much metal nearby and did not remedy the Interference warning for takeoff. Interference warnings cleared with around 10' of altitude.At one particular spot also received Compass Error immediately followed by Compass Interference banners on the OSD approximately :07 into the flight. Flew in this condition for 4 minutes without any handling issues and finished the inspection. Exhaust stack steel and plant infrastructure most certainly caused the condition. Flight was two weeks ago with the latest firmware all around.

View attachment 74556

A Mavic 2? That's a lot of compass errors. I'd need to see the DAT file to understand what's happening there.
 
In the interest of accuracy in this thread I'm going to have to point out that this is incorrect. While the flight characteristics with significant compass and yaw errors can be a bit like that, pressing the RTH button has absolutely no effect, and does not override the compass. The flight problems are occurring because the FC is attempting to navigate or hold position based on an incorrect understanding of which direction it is facing, and instructing it to return home doesn't help. Furthermore, it would have to use the compass to return home anyway.

Controlled flight will only be restored if
  1. The FC resolves the compass error, which is what the tests reported here happens only with the Mavic 2, at least currently;
  2. The FC switches to ATTI mode, which often doesn't occur fast enough;
  3. The pilot manually selects ATTI mode.
I would not be surprised if all future models are programmed the same as the M2 on this issue, and it would be perfectly possible to change the firmware on older models to support IMU yaw reset after takeoff in the event of compass/IMU yaw disagreement.

Good point in switchig to ATTI mode. This case was with a Mavic pro and when it was sweeping around the controls became unresponsive. Pressing RTH and canceling again gave back the control for me
 
Lycus Tech Mavic Air 3 Case

DJI Drone Deals

New Threads

Forum statistics

Threads
130,592
Messages
1,554,161
Members
159,593
Latest member
mini2+