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

ekf2: Fix description of EKF2_HDG_GATE #21708

Merged
merged 1 commit into from
Jun 9, 2023
Merged

Conversation

mortenfyhn
Copy link
Contributor

Solved Problem

The description of EKF2_HDG_GATE made me assume this parameter was irrelevant for a vehicle that doesn't use a magnetometer:

I'm working on a multicopter with external odometry input (via mavlink ODOMETRY type VISION). I want the external odometry system's heading to always be trusted, so I had set EKF2_HDG_GATE very high. Later, having forgotten about the original reason for setting EKF2_HDG_GATE, I found that the docs for this parameter say "Gate size for magnetic heading fusion". Since I do not use a magnetometer, this made me think I'd set this parameter by mistake, so I reset it to the default value. When flying, it became clear that it does indeed also affect yaw estimation with only external vision/odometry yaw, but the parameter description is a bit misleading.

Solution

The simplest fix is to just not mention "magnetometer" in the description of EKF2_HDG_GATE.

Changelog Entry

For release notes:

Feature/Bugfix XYZ
New parameter: XYZ_Z
Documentation: Clarified description of EKF2_HDG_GATE

Alternatives

Not sure, maybe separate parameters for magnetometer heading fusion and other types of heading fusion, but that seems overkill.

Test coverage

N/A

Context

I verified that EKF2_HDG_GATE does affect my system (no magnetometer, using external odometry), by

  1. Flying, and seeing that with low EKF2_HDG_GATE, PX4's heading can diverge from the odemetry's yaw. This does not happen when EKF2_HDG_GATE is set to a high value.
  2. Looking at the call sequence:
    • mavlink_receiver gets mavlink ODOMETRY type VISION
    • published as uorb vehicle_visual_odometry
    • received by the ekf, calls setExtVisionData
    • data pushed into the _ext_vision_buffer
    • Ekf::update runs
    • Ekf::controlFusionModes
    • Ekf::controlExternalVisionFusion
    • Ekf::controlEvYawFusion
    • Ekf::fuseYaw(3 args)
    • Ekf::fuseYaw(4 args)
    • this uses _params.heading_innov_gate which is EKF2_HDG_GATE
    • (it seems to also be used in Ekf::updateGpsYaw)

Copy link
Member

@bresch bresch left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I double-checked in the code and it's used for the "generic yaw fusion" (used by mag heading and EV yaw) and even in the GNSS yaw fusion.

@mortenfyhn
Copy link
Contributor Author

Thank you for the very swift feedback!

@bresch bresch merged commit 135f026 into PX4:main Jun 9, 2023
82 of 84 checks passed
@mortenfyhn mortenfyhn deleted the ekf2-hdg-gate-doc branch June 9, 2023 10:35
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

2 participants