3689394590?profile=original(image from http://www.ngdc.noaa.gov/geomag/WMM/image.shtml)

 

Hi folks!

I decided to implement an on-board declination calculator based on geographic location and I'd love to get some feedback.  It takes up about 1400 flash bytes in total for a 3 degree declination error anywhere that people live (permanently - sorry Vostok!) and using a compass is reasonable.  It's not going to be flight tested until it stops raining here, so use at your own risk!  See the paper for more details :)

-John

 

Paper:

Lightweight%20Computation%20of%20the%20Earths%20Magnetic%20Field.pdf

 

APM Code - check under AP_GPS for AP_Declination_Lookup.*

ArduPilot.zip

 

LUT/IDW C# Calculator:

Geomag.zip

 

Footprint:

COMPASS_DECLINATION_LUT == DISABLED

113268 bytes, Free RAM: 1351, using 2061 bytes of memory

 

COMPASS_DECLINATION_LUT == ENABLED, COMPASS_DECLINATION_LUT_ACCURACY_LEVEL == 0

114692 bytes, Free RAM: 1351, using 2061 bytes of memory

 

Accuracy:
Scalable with table size

Table size: 89 entries (COMPASS_DECLINATION_LUT_ACCURACY_LEVEL == 0)
-------------------------------
Error   0 percentile: 0

Error  10 percentile: 0.1098926

Error  20 percentile: 0.2223369

Error  30 percentile: 0.3377705

Error  40 percentile: 0.4542923

Error  50 percentile: 0.5770731

Error  60 percentile: 0.7134132

Error  70 percentile: 0.8671622

Error  80 percentile: 1.072514

Error  90 percentile: 1.401104

Error  91 percentile: 1.447367

Error  92 percentile: 1.495352

Error  93 percentile: 1.551685

Error  94 percentile: 1.611044

Error  95 percentile: 1.676226

Error  96 percentile: 1.764013

Error  97 percentile: 1.864101

Error  98 percentile: 1.988347

Error  99 percentile: 2.208701

Error 100 percentile: 2.987068

 

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Jack- Could you elaborate? Errors are not necessarily bad as long as they are quantifiable, right? What I think we want to avoid is treating tilt-compensated yaw values from small and high inclinations with the same level of confidence in their accuracy.

    Regarding Doug's comments, I re-ran at 0.1 degree resolution. Here I should clarify that the error is based on deviation from the IGRF model. Here are the results:

    Size:114952
    Table: 114 entries * 5 bytes

    Error 0 percentile: 0
    Error 10 percentile: 0.1202459
    Error 20 percentile: 0.241147
    Error 30 percentile: 0.366117
    Error 40 percentile: 0.4916201
    Error 50 percentile: 0.6215248
    Error 60 percentile: 0.7635632
    Error 70 percentile: 0.9314415
    Error 80 percentile: 1.148144
    Error 90 percentile: 1.463516
    Error 91 percentile: 1.508278
    Error 92 percentile: 1.557454
    Error 93 percentile: 1.611344
    Error 94 percentile: 1.671692
    Error 95 percentile: 1.740637
    Error 96 percentile: 1.819055
    Error 97 percentile: 1.909616
    Error 98 percentile: 2.026399
    Error 99 percentile: 2.20524
    Error 100 percentile: 2.983333
  • With the errors introduced by acceleration, GPS, & shifting poles, there is a point of overdoing the magnetometer.
  • Great work, thanks for posting this John. To improve accuracy, we could store the high res data on a PC or cellphone and send relevant sections to the UAV as needed. Perhaps a MAVLink/QGC extension is in order.
  • Great feedback, Doug!  I am re-running the table creation with a 0.1 degree grid this time.  Also, could you share the coordinates of such a disturbance?  I'd be interested if either the IGRF11 or the WMM2010 take these into account.  You can try out both models here: http://www.ngdc.noaa.gov/geomagmodels/IGRFWMM.jsp?defaultModel=WMM.  Obviously, the accuracy of this method is limited by the accuracy of the model - GIGO as they say :) That said, I don't want anyone thinking that I am claiming the worst case error will scale linearly with the number of points. In other words, 100% < 1 degree error will take *lots* of points.  And by the sound of these disturbances, it's likely infeasible with this model in general.

    I also wanted to explain some more more caveats: 1) 1400 bytes is cheating a little bit (I briefly mention this in the write-up);  I have the user-configurable declination code disabled when this is enabled, so I'd estimate it's closer to 2-3k, but I have not specifically calculated this. 2) By limiting the area of applicability, I'm making a difficult problem much more tractable 3) I'm not taking into account either elevation or time.  In my area, declination is changing at 0.2 degrees/year.  I don't know what worst cases are for this though.

  • Developer
    Hi John,

    Interesting approach, but I am skeptical. For this approach to truly have a 100 percentile error of only 3 degrees the grid of points you weight from would have to be fine enough to catch areas of local geological disturbance. For example there are several locations here in Colorado where the declination can vary by more than a degree over a kilometer near point areas of high disturbance due to mineral deposits. For your approach to catch these localized phenomena I think you would need a lot more data points than would fit in 1400 bytes.
This reply was deleted.