World Magnetic Model needs to be updated (after January 30)
« on: January 13, 2019, 06:24:40 pm »
This amount of mag angle error may or may not be important to the operation of LibrePilot GPS flight modes.

GPS flight modes use the GPS to know where the aircraft is, but they use the mag to know what direction it is pointed in.  If it thinks it is pointed north and it wants to go north it issues a "go forward" command.  If it was actually pointed east when it thought it was pointed north, it will now be farther away than it was to start with and you have a "fly away".  That is for very large errors.  For smaller errors you get oscillations.  For errors below some limit (probably a few degrees) it handles it and all you get is a slightly curved deviation from straight flight.  That is why (in 16.09) we require a green mag to arm in GPS flight modes.

The LibrePilot code's 2015 World Magnetic Model (apparently the WMM is updated every 5 years) was supposed to last until 2020 but magnetic north has drifted and according to the articles:
"The magnetic pole is moving so quickly that it has forced the world's geomagnetism experts into a rare move."
"They realized that it was so inaccurate that it was about to exceed the acceptable limit for navigational errors."

"... the release of the corrected World Magnetic Model, which should restore accuracy through the end of 2019, has now been postponed from January 15th to January 30th -- 'due to the ongoing US government shutdown.' "

https://www.nature.com/articles/d41586-019-00007-1
https://science.slashdot.org/story/19/01/13/0427222/earths-magnetic-field-is-acting-up-and-geologists-dont-know-why

There is a small chance that this is related to some LibrePilot GPS mode aircraft oscillations.

I have convinced myself that simply making a small angle change to aux mag settings (Attitude->Magnetometer->Orientation) will not work to fix this because that rotation is in the model's frame of reference, not the earth's frame of reference.

World Magnetic Model has been updated, needs to be updated in LP code
« Reply #1 on: February 06, 2019, 05:25:26 am »
The World Magnetic Model has been updated.  The update was apparently published Monday Feb 4.
It might fix some GPS mode oscillation issues.
It might be useful to backport it (and some other fixes?) into 16.09 so that people could get these fixes with no settings changes (without starting setup over from scratch)?

https://www.ncei.noaa.gov/news/world-magnetic-model-out-cycle-release
https://www.ngdc.noaa.gov/geomag/WMM/
https://news.slashdot.org/story/19/02/05/2119222/as-magnetic-north-pole-zooms-toward-siberia-scientists-update-world-magnetic-model

karla

  • *****
  • 526
Re: World Magnetic Model needs to be updated (after January 30)
« Reply #2 on: February 16, 2019, 02:00:04 am »
Interesting.
One of the articles mentioned that the planet's magnetic north wanders in the direction of Siberia at a rate of more than 34 miles per year (55 km), so in 5 years has now become 275 km. Maybe not much? But will the effect of this be greater and greater as moving your location from north pole towards the equator? (as distances between longditudes becomes greater)

And, How to use the new updated magnetic model in GPS units?
What do you mean by  "backport it into LP 16.09"

Re: World Magnetic Model needs to be updated (after January 30)
« Reply #3 on: February 16, 2019, 09:11:35 am »
My understanding of the (16.09 and a fairly recent next) code:

GCS code uses WMM 2010 (!) and firmware uses WMM 2015.

The firmware (and GCS) use the date to know where the moving north pole is and calculate a vector to it (it's 3D direction and strength).

Quote
And, How to use the new updated magnetic model in GPS units?
GPS's and mag sensors don't need to know anything about this.  They just return raw data (magnetic north pole is getting closer to Siberia) and the code corrects that to true north.

It seems to me the largest error would occur if the north (or south) pole was to your left one day and had moved to your right by the next day but the code thought it was still to your left (an oversimplification).  I think that means that the equator has roughly a smaller error because it is far away from this.

Musings: I think that the great circle that goes through where the mag north (/south) is and where our current code thinks it should be would have low error (outside of the short segment between is and should be) just like a compass on the great circle from mag north to true north always points true north (except in the short segment between mag north and true north).  Roughly a great circle from the magnetic north pole to Siberia might have low error away from the poles.

You have problems when your mag sensor says magnetic north is "there" and so true north is "there" so it banks your quad toward true north, but the GPS coordinates coming in say that you are moving northeast, not north (an exaggeration).  Another problem is that the strength of Earth's magnetic field has been decreasing about 5% per decade recently.  The code uses the direction of the field to determine true north, but it also uses the strength of the field as an error check.  5% error gives yellow mag and 15% gives red mag.  I think the field strength difference is less of an issue than it looks like because this is compensated for during mag sensor calibration as if it were a mag sensor sensitivity issue?  You would have to have done your last mag cal back in 2016 for mag field strength difference to be much of an issue?

34 miles per year is a huge amount!  :)  In less than 400 years the poles would be reversed.  In geologic time, this happens all the time.  Pole reversal (geomagnetic reversal) is overdue.  During a reversal, the strength of Earth's magnetic field decreases a lot.  Last time it was down to 5% of the current strength.  That leaves us less protected from solar flare issues.  Fun fact: Mars' lack of magnetic field is one reason Mars doesn't have much of an atmosphere.  :)

My understanding of the reason for this out-of-band / unplanned WMM update is that vehicles that depend on WMM were found to be at the edge of their safety limits; not actually unsafe, but needing correction.

Quote
What do you mean by  "backport it into LP 16.09"
Backport generally means to take a code change from some new, incompatible version (for us that is 'next') and put it back into an old version (for us that is 16.09) without breaking compatibility with the old version.  It is easy to take the old 16.09 code and make changes that don't require running setup again.  Generally, changes that don't change UAVO's are trivial to backport.  I am guessing that there are people with 16.09 who are not upgrading to the latest next, but who would gladly upgrade to "16.09.01" if they don't have to run setup.  There are quite a few things I could imagine being in a 16.09.01.

The WMM is an array of numbers that allows you to predict where the magnetic north pole is.  That array of numbers is in the source code and in the compiled GCS and firwmare.  This new model is just a new array of numbers that better predict where magnetic north is and is a simple ( :) ) change to this array.  The new WMM could easily be one of the things put in 16.09.01.  I should note that it would probably be a good idea (might be required) to redo mag calibration after updating WMM.

This gets into LP procedures, because we have never done this before.  Is something like 16.09+newWMM worth doing so we can ask people with certain kinds of GPS mode oscillations to try it with no other changes to see if it fixes issues?  Does "dev" think the idea of 16.09.01 is reasonable or that it should be avoided at all cost?  Does LP have easy ways of building "private" code sets?  For instance, I don't have a way of building for OSX, and my Windows environment would need a complete do over.

It might fix some GPS mode oscillation issues.
Let me clarify that.  There will always be areas on Earth where GPS modes oscillate.  Generally this is worst close to the mag poles.  Earth's mag field is strangely shaped too and that might cause issues away from the poles if the WMM is too inaccurate?  A better WMM will make these bad areas smaller.
« Last Edit: February 16, 2019, 05:37:04 pm by TheOtherCliff »

karla

  • *****
  • 526
Re: World Magnetic Model needs to be updated (after January 30)
« Reply #4 on: February 20, 2019, 01:22:25 am »
Okay, so backport, is something similar to a 'patch', got it.

I can certainly help testing an update to the new WMM.
Especially on that stubborn 450 Heli, now on latest next :)

/karl

Re: World Magnetic Model needs to be updated (LP source in this post)
« Reply #5 on: February 20, 2019, 06:30:34 am »
I kind of doubt that updating the WMM will fix a problem with one aircraft.  I think it's more likely to fix issues if you had the same problem with all your aircraft.

Silly question, but I think I remember that you move around to different cities somewhat.  Have you done mag calibration where you are flying it now?  Do I also recall that you have problems doing a mag cal on this model?  Also, there was a bug long ago where you had to do a special procedure during mag cal because the data from previous cal wasn't cleared out correctly and I wonder if that had caused you problems.  That's probably too long ago to affect this model...

16.09 and the latest next use the same files, so here is the updated LP WMM source code that will work with either version for anyone having GPS mode oscillations that aren't fixed by any of the normal fixes (twist/reroute all high current wire sets, mag recal, check GPS/mag/FC/model alignment, firmware that helps for DJI/Naza GPS caused slow oscillation) and don't happen in Attitude mode.  Just put wmmupdate.tar.gz in your build root (the directory that has flight and ground subdirectories) then extract it with something like:
Code: [Select]
cd librepilot-or-whatever-you-named-your-build-root-source-directory
tar -xvzf wmmupdate.tar.gz
The changes were easy, just copy a list of numbers (OK, I did have to do some bash-sed-foo to format the numbers) from NOAA into the source and update a little tag from WMM-2015 to WMM-2015v2.  The numbers are close to the old numbers at the same location so it really does look correct.  I did a quick scan of the NOAA source code and did not see any changes affecting us.  I built it, but I have not tested it.

Build both GCS and firmware and flash the firmware.  You don't need to run setup, but I would recommend that you do a mag calibration.

Anyone using this please post back with results; especially if you have a medium to fast GPS mode oscillation that is not fixed with the fixes discussed above.  :)
« Last Edit: February 20, 2019, 09:03:30 am by TheOtherCliff »

karla

  • *****
  • 526
Re: World Magnetic Model needs to be updated (LP source in this thread)
« Reply #6 on: February 20, 2019, 10:07:58 am »
Thanks Cliff,

Trying to answer your questions:
Quote from: TheOtherCliff
Have you done mag calibration where you are flying it now?
Do I also recall that you have problems doing a mag cal on this model?
Also, there was a bug long ago where you had to do a special procedure during mag cal because the data from previous cal wasn't cleared out correctly and I wonder if that had caused you problems.
. yes, do travel north Europe to south and middle of China, and every time I do mag calibration (actually also accelerometer calibration ).
. yes, often the mag calibration end up in system hang! PC and win 10 of course. need to relaunche LP GCS and try again until it succeeds.
. can't really remember a possible issue of non cleared out mag calibration data, sorry.
 
Thanks a lot for the info on updating the firmware.
I will really study and consider it, and of course report back results, if/when trying :)
« Last Edit: February 20, 2019, 10:46:08 am by TheOtherCliff »