Skip to content

FFT notch tune: persist the tracking mode and name the notch used - #33879

Open
andyp1per wants to merge 3 commits into
ArduPilot:masterfrom
andyp1per:pr-fft-notch-tune-mode
Open

FFT notch tune: persist the tracking mode and name the notch used#33879
andyp1per wants to merge 3 commits into
ArduPilot:masterfrom
andyp1per:pr-fft-notch-tune-mode

Conversation

@andyp1per

Copy link
Copy Markdown
Contributor

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, and save() 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 made INS_HNTC2_MODE default 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)

  • Checked by a human programmer
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)

test.Copter.GyroFFTAverage passes.

Flown in SITL with INS_HNTCH_MODE 0 supplied as a default, so the first notch is static and the tune has to move on:

AP: FFT: Notch 2 freq 148.8Hz ref 0.39 selected
eeprom: INS_HNTCH_MODE <not in eeprom>   INS_HNTC2_MODE 1

With only the _tracking_mode save removed and the same flight repeated, INS_HNTC2_MODE is absent from the eeprom. INS_HNTCH_MODE stays 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_idx is 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 plain save() for _enable, which has the same latent issue if a board's defaults.parm sets INS_HNTCH_ENABLE 1. Left alone here as it is a separate change.

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.
Comment on lines 2398 to 2400
if (notch.params.tracking_mode() != HarmonicNotchDynamicMode::UpdateThrottle) {
continue;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not just always configure the first notch? This is a setup thing so were not expecting there to be any exiting config?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I mean we could, feels a bit dictatorial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants