LIBRARY
Examples.ACADOSMPCTrackingExample ​
Tracking of an angle reference with ACADOSMPC whose prediction model is the plant component itself (dynamics = plant, inputs = ["tau"]), with the angular velocity softly bounded to ±1 (a named constraint) and a real-time iteration (SQP_RTI) per tick. The reference steps from 0 to 0.5 rad at t = 1. Verified in test/test_acados_mpc.jl.
Usage ​
MPCComponents.Examples.ACADOSMPCTrackingExample()
Parameters: ​
| Name | Description | Units | Default value |
|---|---|---|---|
output_trajectories | Record the predicted trajectories and solver residuals of the controller (for mpc_gui) | – | false |
Variables ​
| Name | Description | Units |
|---|---|---|
theta | Angle | – |
omega | Angular velocity | – |
u1 | Torque | – |
flag | acados status | – |
Behavior ​
Behavior of this component cannot be rendered because it includes path variables.
Source ​
dyad
"""
Tracking of an angle reference with `ACADOSMPC` whose prediction model is the plant component itself
(`dynamics = plant, inputs = ["tau"]`), with the angular velocity softly bounded to ±1 (a named
constraint) and a real-time iteration (`SQP_RTI`) per tick. The reference steps from 0 to 0.5 rad at t = 1. Verified in `test/test_acados_mpc.jl`.
"""
example component ACADOSMPCTrackingExample
periodicclock = DiscreteComponents.PeriodicClock(dt = 0.05) {
"Dyad": {"placement": {"diagram": {"x1": 300, "y1": 100, "x2": 400, "y2": 200}}}
}
plant = MPCComponents.Examples.ACADOSPendulumPlant() {
"Dyad": {"placement": {"diagram": {"x1": 700, "y1": 300, "x2": 800, "y2": 400}}}
}
s1 = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {"diagram": {"x1": 500, "y1": 500, "x2": 600, "y2": 600, "rot": 180}}
}
}
s2 = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {"diagram": {"x1": 500, "y1": 650, "x2": 600, "y2": 750, "rot": 180}}
}
}
s3 = DiscreteComponents.Sampler() {
"Dyad": {"placement": {"diagram": {"x1": 100, "y1": 250, "x2": 200, "y2": 350}}}
}
zoh = DiscreteComponents.ZeroOrderHold() {
"Dyad": {"placement": {"diagram": {"x1": 500, "y1": 300, "x2": 600, "y2": 400}}}
}
ref = BlockComponents.Sources.Step(height = 0.5, start_time = 1.0) {
"Dyad": {"placement": {"diagram": {"x1": -100, "y1": 250, "x2": 0, "y2": 350}}}
}
zero = BlockComponents.Sources.Constant(k = 0.0) {
"Dyad": {"placement": {"diagram": {"x1": -100, "y1": 550, "x2": 0, "y2": 650}}}
}
mpc = MPCComponents.ACADOSMPC(dynamics = plant, inputs = ["tau"], state_variables = ["th", "om"], outputs = ["theta", "omega"], Ts = 0.05, Np = 20, Q1 = diagonal([10.0, 0.1]), Q2 = diagonal([0.01]), umin = [-8.0], umax = [8.0], constrained = ["omega"], constrained_min = [-1.0], constrained_max = [1.0], nlp_solver = ACADOSSolver.SQP_RTI(), final output_trajectories = output_trajectories) {
"Dyad": {"placement": {"diagram": {"x1": 300, "y1": 300, "x2": 400, "y2": 400}}}
}
"Record the predicted trajectories and solver residuals of the controller (for mpc_gui)"
structural parameter output_trajectories::Boolean = false
"Angle"
variable theta::Real
"Angular velocity"
variable omega::Real
"Torque"
variable u1::Real
"acados status"
variable flag::Real
relations
theta = plant.theta
omega = plant.omega
u1 = mpc.u[1]
flag = mpc.exitflag
connect(zoh.y, plant.tau)
connect(plant.theta, s1.u)
connect(plant.omega, s2.u)
connect(ref.y, s3.u)
connect(s1.y, mpc.x[1], periodicclock.y)
connect(s2.y, mpc.x[2])
connect(s3.y, mpc.r[1])
connect(zero.y, mpc.r[2])
connect(mpc.u[1], zoh.u)
metadata {"Dyad": {"doc": {"behavior": false}}}
endFlattened Source
dyad
"""
Tracking of an angle reference with `ACADOSMPC` whose prediction model is the plant component itself
(`dynamics = plant, inputs = ["tau"]`), with the angular velocity softly bounded to ±1 (a named
constraint) and a real-time iteration (`SQP_RTI`) per tick. The reference steps from 0 to 0.5 rad at t = 1. Verified in `test/test_acados_mpc.jl`.
"""
example component ACADOSMPCTrackingExample
periodicclock = DiscreteComponents.PeriodicClock(dt = 0.05) {
"Dyad": {"placement": {"diagram": {"x1": 300, "y1": 100, "x2": 400, "y2": 200}}}
}
plant = MPCComponents.Examples.ACADOSPendulumPlant() {
"Dyad": {"placement": {"diagram": {"x1": 700, "y1": 300, "x2": 800, "y2": 400}}}
}
s1 = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {"diagram": {"x1": 500, "y1": 500, "x2": 600, "y2": 600, "rot": 180}}
}
}
s2 = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {"diagram": {"x1": 500, "y1": 650, "x2": 600, "y2": 750, "rot": 180}}
}
}
s3 = DiscreteComponents.Sampler() {
"Dyad": {"placement": {"diagram": {"x1": 100, "y1": 250, "x2": 200, "y2": 350}}}
}
zoh = DiscreteComponents.ZeroOrderHold() {
"Dyad": {"placement": {"diagram": {"x1": 500, "y1": 300, "x2": 600, "y2": 400}}}
}
ref = BlockComponents.Sources.Step(height = 0.5, start_time = 1.0) {
"Dyad": {"placement": {"diagram": {"x1": -100, "y1": 250, "x2": 0, "y2": 350}}}
}
zero = BlockComponents.Sources.Constant(k = 0.0) {
"Dyad": {"placement": {"diagram": {"x1": -100, "y1": 550, "x2": 0, "y2": 650}}}
}
mpc = MPCComponents.ACADOSMPC(dynamics = plant, inputs = ["tau"], state_variables = ["th", "om"], outputs = ["theta", "omega"], Ts = 0.05, Np = 20, Q1 = diagonal([10.0, 0.1]), Q2 = diagonal([0.01]), umin = [-8.0], umax = [8.0], constrained = ["omega"], constrained_min = [-1.0], constrained_max = [1.0], nlp_solver = ACADOSSolver.SQP_RTI(), final output_trajectories = output_trajectories) {
"Dyad": {"placement": {"diagram": {"x1": 300, "y1": 300, "x2": 400, "y2": 400}}}
}
"Record the predicted trajectories and solver residuals of the controller (for mpc_gui)"
structural parameter output_trajectories::Boolean = false
"Angle"
variable theta::Real
"Angular velocity"
variable omega::Real
"Torque"
variable u1::Real
"acados status"
variable flag::Real
relations
theta = plant.theta
omega = plant.omega
u1 = mpc.u[1]
flag = mpc.exitflag
connect(zoh.y, plant.tau)
connect(plant.theta, s1.u)
connect(plant.omega, s2.u)
connect(ref.y, s3.u)
connect(s1.y, mpc.x[1], periodicclock.y)
connect(s2.y, mpc.x[2])
connect(s3.y, mpc.r[1])
connect(zero.y, mpc.r[2])
connect(mpc.u[1], zoh.u)
metadata {"Dyad": {"doc": {"behavior": false}}}
endTest Cases ​
No test cases defined.
Related ​
Examples
Experiments
Analyses