AP_NavEKF3: resetHeightDatum stricter early return#32915
Closed
gdavud wants to merge 1 commit into
Closed
Conversation
be091bb to
d3cb926
Compare
d3cb926 to
5d3d6f7
Compare
5d3d6f7 to
3807180
Compare
peterbarker
reviewed
May 5, 2026
| bool NavEKF3_core::resetHeightDatum(void) | ||
| { | ||
| if (activeHgtSource == AP_NavEKF_Source::SourceZ::RANGEFINDER || !onGround) { | ||
| if (activeHgtSource == AP_NavEKF_Source::SourceZ::RANGEFINDER || !onGround || inFlight) { |
Contributor
There was a problem hiding this comment.
Can you see this change is in direct contravention of the comment immediate after it?
3807180 to
2afb4f4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Attempts to fix issue #32720 with altitude spikes on termination (or disarm). AP_NavEKF3 lib treats all disarmed states as definetly on-ground. During flight termination, the vehicle can be airborne while disarmed which can trigger a height origin reset, causing an altitude spike.
Classification & Testing (check all that apply and add your own)
Description
NavEKF3_core::detectFlight()marksNavEKF3_core::onGroundas true, this allowsNavEKF3_core::resetHeightDatum()to run which may updateNavEKF3_core::ekfGpsRefHgtwhich in turn may update the vehicle'slocal_origininNavEKF3_core::getPosD()causing discontinuity in vertical position.Function
resetHeightDatum()returns false immediately ifonGroundis false. During the untermination test,onGroundis true when the vehicle terminates (even tho we are still airborne), which aligns with the spike from the original issue.This pr prevents

NavEKF3_core::resetHeightDatumfrom executing if vehicle is disarmed while airborne.Untermination test running on this patch:
Some logs that explain the original issue: