Expand description
A discrete-time PID controller for closed-loop budget regulation.
The DCC uses this to drive GORNA’s global budget multiplier so that the
measured frame time tracks a setpoint (the heuristic-suggested latency),
replacing the old static thermal/battery lookup. The controller is a pure
scalar algorithm — no engine state, no allocation — so it lives in
khora-core and is unit-tested in isolation.
It implements the practical refinements that matter for a noisy, saturating, discrete-actuator plant:
- Derivative on measurement (not on error) — no derivative kick when the setpoint jumps (it jumps every time the thermal state or phase changes).
- Filtered derivative — a first-order low-pass on the derivative term
tames frame-time noise; the filter time constant is
(Kd/Kp)/N. - Back-calculation anti-windup — the output saturates to
[output_min, output_max]; the integrator is unwound byKb·(saturated − unsaturated)so it never accumulates against a limit (the steady ceiling atoutput_maxwhen running with headroom is the most common windup case here). - Setpoint weighting — the setpoint is weighted by
bin the proportional term to curb overshoot without hurting disturbance rejection. - Output clamping — to a configurable
[output_min, output_max].
Structs§
- PidConfig
- Tuning and limits for a
PidController. - PidController
- A discrete-time PID controller with filtered derivative-on-measurement and back-calculation anti-windup. See the module docs for the rationale.