pyrtc.predictive

Model-based predictive control for the modal loop.

A loop running pyrtc.loop.Loop.predictive_integrator() estimates the pseudo open-loop (POL) disturbance of each controlled mode every frame,

pol_t = residual_t - command_applied_t,

and asks a ModalPredictor for the disturbance horizon frames ahead, when the next command will be on the corrector. The command cancels that prediction.

Predictors are pluggable. Each one learns its model from recorded POL data (ModalPredictor.fit()) and then filters online (ModalPredictor.update() / ModalPredictor.predict()). Register a new method with register_predictor(); the loop builds one from its predictor config with make_predictor(). Built in:

persistence

Predicts that the disturbance stays at its last measurement. Used before any fit, where it makes the loop a pseudo open-loop integrator.

ar_kalman

Modal LQG: an AR(2) disturbance model per mode, fitted by least squares with the measurement noise estimated from the spectrum’s floor, and a steady-state Kalman filter that predicts horizon frames ahead.

least_squares

A per-mode linear prediction filter over the last order POL samples, fitted by ridge regression to predict horizon frames ahead.

All predictors work on (num_modes,) vectors, one per frame, and are vectorized over modes.

Functions

available_predictors()

Return the registered predictor names.

make_predictor(conf, num_modes)

Build a predictor from a predictor config mapping.

register_predictor(name)

Class decorator registering a ModalPredictor under name.

Classes

ARKalmanPredictor(num_modes[, horizon, ...])

Modal LQG predictor: an AR(2) model per mode with a steady-state Kalman filter.

LeastSquaresPredictor(num_modes[, horizon, ...])

Per-mode linear prediction filter fitted by ridge regression.

ModalPredictor(num_modes[, horizon])

Predict each mode's disturbance horizon frames ahead.

PersistencePredictor(num_modes[, horizon])

Predict that each mode keeps its last measured value.