Skip to content
LIBRARY
Examples.ACADOSScheduledExportExample.md

Examples.ACADOSScheduledExportExample ​

A purely discrete ACADOSScheduledController for C code export: the sampled measurement, reference and scheduling variable are inputs, the control and the acados status are outputs, and a PeriodicClock is connected to one input so the model carries its own clock. The controller is the acados counterpart of LinearMPCScheduledExportExample and takes the same bank (build_scheduled_export_bank, a double integrator whose input gain is the scheduling variable), so the two exported controllers can be compared on the same problem. Exported to standalone C by the CCodeExport analysis.

Usage ​

MPCComponents.Examples.ACADOSScheduledExportExample()

Parameters: ​

NameDescriptionUnitsDefault value
bankBank of controllers for the input gains 0.5, 1 and 2–build_sched...port_bank()

Connectors ​

  • y - This connector represents a real signal as an input to a component (RealInput)

  • r - This connector represents a real signal as an input to a component (RealInput)

  • rho - This connector represents a real signal as an input to a component (RealInput)

  • u - This connector represents a real signal as an output from a component (RealOutput)

  • status - This connector represents a real signal as an output from a component (RealOutput)

Behavior ​

Behavior of this component cannot be rendered because it includes path variables.

Source ​

dyad
"""
A purely discrete `ACADOSScheduledController` for C code export: the sampled measurement, reference
and scheduling variable are inputs, the control and the acados status are outputs, and a
`PeriodicClock` is connected to one input so the model carries its own clock. The controller is the
acados counterpart of `LinearMPCScheduledExportExample` and takes the same bank
(`build_scheduled_export_bank`, a double integrator whose input gain is the scheduling variable), so
the two exported controllers can be compared on the same problem. Exported to standalone C by the
`CCodeExport` analysis.
"""
example component ACADOSScheduledExportExample
  "Sampled position measurement"
  y = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -100, "y1": 350, "x2": 0, "y2": 450}}}
  }
  "Position reference"
  r = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -100, "y1": 550, "x2": 0, "y2": 650}}}
  }
  "Scheduling variable (the plant's input gain)"
  rho = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -100, "y1": 150, "x2": 0, "y2": 250}}}
  }
  "Control signal"
  u = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "y1": 450, "x2": 1100, "y2": 550}}}
  }
  "acados status of the last solve"
  status = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "y1": 650, "x2": 1100, "y2": 750}}}
  }
  periodicclock = DiscreteComponents.PeriodicClock(dt = 0.1) {
    "Dyad": {"placement": {"diagram": {"x1": 200, "y1": 700, "x2": 400, "y2": 900}}}
  }
  mpc = MPCComponents.Experimental.ACADOSScheduledController(mpc = bank, backend = MPCComponents.Backend.C()) {
    "Dyad": {"placement": {"diagram": {"x1": 400, "y1": 350, "x2": 600, "y2": 650}}}
  }
  "Bank of controllers for the input gains 0.5, 1 and 2"
  structural parameter bank::MPCComponents.MPCRef = build_scheduled_export_bank()
relations
  connect(y, mpc.y[1], periodicclock.y) {}
  connect(r, mpc.r[1]) {}
  connect(rho, mpc.rho) {}
  connect(mpc.u[1], u) {}
  connect(mpc.exitflag, status) {}
metadata {"Dyad": {"doc": {"behavior": false}}}
end
Flattened Source
dyad
"""
A purely discrete `ACADOSScheduledController` for C code export: the sampled measurement, reference
and scheduling variable are inputs, the control and the acados status are outputs, and a
`PeriodicClock` is connected to one input so the model carries its own clock. The controller is the
acados counterpart of `LinearMPCScheduledExportExample` and takes the same bank
(`build_scheduled_export_bank`, a double integrator whose input gain is the scheduling variable), so
the two exported controllers can be compared on the same problem. Exported to standalone C by the
`CCodeExport` analysis.
"""
example component ACADOSScheduledExportExample
  "Sampled position measurement"
  y = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -100, "y1": 350, "x2": 0, "y2": 450}}}
  }
  "Position reference"
  r = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -100, "y1": 550, "x2": 0, "y2": 650}}}
  }
  "Scheduling variable (the plant's input gain)"
  rho = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -100, "y1": 150, "x2": 0, "y2": 250}}}
  }
  "Control signal"
  u = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "y1": 450, "x2": 1100, "y2": 550}}}
  }
  "acados status of the last solve"
  status = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "y1": 650, "x2": 1100, "y2": 750}}}
  }
  periodicclock = DiscreteComponents.PeriodicClock(dt = 0.1) {
    "Dyad": {"placement": {"diagram": {"x1": 200, "y1": 700, "x2": 400, "y2": 900}}}
  }
  mpc = MPCComponents.Experimental.ACADOSScheduledController(mpc = bank, backend = MPCComponents.Backend.C()) {
    "Dyad": {"placement": {"diagram": {"x1": 400, "y1": 350, "x2": 600, "y2": 650}}}
  }
  "Bank of controllers for the input gains 0.5, 1 and 2"
  structural parameter bank::MPCComponents.MPCRef = build_scheduled_export_bank()
relations
  connect(y, mpc.y[1], periodicclock.y) {}
  connect(r, mpc.r[1]) {}
  connect(rho, mpc.rho) {}
  connect(mpc.u[1], u) {}
  connect(mpc.exitflag, status) {}
metadata {"Dyad": {"doc": {"behavior": false}}}
end


Test Cases ​

No test cases defined.

  • Examples

  • Experiments

  • Analyses