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

Compass error demonstration

the file that you posted the magnetic field strength was way out of spec, and that alone should trigger a warning:

I have expected so because that's a pretty strong magnet but what I have seen repetitively is that as long as there was no GPS fix, the warning message did not show up. This is consistent with the log file. compassError changed from false to true only after some GPS satellites were seen :

1585574932171.png
 
Last edited:
I have expected so because that's a pretty strong magnet but what I have seen repetitively is that as long as there was no GPS fix, the warning message did not show up. This is consistent with the log file. compassError changed from false to true only after some GPS satellites were seen :

View attachment 97530

Maybe. The field inclination that you imposed was 55°. The expected inclination was 33°:

73.309 : 3389 [L-NS][AHRS] wmm dec: -2.802338​
73.309 : 3389 [L-NS][AHRS] wmm inc: 33.525585​

Obviously that's a big enough difference to be detected, and could have caused the error message:

81.292 : 3786 [L-FMU/LED]action changed. compass out of range:need_cali_mag_or_wait_rtk_fix(1)​

That's consistent with your hypothesis, but is still only a correlation at this point. For example, it may only conduct that check after entering P-mode, or it could still be checking expected field strength rather than inclination.
 
The problem with P-GPS mode is that, unlike in ATTI mode, the FC is not interpreting elevator and aileron commands as purely pitch and roll instructions - it is interpreting them as instructions to fly forwards/backwards and right/left relative to the direction that the aircraft is pointing. It will start by applying simple pitch/roll but then correct as needed to make the aircraft fly a track that equals its assumed heading. So the problem is the same as positional holding - if you push the stick forwards and the aircraft applies negative pitch, but then detects (incorrectly) that it is moving backwards, then it will keep increasing negative pitch to try to compensate - another runaway positive feedback loop.
I have seen the software you have to download for the phone controller to convert 'Tripod" to ATTI, but what about the SC. Someone posted online that if you turn off the bottom sensors on the SC that will convert it to ATTI? That doesn't seem to make any sense to me.
 
I have seen the software you have to download for the phone controller to convert 'Tripod" to ATTI, but what about the SC. Someone posted online that if you turn off the bottom sensors on the SC that will convert it to ATTI? That doesn't seem to make any sense to me.

It's the remote controller mode switch that controls the mode, and the mapping is set in the aircraft firmware, so it won't matter whether you are using iOS, Android or the SC.

Turning off the sensors will only serve to force ATTI mode by preventing P-mode with optical positioning when GPS is unavailable, e.g. indoors. It won't force ATTI if GPS positioning is available.
 
Here is the flight test result under the conditions that have led to yaw/compass errors and crashed many Mavic Pros and Mavic Airs. No rebar - instead I used a small magnet taped to the landing pad to distort the magnetic field at the M2P compass. The aircraft was facing south, but reported facing northwest. No magnetic interference errors occurred on startup - I had the magnet aligned to produce a credible magnetic field strength and direction, with the interference values in the green.

The graph below uses unwrapped angles, primarily because I carelessly chose to align the aircraft south for ease of manipulating the magnetic field. Unfortunately south is, of course, at the discontinuity between +180° and –180°, resulting in a messy presentation in wrapped angle space.

View attachment 73889

Note that the distorted field was steady and the IMU yaw was incorrectly initialized. The direction indicator on the GO 4 app showed the same incorrect heading. Motor start (zero seconds) was followed by takeoff at 40 seconds. I had my finger on the mode switch to go to ATTI when things went bad.

But instead, there is the incontrovertible evidence that they changed the way that the firmware deals with IMU/compass discrepancies at takeoff. As the aircraft climbs out of the distorted magnetic field and sees only the earth's magnetic field, it changes to show –180° (south) as expected. That would previously have led to an immediate 130° discrepancy between the compass and the IMU yaw but, under this firmware, the FC immediately resets the IMU yaw to match the new compass value, even though the z-axis rate gyro (green trace) detects no rotation. No discrepancy and no compass errors. There were no messages in the event stream mentioning the reset.

At 90 seconds I rotated the aircraft through a full 360° to test the system; the compass and the z-axis rate gyro both correctly detect the rotation and the IMU yaw is appropriately updated.

In my opinion this is a significant improvement, since this situation has probably produced more crashes than any other single problem. And it's a good strategy since if the compass changes rapidly on takeoff without any detected aircraft rotation, the compass is almost always going to be correct after takeoff rather than before. We have discussed this at some length on this forum. @BudWalker – perhaps the DJI guys do visit occasionally after all...
I am really grateful to you for these insights: there is so much information here but it is worth the effort to decode it all and ensure safer flights.

But I noticed in this post you mentioned that you were flying an M2P and that you "had [your] finger on the mode switch to go to ATTI when things went bad." what switch is that?? I can do it on my Ph4Pro2.0 but am not aware of any way to get into ATTI mode on the M2P other than wrapping the legs in tin foil. Please inform. I wish ALL drones had the ability to train in ATTI mode so that folks would have a better fore-knowledge of what is going to happen when they lose GPS and vision.
 
I am really grateful to you for these insights: there is so much information here but it is worth the effort to decode it all and ensure safer flights.

But I noticed in this post you mentioned that you were flying an M2P and that you "had [your] finger on the mode switch to go to ATTI when things went bad." what switch is that?? I can do it on my Ph4Pro2.0 but am not aware of any way to get into ATTI mode on the M2P other than wrapping the legs in tin foil. Please inform. I wish ALL drones had the ability to train in ATTI mode so that folks would have a better fore-knowledge of what is going to happen when they lose GPS and vision.
You can remap the mode switch positions on the M2P. I have Tripod remapped to ATTI.

Mavic 2 Atti mode | DJI Mavic Drone Forum (mavicpilots.com)
 
I know this is an older thread but wanted to say thanks (again, I probably did so at the time) for this important info and demonstration. DJI really should be a bit more explicit about this. I always confirm my AC is pointed to north before takeoff.... except the one time I didn't, and my old Air went haywire and nearly nailed a tree overlooking a lake. 20 seconds or so later I was able to get it under control, but that was a moment of sheer terror. I had planned to take it up for a very short flight to check the heights of some trees for a Litchi mission. It was wind as long as I was just ascending, but as I yawed around it flew off toward the trees/water.

Sure enough, when I checked the flight log, it was about 40 degrees off. Will not make that mistake again (I was recording a video and keep it on my desktop now to make sure I always remember this).
 
  • Like
Reactions: sar104
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
Were you ever able to figure out what the units were for magx, magy, and magz. I have been looking this myself and have not found anything yet. Any help would be great!
 
Were you ever able to figure out what the units were for magx, magy, and magz. I have been looking this myself and have not found anything yet. Any help would be great!
The scale factor for each of the magnetometers changes depending on the last magnetometer calibration. Depending on the geomagnetic field strength the scale is adjusted for each axis so that the modulus is close to 1500. The biases can also be adjusted. Recalibrating in the same location will change the biases and scales slightly. Recalibrating in a new location with substantially different geomagnetic field strength will have a larger effect on the biases and scales.

The scales and biases can be seen by looking at the eventLog stream for the last calibration.

Some of the DJI platforms record the raw magnetometer data that are then scaled and biased. However, this isn't recorded for the Mavic 2. But, IMHO, it would be difficult to determine the actual geomagnetic field strength using the raw data.
 
The scale factor for each of the magnetometers changes depending on the last magnetometer calibration. Depending on the geomagnetic field strength the scale is adjusted for each axis so that the modulus is close to 1500. The biases can also be adjusted. Recalibrating in the same location will change the biases and scales slightly. Recalibrating in a new location with substantially different geomagnetic field strength will have a larger effect on the biases and scales.

The scales and biases can be seen by looking at the eventLog stream for the last calibration.

Some of the DJI platforms record the raw magnetometer data that are then scaled and biased. However, this isn't recorded for the Mavic 2. But, IMHO, it would be difficult to determine the actual geomagnetic field strength using the raw data.
Okay thank you. So realistically do you think I can find a specific unit for this data? I have the raw data converted from datcon. If it is scaled different for each run I can figure that out at a later point potentially, right now I really just need the units for this data. Should I try reaching out to dji directly? I am not so much worried about the scale right now as I am for the actual units. Let me know your thoughts
 
Okay thank you. So realistically do you think I can find a specific unit for this data? I have the raw data converted from datcon. If it is scaled different for each run I can figure that out at a later point potentially, right now I really just need the units for this data. Should I try reaching out to dji directly? I am not so much worried about the scale right now as I am for the actual units. Let me know your thoughts
The "unit" has to be tesla. The scale is unknown and varies as I described previously. It's not nano tesla or micro tesla. It's some other scaling factor that's different for each axis and compass calibration.

If you're looking at a Mavic 2 the data you get from DatCon isn't raw. It's been scaled and biased as I described. Even if you had access to the raw sensor data it's not going give you the "specific" or "actual" unit.

The scaling factor isn't really relevant for what the Flight Controller needs.

Can you tell me what you're trying to do?
 
The "unit" has to be tesla. The scale is unknown and varies as I described previously. It's not nano tesla or micro tesla. It's some other scaling factor that's different for each axis and compass calibration.

If you're looking at a Mavic 2 the data you get from DatCon isn't raw. It's been scaled and biased as I described. Even if you had access to the raw sensor data it's not going give you the "specific" or "actual" unit.

The scaling factor isn't really relevant for what the Flight Controller needs.

Can you tell me what you're trying to do?
Oh okay, I didn't realize it's just a scaled version of teslas. Essentially I am trying to pull the magnetic field data to see what it did to the drone when exposed. If this scaling is different for every calibration, that could be an issue. Is that why my IMU magx data, etc. starts at a specific number other than zero? Cause you would think that it would be displaying zero in the beginning of the data collection and instead it starts a either a negative or positive number in the hundreds.
 
Oh okay, I didn't realize it's just a scaled version of teslas. Essentially I am trying to pull the magnetic field data to see what it did to the drone when exposed. If this scaling is different for every calibration, that could be an issue. Is that why my IMU magx data, etc. starts at a specific number other than zero? Cause you would think that it would be displaying zero in the beginning of the data collection and instead it starts a either a negative or positive number in the hundreds.

Magnetometer values don't start at 0 and then change. The geomagnetic field is always present, i.e. non-zero. The initial magnetometer values represent the geomagnetic field when the drone is turned on. For an AC that is stationary any change in magnetometer values is due random noise.

Generally, magnetometer values are all non-zero. But an axis perpendicular to the field will have a zero magnetometer value. If, for example, the Z axis is aligned with the geomagnetic field then both the Y and X axes will be perpendicular to the field and magY and magX will be zero.

If an axis points into the field the magnetometer will > 0.0. If it points away from the field the value will be <0.0.

I don't understand "magnetic field data to see what it did to the drone when exposed".
 
  • Like
Reactions: db4476

DJI Drone Deals

New Threads

Forum statistics

Threads
131,128
Messages
1,560,123
Members
160,099
Latest member
tflys78