Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Magnetometer Calibration algorithm documentation #2338

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

junwoo091400
Copy link
Contributor

@junwoo091400 junwoo091400 commented Mar 12, 2023

Motivation

As noted in PX4/PX4-Autopilot#19459, the calibration algorithm in PX4 is sophisticated & amazing, but it isn't well documented and reading the code to understand it is quite challenging (due to it's complexity), this adds a documentation for what Magnetometer calibration actually does.

This came up while discussing whether PX4 includes online soft iron calibration feature, which was hard to figure out by reading the codebase! And only 10+ minutes later, I realized offline soft iron calibration is implemented in this PR: PX4/PX4-Autopilot#15235

Relevant Twitter thread: https://twitter.com/YohanHadji/status/1566075481576931330
Relevant Discord message: https://discord.com/channels/1022170275984457759/1032412576727978084/1084491061935738930

Relevant doc (perhaps): https://www.infineon.com/dgdl/Infineon-AN2272_PSoC_1_Sensing_Magnetic_Compass_with_Tilt_Compensation-ApplicationNotes-v04_00-EN.pdf?fileId=8ac78c8c7cdc391c017d0731b0d05573

TODOs

  • Include diagram about soft iron calibration (how off-diagonal scaling comes into play)
  • Include hard iron calibration diagram (how diagonal scaling affects)
  • Include flowchart of how the calibration data gets applied (with units)

@junwoo091400
Copy link
Contributor Author

Btw @bresch it seems like this paper implements online 'soft iron' calibration. Any reason why this wasn't implemented, but only the 'hard iron' calibration was adapted in PX4/PX4-Autopilot#18327?

4. `rotation[3 x 3]`: Final rotation matrix to transform magnetometer data from sensor frame to body frame, set via setting the rotation enum as in [Flight Controller Orientation](../config/flight_controller_orientation.md).


## Orthogonal offset calibration
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First letter capitalization everywhere.

@hamishwillee hamishwillee marked this pull request as draft March 12, 2023 21:33
@hamishwillee
Copy link
Collaborator

I've moved to draft. MOve it back when you are ready for review.

This is a good topic but as with any content, have a little think about who it is for, and what they will use it for. Then you ask yourself, did this doc help those people - a bit like test driven programming.

If it is developers then they probably would benefit from links to the code which implement the interesting bits. You should also provide cross links from the calibration pages because otherwise this will probably not be very discoverable.

Arguably the people who are most interested in this will already know, but I like to define what is meant by each term - so what is hard/soft iron. How does the calibration differ. What are the impacts of getting it wrong. Etc.

@hamishwillee hamishwillee marked this pull request as ready for review May 3, 2023 23:01
@hamishwillee hamishwillee marked this pull request as draft May 3, 2023 23:03
@DronecodeBot
Copy link

This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/some-notes-on-everything-that-was-a-pain-in-using-px4/33573/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants