LIBRARY
Examples.LinearMPCStandaloneExample ​
The escape hatch: a controller built with the LinearMPC.jl API in Julia (build_standalone_mpc_example, with two general constraint blocks that differ in horizon and softness and no observer) is passed to LinearMPCOptimizer, which is used as a state-feedback MPC around a double integrator.
Usage ​
MPCComponents.Examples.LinearMPCStandaloneExample()
Parameters: ​
| Name | Description | Units | Default value |
|---|---|---|---|
ctrl | Hand-built LinearMPC.jl controller | – | build_stand...c_example() |
Variables ​
| Name | Description | Units |
|---|---|---|
y1 | Position | – |
u1 | Control signal | – |
Behavior ​
Behavior of this component cannot be rendered because it includes path variables.
Source ​
dyad
"""
The escape hatch: a controller built with the LinearMPC.jl API in Julia
(`build_standalone_mpc_example`, with two general constraint blocks that differ in horizon and
softness and no observer) is passed to `LinearMPCOptimizer`, which is used as a state-feedback
MPC around a double integrator.
"""
example component LinearMPCStandaloneExample
periodicclock = DiscreteComponents.PeriodicClock(dt = 0.1) {}
vel = BlockComponents.Continuous.Integrator(x0 = 0.0) {}
pos = BlockComponents.Continuous.Integrator(x0 = 1.0) {}
s1 = DiscreteComponents.Sampler() {}
s2 = DiscreteComponents.Sampler() {}
sr = DiscreteComponents.Sampler() {}
zoh = DiscreteComponents.ZeroOrderHold() {}
ref = BlockComponents.Sources.Step(start_time = 2.0, height = -1.0) {}
mpc = MPCComponents.LinearMPCOptimizer(mpc = ctrl) {}
"Hand-built LinearMPC.jl controller"
structural parameter ctrl::MPCComponents.MPCRef = build_standalone_mpc_example()
"Position"
variable y1::Real
"Control signal"
variable u1::Real
relations
y1 = pos.y
u1 = mpc.u[1]
connect(zoh.y, vel.u)
connect(vel.y, pos.u, s2.u)
connect(pos.y, s1.u)
connect(s1.y, mpc.xhat[1], periodicclock.y)
connect(s2.y, mpc.xhat[2])
connect(ref.y, sr.u)
connect(sr.y, mpc.r[1])
connect(mpc.u[1], zoh.u)
metadata {"Dyad": {"tests": {"case1": {"stop": 5}}, "doc": {"behavior": false}}}
endFlattened Source
dyad
"""
The escape hatch: a controller built with the LinearMPC.jl API in Julia
(`build_standalone_mpc_example`, with two general constraint blocks that differ in horizon and
softness and no observer) is passed to `LinearMPCOptimizer`, which is used as a state-feedback
MPC around a double integrator.
"""
example component LinearMPCStandaloneExample
periodicclock = DiscreteComponents.PeriodicClock(dt = 0.1) {}
vel = BlockComponents.Continuous.Integrator(x0 = 0.0) {}
pos = BlockComponents.Continuous.Integrator(x0 = 1.0) {}
s1 = DiscreteComponents.Sampler() {}
s2 = DiscreteComponents.Sampler() {}
sr = DiscreteComponents.Sampler() {}
zoh = DiscreteComponents.ZeroOrderHold() {}
ref = BlockComponents.Sources.Step(start_time = 2.0, height = -1.0) {}
mpc = MPCComponents.LinearMPCOptimizer(mpc = ctrl) {}
"Hand-built LinearMPC.jl controller"
structural parameter ctrl::MPCComponents.MPCRef = build_standalone_mpc_example()
"Position"
variable y1::Real
"Control signal"
variable u1::Real
relations
y1 = pos.y
u1 = mpc.u[1]
connect(zoh.y, vel.u)
connect(vel.y, pos.u, s2.u)
connect(pos.y, s1.u)
connect(s1.y, mpc.xhat[1], periodicclock.y)
connect(s2.y, mpc.xhat[2])
connect(ref.y, sr.u)
connect(sr.y, mpc.r[1])
connect(mpc.u[1], zoh.u)
metadata {"Dyad": {"tests": {"case1": {"stop": 5}}, "doc": {"behavior": false}}}
endTest Cases ​
Test Case case1 ​
Related ​
Examples
Experiments
Analyses