Skip to content
LIBRARY
Examples.ACADOSMPCExportExample.md

Examples.ACADOSMPCExportExample ​

A purely discrete ACADOSMPC controller for C code export: the state and reference are sampled inputs, the control and status are outputs, and a PeriodicClock is connected to one input so the model carries its own clock. Exported to standalone C by the CCodeExport analysis. A purely discrete model has no plant subcomponent, so the prediction model is named by the component constructor of the plant, dynamics = ACADOSPendulumPlant, which the controller instantiates.

Usage ​

MPCComponents.Examples.ACADOSMPCExportExample()

Connectors ​

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

  • x2 - 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 `ACADOSMPC` controller for C code export: the state and reference are sampled
inputs, the control and status are outputs, and a `PeriodicClock` is connected to one input so the
model carries its own clock. Exported to standalone C by the `CCodeExport` analysis. A purely
discrete model has no plant subcomponent, so the prediction model is named by the component
constructor of the plant, `dynamics = ACADOSPendulumPlant`, which the controller instantiates.
"""
example component ACADOSMPCExportExample
  "Sampled state"
  x1 = RealInput() {}
  x2 = RealInput() {}
  "Control"
  u = RealOutput() {}
  "acados status"
  status = RealOutput() {}
  periodicclock = DiscreteComponents.PeriodicClock(dt = 0.05) {}
  mpc = MPCComponents.ACADOSMPC(dynamics = ACADOSPendulumPlant, inputs = ["tau"], state_variables = ["th", "om"], outputs = ["theta", "omega"], Ts = 0.05, Np = 15, Q1 = diagonal([10.0, 0.1]), Q2 = diagonal([0.05]), umin = [-5.0], umax = [5.0], reference_tracking = false, backend = Backend.C()) {}
relations
  connect(x1, mpc.x[1], periodicclock.y)
  connect(x2, mpc.x[2])
  connect(mpc.u[1], u)
  connect(mpc.exitflag, status)
metadata {"Dyad": {"doc": {"behavior": false}}}
end
Flattened Source
dyad
"""
A purely discrete `ACADOSMPC` controller for C code export: the state and reference are sampled
inputs, the control and status are outputs, and a `PeriodicClock` is connected to one input so the
model carries its own clock. Exported to standalone C by the `CCodeExport` analysis. A purely
discrete model has no plant subcomponent, so the prediction model is named by the component
constructor of the plant, `dynamics = ACADOSPendulumPlant`, which the controller instantiates.
"""
example component ACADOSMPCExportExample
  "Sampled state"
  x1 = RealInput() {}
  x2 = RealInput() {}
  "Control"
  u = RealOutput() {}
  "acados status"
  status = RealOutput() {}
  periodicclock = DiscreteComponents.PeriodicClock(dt = 0.05) {}
  mpc = MPCComponents.ACADOSMPC(dynamics = ACADOSPendulumPlant, inputs = ["tau"], state_variables = ["th", "om"], outputs = ["theta", "omega"], Ts = 0.05, Np = 15, Q1 = diagonal([10.0, 0.1]), Q2 = diagonal([0.05]), umin = [-5.0], umax = [5.0], reference_tracking = false, backend = Backend.C()) {}
relations
  connect(x1, mpc.x[1], periodicclock.y)
  connect(x2, mpc.x[2])
  connect(mpc.u[1], u)
  connect(mpc.exitflag, status)
metadata {"Dyad": {"doc": {"behavior": false}}}
end


Test Cases ​

No test cases defined.

  • Examples

  • Experiments

  • Analyses