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

Refactor magnetometer fusion and add mag_type "init" #3532

Merged
merged 4 commits into from
Jan 23, 2025

Conversation

bresch
Copy link
Member

@bresch bresch commented Jan 6, 2025

Mag type "init" was added in PX4/PX4-Autopilot#23185 but documentation was missing

@bresch bresch requested a review from hamishwillee January 6, 2025 14:47
@bresch bresch self-assigned this Jan 6, 2025
Copy link

No flaws found


- The magnetometer **biases** are only observable while the drone is rotating
- The true heading is observable when the vehicle is accelerating (linear acceleration) while absolute position or velocity measurements are fused (e.g. GPS).
This means that magnetometer heading measurements are optional after initialization if those conditions are met often enough to constrain the heading drift (caused by gyro bias).
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand that we can get heading from GPS-measured position/velocity when moving so we don't need magnetometer readings when moving, as long as we're getting enough info to constrain the heading drift - right. Presumably there might be some drift when we stop in position?

When you say "optional after initialization" do you mean "before arming"? I mean, why do we need them on initialization/or does the measurement matter until we're ready to fly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Presumably there might be some drift when we stop in position?

Yes, the heading can drift if you hover in place but usually there are enough disturbances to always provide the tiny bit of motion required to constrain the heading drift. Also, when the position controller is active, an incorrect heading makes the drone "toilet bowl", which makes the heading observable, so unless really unlucky, the heading cannot really drift away by a lot without causing disturbances that makes the heading observable.

Copy link
Member Author

Choose a reason for hiding this comment

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

When you say "optional after initialization" do you mean "before arming"? I mean, why do we need them on initialization/or does the measurement matter until we're ready to fly?

We often just need the magnetometer to align the heading and start fusing GNSS. So even before arming, if the drone is not moving, the heading won't change and the drift is really low, and if it's moving the heading is observable so we don't need a mag at all to constrain the drift


The following selection tree can be used to select the right option:

![EKF mag type selection tree](../../assets/config/ekf/ekf_mag_type_selection_tree.png)
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI, Images are best in-tree (done). I also ran prettier and fixed a few typos.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, good to know, thanks!

@hamishwillee
Copy link
Collaborator

@bresch Did this go into PX4 v1.15 or main? I want to add a release note for this.

Looks great. A few questions mostly FMI here https://github.com/PX4/PX4-user_guide/pull/3532/files#r1926316422 but I'm going to merge.

@hamishwillee hamishwillee merged commit 6140160 into main Jan 23, 2025
2 checks passed
@hamishwillee hamishwillee deleted the pr-mag_type_init branch January 23, 2025 03:41
@bresch
Copy link
Member Author

bresch commented Jan 23, 2025

Did this go into PX4 v1.15 or main?

That feature was merged after 1.15

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.

2 participants