MPC Controller
Advanced
运行在线示例
免费 · 无需注册 · 直接在浏览器中运行
MPCController 模块是面向线性状态空间系统的离散时间模型预测控制器(Model Predictive Controller)。在每个仿真步长中,该模块使用 Mehrotra 预测-校正原对偶内点法求解有限预测时域内的二次规划(QP)问题,并将计算出的第一组最优控制量 施加于被控对象。
与无约束的 LQR 控制器相比,MPC 显式考虑了执行器饱和限制()与状态约束()。当终端代价矩阵 留空时,模块会自动通过离散代数黎卡提方程(DARE)计算无限时域的黎卡提稳态解,从而保证闭环系统的渐近稳定性。
输入与输出
| Direction | ID | Label | 类型 | Status |
|---|---|---|---|---|
| → In | in1 |
x₀ | number | Required |
| → In | in2 |
x₁ | number | Optional |
| → In | in3 |
x₂ | number | Optional |
| → In | in4 |
x₃ | number | Optional |
| → In | in5 |
x₄ | number | Optional |
| → In | in6 |
x₅ | number | Optional |
| → In | in7 |
r₀ | number | Optional |
| → In | in8 |
r₁ | number | Optional |
| → In | in9 |
r₂ | number | Optional |
| → In | in10 |
r₃ | number | Optional |
| → In | in11 |
r₄ | number | Optional |
| → In | in12 |
r₅ | number | Optional |
| ← Out | out |
u | number | Output |
| ← Out | valid |
Valid | number | Output |
| ← Out | status |
Status | number | Output |
| ← Out | iterations |
Iterations | number | Output |
| ← Out | cost |
Cost | number | Output |
参数
| 参数 | Label | 类型 | 默认值 | 描述 |
|---|---|---|---|---|
nx |
Number of States (nₓ) | number | 2 |
Number of states in the model (1-6). Determines how many x inputs are used. |
horizon |
Prediction Horizon (N) | number | 10 |
Number of steps to predict. Longer horizon → better performance but more computation. |
A |
A (nₓ×nₓ) | matrix | 1 0.1; 0 1 |
State transition matrix. Rows separated by ';'. Example: '1 dt; 0 1' for double integrator with dt=0.1 |
B |
B (nₓ×1) | matrix | 0.005; 0.1 |
Input matrix. One entry per state. Example: 'dt²/2; dt' for double integrator |
sampleTime |
Sample Time | number | 0.1 |
|
Q |
Q (nₓ×nₓ) | matrix | 10 0; 0 1 |
State cost matrix. Diagonal entries penalize state deviations. Larger = faster settling. |
R |
R (1×1) | matrix | 1 |
Input cost weight. Larger R = gentler control effort. Must be positive. |
P |
Terminal Cost P (nₓ×nₓ) | matrix | |
Optional terminal cost. If empty, computed automatically from DARE (infinite-horizon LQR cost-to-go). |
uMin |
Input Min | number | -100 |
Lower bound on control input u |
uMax |
Input Max | number | 100 |
Upper bound on control input u |
xMin |
State Min (per state) | matrix | |
Optional lower bounds on states (1×nₓ matrix). Leave empty to disable state constraints. |
xMax |
State Max (per state) | matrix | |
Optional upper bounds on states (1×nₓ matrix). Leave empty to disable state constraints. |
slackWeight |
State Slack Weight | number | 10000 |
Penalty weight for soft state constraints. Values > 0 guarantee solver feasibility under disturbances. Set to 0 for hard constraints. |
reference |
Enable Reference Tracking | boolean | false |
When enabled, ref0..ref(n-1) inputs are used for offset-free tracking. The controller regulates the deviation from reference. |