FFT notch tune: persist the tracking mode and name the notch used - #33879
Open
andyp1per wants to merge 3 commits into
Open
FFT notch tune: persist the tracking mode and name the notch used#33879andyp1per wants to merge 3 commits into
andyp1per wants to merge 3 commits into
Conversation
save_params() is called when the FFT notch tune configures a notch, but left the tracking mode out. The mode normally equals its parameter default, so a plain save() would not store it and the tuned notch was left relying on that default staying put. Force it into storage so the notch cannot change tracking source later.
setup_throttle_gyro_harmonic_notch() takes the first notch in throttle mode, which is not necessarily the first notch: a static or RPM tracking first notch is skipped and a later one is enabled instead. Return the notch used so the caller can say which one it was.
The tune does not always configure the first notch, so report which one it enabled. Shortened to keep the message inside the 50 character statustext limit.
IamPete1
reviewed
Jul 29, 2026
Comment on lines
2398
to
2400
| if (notch.params.tracking_mode() != HarmonicNotchDynamicMode::UpdateThrottle) { | ||
| continue; | ||
| } |
Member
There was a problem hiding this comment.
Why not just always configure the first notch? This is a setup thing so were not expecting there to be any exiting config?
Contributor
Author
There was a problem hiding this comment.
I mean we could, feels a bit dictatorial
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
Two problems with the notch the FFT tune configures.
save_params()left the tracking mode out. The mode normally sits at its parameter default, andsave()does not write a value that equals its default, so the tuned notch was left relying on that default never moving. It does move: the pre-4.2 fixed notch conversion madeINS_HNTC2_MODEdefault to 0 while HNTC2 was disabled and 1 once it was enabled (fixed separately in #33878), which is exactly the failure this guards against.setup_throttle_gyro_harmonic_notch()takes the first notch in throttle mode, which is not necessarily the first notch. A static or RPM-tracking first notch is skipped and a later one is enabled instead, and the tune reported success without saying which notch it had touched.Classification & Testing (check all that apply and add your own)
test.Copter.GyroFFTAveragepasses.Flown in SITL with
INS_HNTCH_MODE 0supplied as a default, so the first notch is static and the tune has to move on:With only the
_tracking_modesave removed and the same flight repeated,INS_HNTC2_MODEis absent from the eeprom.INS_HNTCH_MODEstays out of storage in both cases, so the forced save is scoped to the notch the tune actually configured.Description
The retargeting itself is reasonable behaviour - it preserves a deliberately configured static notch and uses the next available one - so this keeps it and just makes it visible rather than refusing to tune. The message needed shortening (
frequency->freq) because adding the notch number pushed the old string to 52 characters and MAVLink truncated it at 50.notch_idxis an optional out-param rather than a changed return type so that the AP_InertialSensor commit still compiles on its own.Note
save_params()still uses a plainsave()for_enable, which has the same latent issue if a board'sdefaults.parmsetsINS_HNTCH_ENABLE 1. Left alone here as it is a separate change.