Follow up to my post above. I found two more issues with the same cause. Code in the rate path that assumes it runs once per main loop, which isn’t true with the fast-rate thread any more. Checked against Copter-4.7.1 and master (755258d).
rate_controller_run_dt() runs once per rate-thread sample with fast rate, but calls two helpers assuming main-loop timing:
-
PD boost compounds:
update_throttle_gain_boost()multiplies_pd_scaleby(1+ATC_THR_G_BOOST)on every rate-thread call and it is only reset once per main loop which results in(1+G_BOOST)^n, no limit (my post above). This is not confined to autotuning. It happens in normal flight as well. -
Angle P boost is never applied without fast rate, compounds with fast rate: since c683d8c16 (4.7.0)
_angle_P_scaleis reset inrate_controller_target_reset(), right after the rate run applies the boost and beforeupdate_flight_mode()runs the angle controller. So the angle controller reads 1.0, whileATSC.AngPScXlogs the boost. With fast rate the rate thread keeps multiplying after the reset. QuadPlane (Q_A_THR_G_BOOST) has the same order, so its angle P boost is also dead since 4.7.0. -
THR_MIX slews too fast:
update_throttle_rpy_mix()steps by the main loop_dt_sbut runs at the rate loop rate, so both ramps are (rate loop / main loop) times too fast. With defaults the 0.8 s ramp down becomes 0.32 s at 1 kHz / 400 Hz, 0.16 s at 2 kHz.
Conditions: FSTRATE_ENABLE ≠ 0 for 1 and 3, ATC_THR_G_BOOST > 0 for 1 and 2 (both default 0).
Claude reproduced all three in SITL for me, on master with ATC_THR_G_BOOST = 0.4 and an extra log message for the angle P scale the angle controller actually reads. SITL’s gyro is fixed at 1 kHz, so the rate thread can’t run faster than that. To get more rate-thread runs per main loop, SCHED_LOOP_RATE was lowered instead: 400 / 200 / 100 Hz gives 2.5 / 5 / 10 runs per main loop.
- Without fast rate: max
ATSC.PDScXis 1.4.ATSC.AngPScXlogs 1.96, but the angle controller reads 1.0 in every boosted loop. - With fast rate: max
ATSC.PDScXis 1.4^8 / 1.4^9 / 1.4^16, and the angle controller reads between 1.96^1 and 1.96^6. The exponents vary with how SITL schedules the threads. THR_MIXslews at 5.0 / 10 / 20 per s up and 1.25 / 2.5 / 5.0 per s down, instead of 2.0 and 0.5.
I’ll open a PR with a SITL test that shows the problem and a suggested fix. Just give me a couple days to get this right. I could also fly before/after logs on my 7" to not only rely on the simulations.