parallaxinc / Flight-Controller

Quadcopter Flight Controller
Other
24 stars 20 forks source link

Compass calibration. #44

Closed MatzElectronics closed 7 years ago

MatzElectronics commented 7 years ago

@JasonDorie For compass calibration, will it need declination and inclination input somehow, or will it "discover" these through a calibration routine? Just curious if it has GS implications...

JasonDorie commented 7 years ago

I'm not sure, honestly. I suspect it'll need to be entered, but it might be discoverable on startup / init / calibrate too.

J

On Monday, September 19, 2016, Matthew Matz notifications@github.com wrote:

@JasonDorie https://github.com/JasonDorie For compass calibration, will it need declination and inclination input somehow, or will it "discover" these through a calibration routine? Just curious if it has GS implications...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/parallaxinc/Flight-Controller/issues/44, or mute the thread https://github.com/notifications/unsubscribe-auth/ANak_hh52ProwDuKZpGSerWd7wnDPwSpks5qrwxigaJpZM4KBCJ5 .

RoboTechie commented 7 years ago

As far as I know from Search and Rescue (and a little bit of googling) you can't determine declination without location (GPS or manual entry) - I don't think we can do any calibration trickery to extrapolate that information. NOAA has a great tool for calculating declination using the WMM of IGRF models. Lots of good info available from the NOAA Geomagnatism page. For reference, declination in Nor Cal is appx 13.5° right now.

Here are a few potentially useful open-source magnetic declination code resources.

JasonDorie commented 7 years ago

Having played with this a bunch now, declination can be ignored until we have on-board GPS. Not having a "true" north is irrelevant as long as whatever north you have remains fixed - It's just an external reference to lock onto so the heading doesn't drift.

For inclination, the current code cancels it out by projecting the inclined vector onto the earth horizontal plane, then computes the compass heading from that flattened vector. Take a look at the "Heading Calculation" diagram mid-page here: http://ozzmaker.com/compass2/

In that image, 'H' is the inclined heading vector, pointing forward-right and downward, into the earth. Projecting that vector to the horizontal plane gives you Hh, and that is the vector that you compute heading from (or in our case, align the IMU matrix with).

JasonDorie commented 7 years ago

This is coded. Needs testing, but seems to be correct, and the calibration code is handled by the quad itself. In "FloatStreamCompiler" branch, also requires flashing with the "elev8-drivers" firmware first, hitting "enter" to upload, then flashing with main flight firmware.

JasonDorie commented 7 years ago

I have tested this - needs verification by others.

MatzElectronics commented 7 years ago

Tested and verified. Before I close this - do we want to consider whether allowing the user to input an offset (declination) is necessary, especially for GPS?

JasonDorie commented 7 years ago

It'll probably be necessary when GPS comes online, but it certainly isn't necessary without it, and I'll also need to write the code to use it.

On Tue, Nov 15, 2016 at 2:30 PM, Matthew Matz notifications@github.com wrote:

Tested and verified. Before I close this - do we want to consider whether allowing the user to input an offset (declination) is necessary, especially for GPS?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/parallaxinc/Flight-Controller/issues/44#issuecomment-260791125, or mute the thread https://github.com/notifications/unsubscribe-auth/ANak_pCxqrYePO1LpPhyreOMfP0PZPs8ks5q-jJrgaJpZM4KBCJ5 .

MatzElectronics commented 7 years ago

Sounds good, I'll close this one and let that propagate back up when we get closer.