R2r mpc control

From XuShuwenn/RedAct · View interactive version

R2r mpc control is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Implement MPC controller for roll-to-roll manufacturing to stabilize web tensions during roller changes.

How to use this skill

Skill file

Roll-to-Roll MPC Controller

When to Use

Execution Protocol

Execution Protocol

Problem

Workflow

  1. Derive linearized state-space model at reference operating point

1a. Inspect r2r_simulator.py enough to confirm the actual class/interface before coding: constructor, state representation, how to advance simulation, what outputs are returned, and how disturbances/reference values are exposed. Do not assume methods or return signatures from naming alone.

  1. Design an actual MPC controller with horizon N in [3, 30]: formulate a finite-horizon receding-horizon optimization and solve it at each control step. Do not substitute a fixed LQR/state-feedback law and label it MPC.
  2. Run controller for at least 5 seconds

3a. Treat the full 5-second closed-loop simulation as the acceptance test. Use short smoke tests only for debugging; make final tuning and validation decisions from the required full simulation and reported metrics.

  1. Log tensions and compute metrics
  2. Reopen generated artifacts and verify that controller_params.json, control_log.json, and metrics.json were created from the latest successful run, are populated, and are structurally correct.
  3. Compare computed metrics against every stated target before declaring success; if any requirement fails or output is truncated/unverified, rerun or continue debugging.
  4. If behavior is unstable, biased, produces nan/inf, or suspicious metrics, validate the model/control formulation before further retuning.

Required Outputs

controller_params.json

{
  "horizon_N": 9,
  "Q_diag": [100.0, ...],
  "R_diag": [0.033, ...],
  "K_lqr": [[...], ...],
  "A_matrix": [[...], ...],
  "B_matrix": [[...], ...]
}

control_log.json

{"phase": "control", "data": [{"time": 0.01, "tensions": [...], ...}]}

metrics.json

{"steady_state_error": 0.5, "settling_time": 1.0, ...}

Performance Targets

Tips

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.