Examples.DisturbanceRejectionMPCExample ​
Load-disturbance rejection with LinearMPCController on the first-order plant 1/(10s+1): a unit step load disturbance enters at the input at t = 10. Without a disturbance model the controller leaves a steady-state offset; with the offset-free observer the output returns to the reference and the control settles at -1. The observer is the tutorial's: a constant load disturbance on the input (offset_free = InputDisturbance) estimated by a Kalman filter on the augmented model with the tutorial's covariances R1 = diag(0.001, 0.1), whose disturbance entry sets the estimation speed (the tutorial lowers it from 1 to 0.1 to reduce the sensitivity peak). Translated from the DyadControlSystems disturbance-rejection tutorial. Verified in test/test_acados_tutorials.jl.
Usage ​
MPCComponents.Examples.DisturbanceRejectionMPCExample()
Variables ​
| Name | Description | Units |
|---|---|---|
y_none | Output without a disturbance model | – |
y_of | Output with the offset-free observer | – |
u_of | Control with the offset-free observer | – |
Behavior ​
Behavior of this component cannot be rendered because it includes path variables.
Source ​
"""
Load-disturbance rejection with `LinearMPCController` on the first-order plant 1/(10s+1): a unit step
load disturbance enters at the input at t = 10. Without a disturbance model the controller leaves a
steady-state offset; with the offset-free observer the output returns to the reference and the control
settles at -1. The observer is the tutorial's: a constant load disturbance on the input
(`offset_free = InputDisturbance`) estimated by a Kalman filter on the augmented model with the
tutorial's covariances `R1 = diag(0.001, 0.1)`, whose disturbance entry sets the estimation speed (the
tutorial lowers it from 1 to 0.1 to reduce the sensitivity peak). Translated from the DyadControlSystems
disturbance-rejection tutorial. Verified in `test/test_acados_tutorials.jl`.
"""
example component DisturbanceRejectionMPCExample
periodicclock = DiscreteComponents.PeriodicClock(dt = 1.0) {}
plant_none = MPCComponents.Examples.FirstOrderLoadPlant() {}
plant_of = MPCComponents.Examples.FirstOrderLoadPlant() {}
dist = BlockComponents.Sources.Step(height = 1.0, start_time = 10.0) {}
ref = BlockComponents.Sources.Constant(k = 0.0) {}
sr = DiscreteComponents.Sampler() {}
s_none = DiscreteComponents.Sampler() {}
s_of = DiscreteComponents.Sampler() {}
zoh_none = DiscreteComponents.ZeroOrderHold() {}
zoh_of = DiscreteComponents.ZeroOrderHold() {}
mpc_none = MPCComponents.LinearMPCController(dynamics = plant_none, inputs = ["u"], disturbance_inputs = ["d"], outputs = ["y"], state_variables = ["x"], Ts = 1.0, Np = 10, Q1 = [100.0], Q2 = [0.01], umin = [-1.1], umax = [1.1], R1 = [0.001], R2 = [1.0]) {}
mpc_of = MPCComponents.LinearMPCController(dynamics = plant_of, inputs = ["u"], disturbance_inputs = ["d"], outputs = ["y"], state_variables = ["x"], Ts = 1.0, Np = 10, Q1 = [100.0], Q2 = [0.01], umin = [-1.1], umax = [1.1], R1 = [0.001, 0.1], R2 = [1.0], offset_free = OffsetFreeMethod.InputDisturbance()) {}
"Output without a disturbance model"
variable y_none::Real
"Output with the offset-free observer"
variable y_of::Real
"Control with the offset-free observer"
variable u_of::Real
relations
y_none = plant_none.y
y_of = plant_of.y
u_of = mpc_of.u[1]
connect(ref.y, sr.u)
connect(dist.y, plant_none.d, plant_of.d)
connect(plant_none.y, s_none.u)
connect(s_none.y, mpc_none.y[1], periodicclock.y)
connect(sr.y, mpc_none.r[1], mpc_of.r[1])
connect(mpc_none.u[1], zoh_none.u)
connect(zoh_none.y, plant_none.u)
connect(plant_of.y, s_of.u)
connect(s_of.y, mpc_of.y[1])
connect(mpc_of.u[1], zoh_of.u)
connect(zoh_of.y, plant_of.u)
metadata {"Dyad": {"doc": {"behavior": false}}}
endFlattened Source
"""
Load-disturbance rejection with `LinearMPCController` on the first-order plant 1/(10s+1): a unit step
load disturbance enters at the input at t = 10. Without a disturbance model the controller leaves a
steady-state offset; with the offset-free observer the output returns to the reference and the control
settles at -1. The observer is the tutorial's: a constant load disturbance on the input
(`offset_free = InputDisturbance`) estimated by a Kalman filter on the augmented model with the
tutorial's covariances `R1 = diag(0.001, 0.1)`, whose disturbance entry sets the estimation speed (the
tutorial lowers it from 1 to 0.1 to reduce the sensitivity peak). Translated from the DyadControlSystems
disturbance-rejection tutorial. Verified in `test/test_acados_tutorials.jl`.
"""
example component DisturbanceRejectionMPCExample
periodicclock = DiscreteComponents.PeriodicClock(dt = 1.0) {}
plant_none = MPCComponents.Examples.FirstOrderLoadPlant() {}
plant_of = MPCComponents.Examples.FirstOrderLoadPlant() {}
dist = BlockComponents.Sources.Step(height = 1.0, start_time = 10.0) {}
ref = BlockComponents.Sources.Constant(k = 0.0) {}
sr = DiscreteComponents.Sampler() {}
s_none = DiscreteComponents.Sampler() {}
s_of = DiscreteComponents.Sampler() {}
zoh_none = DiscreteComponents.ZeroOrderHold() {}
zoh_of = DiscreteComponents.ZeroOrderHold() {}
mpc_none = MPCComponents.LinearMPCController(dynamics = plant_none, inputs = ["u"], disturbance_inputs = ["d"], outputs = ["y"], state_variables = ["x"], Ts = 1.0, Np = 10, Q1 = [100.0], Q2 = [0.01], umin = [-1.1], umax = [1.1], R1 = [0.001], R2 = [1.0]) {}
mpc_of = MPCComponents.LinearMPCController(dynamics = plant_of, inputs = ["u"], disturbance_inputs = ["d"], outputs = ["y"], state_variables = ["x"], Ts = 1.0, Np = 10, Q1 = [100.0], Q2 = [0.01], umin = [-1.1], umax = [1.1], R1 = [0.001, 0.1], R2 = [1.0], offset_free = OffsetFreeMethod.InputDisturbance()) {}
"Output without a disturbance model"
variable y_none::Real
"Output with the offset-free observer"
variable y_of::Real
"Control with the offset-free observer"
variable u_of::Real
relations
y_none = plant_none.y
y_of = plant_of.y
u_of = mpc_of.u[1]
connect(ref.y, sr.u)
connect(dist.y, plant_none.d, plant_of.d)
connect(plant_none.y, s_none.u)
connect(s_none.y, mpc_none.y[1], periodicclock.y)
connect(sr.y, mpc_none.r[1], mpc_of.r[1])
connect(mpc_none.u[1], zoh_none.u)
connect(zoh_none.y, plant_none.u)
connect(plant_of.y, s_of.u)
connect(s_of.y, mpc_of.y[1])
connect(mpc_of.u[1], zoh_of.u)
connect(zoh_of.y, plant_of.u)
metadata {"Dyad": {"doc": {"behavior": false}}}
endTest Cases ​
No test cases defined.
Related ​
Examples
Experiments
Analyses