AP_Common: add SITL check for matching alt frame in linearly_interpolate_alt#33079
Merged
Merged
Conversation
Member
|
I would vote to put the check in the |
abf7fb4 to
44915e7
Compare
Contributor
Author
|
Thanks @IamPete1 , that's the better design. Moved the check into |
rmackay9
approved these changes
May 17, 2026
…ate_alt linearly_interpolate_alt() interpolates altitude between two Location endpoints and only produces meaningful results when both endpoints share an alt frame; mixing frames produces nonsense altitudes. Add a SITL-only panic at the top of the function so the contract is checked for every caller (BendyRulerHorizontal and Dijkstras path handling in AC_WPNav_OA, plus any future callers), as suggested by IamPete1 in code review. Fixes ArduPilot#32926
eb15852 to
baebdb9
Compare
peterbarker
approved these changes
May 20, 2026
Contributor
|
Incidentally, throwing a "flow_of_control" internal error would have been perfectly valid - if it happens on a real aircraft bad things are going to happen. |
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
Fixes #32926.
update_wpnav()callslinearly_interpolate_alt()againstorigin_locanddestination_locfor both the BendyRulerHorizontal and Dijkstras path-handling branches. That helper's contract is that its two endpoint Locations share an alt frame; mixing frames produces meaningless interpolated altitudes.Today the two locations are always constructed from the same
_is_terrain_alt_oabakconditional so the invariant holds, but there's no runtime check to catch a future change that breaks it. Added a SITL-onlyINTERNAL_ERRORright after the Locations are constructed.Classification & Testing
Built ArduCopter SITL on macOS (arm64). With the current code path the alt frames match by construction, so the new check does not fire (no behavior change). The check is guarded by
#if CONFIG_HAL_BOARD == HAL_BOARD_SITLso production builds are unaffected.