Repository navigation
Copter: fix vibration compensation response - #34607
Conversation
Global Size Summary (Total Flash delta in bytes)Built from 280b87a rebased onto e21a6ae
|
Previous review (2026-10-04)Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting. Reviewed at head Thanks, this is a real regression and the fix looks right. In the NED conversion (aa69e79), One small, nonblocking suggestion for the test: it never checks that VFR_HUD samples were actually received (arducopter.py:2074). As written, zero or very few samples pass. A guard such as For maintainers: the regression is in Copter-4.7.0/4.7.1, so the AC_AttitudeControl commit looks like a 4.7 backport candidate. |
|
Oh my, I suspect this may be the cause of this support discussion where Sokerer talks about an alternating throttle |
Exactly what I saw on my vehicle. |
2ad11ca to
06817b9
Compare
Previous review (2026-10-05)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head The vibration fix is still right. The gravity divisor at AC_PosControl.cpp:1472 is unchanged, and thanks for adding the minimum-sample guard to the test (arducopter.py:2075). The tests pass in SITL at 06817b9. The PR has since picked up six AP_AHRS/autotest commits, and one of them breaks builds with DCM compiled out. AP_AHRS.cpp:1336 returns Smaller points, none blocking:
|
…ottle The NEU to NED conversion dropped the division by GRAVITY_MSS when computing the throttle-per-acceleration gain used while vibration compensation is active. This made both the feed-forward and the integrator gains roughly 10x too large, driving the vertical controller into a limit cycle that pulses throttle between zero and full.
06817b9 to
280b87a
Compare
|
Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head Thanks for dropping the AHRS refactor from this PR. The branch is now just the two vibration-fix commits, patch-identical to the ones reviewed before, so the earlier DCM-disabled build break and the AHRS side points no longer apply. The fix still looks right: restoring Not checked: hardware or flight logs, the full Copter suite, and CI, which was still pending at this head. |
|
I'm in two minds about the need to add an autotest here, I mean adding one for a single line change is overkill. Also I have always seen throttle oscillation with vibration compensation, even on older builds - this just makes it 10 time worse (literally). So I am not even sure the test is that correct. |
|
Thanks very much for the fix! I agree in general with @andyp1per's comment that we may be overdoing the CI tests but on the other hand this is a rarely used part of the code so having a good autotest for this area is probably a good idea. |
|
This is included in 4.7.3-beta1 |
Summary
Fix the vertical controller oscillating between zero and full throttle
whenever vibration compensation is active. The NEU to NED conversion
(aa69e79) dropped the
/ GRAVITY_MSSfrom the throttle-per-accelerationgain in
AC_PosControl::get_throttle_with_vibration_override(). This made thevibration-override feed-forward and integrator gains about 9.8x too large.
Copter-4.7.0 and 4.7.1 are affected. 4.6.x is not.
Classification & Testing (check all that apply and add your own)
The new autotest
Copter.VibrationCompensationThrottletakes off in LOITER,adds an accelerometer Z bias (the same trigger as
VibrationFailsafe), andwaits for "Vibration compensation ON". It then records VFR_HUD throttle at
10Hz for 30s and fails if more than 20 sample-to-sample steps exceed 15%. The
faked bias makes the EKF reset its height estimate about every 13s. That
causes a few large steps even when the controller is behaving correctly, so
the test allows some.
Three runs per build:
The parent of aa69e79 does not compile because it is mid-series, so I
used the commit just before the series as the "before regression" build.
The existing
VibrationFailsafetest also passes with this PR.Description
The bug was found while analysing a flight log from a quad on 4.8.0-dev
(log available on request). A battery failsafe RTL was followed one second
later by "Vibration compensation ON" (VibeZ ~40, heavy clipping). From then
until landing, CTUN.ThO pulsed between 0 and 1 with a period of about
1-1.5s, and PSCD.TAD swung by about ±40 m/s².
Recomputing the throttle from the logged target acceleration with the
current formula (
hover - 0.25 * hover * TAD - I, MOT_THST_HOVER=0.125)reproduces the logged ThO closely. With
/ GRAVITY_MSSrestored, the sametargets produce commands of only about 0 to 0.23:
/ gWith the correct gain, the vibration-mode velocity loop has an effective
bandwidth of about
0.25 * PSC_D_VEL_P= 1.25 rad/s. The 9.8x error raisesthat to about 12 rad/s. That is right at the 2Hz throttle cutoff, before
adding motor lag and the lag in the vertical velocity estimate used in
high-vibration mode, so the loop becomes unstable. Hover throttle cancels
out of the loop gain, so the problem affects every airframe.
Before the NEU to NED series, the other scalings in this function were
(thr / 100) * 1000on the integrator and* 0.001on the output. Thosecancel each other and were correctly removed. Only the gravity divisor was
lost. The fix restores it, which returns the gains to their 4.6 values in
SI units.
Commits:
AC_AttitudeControl: restore gravity scaling in vibration override throttleautotest: add test for throttle oscillation under vibration compensationThis should be considered for backport to 4.7.
The bit which broke it:
aa69e79#diff-9fe7f1dfc4ef9b28922f55104d879c4b78656bc70293cde53f3c114dad535eeeL1456
(the variable name there loses unit-correctness and doesn't get it back)