Skip to content
LIBRARY
Examples.LinearMPCScheduledExportExample.md

Examples.LinearMPCScheduledExportExample ​

A LinearMPCScheduledController for the double integrator with a scheduled input gain, with its clock and free top-level connectors, the shape a gain-scheduled controller takes to be exported as standalone C (see CCodeExport and LinearMPCScheduledExportDemo). y is the sampled position, r the position reference, rho the scheduling variable (the input gain, the bank has members at 0.5, 1 and 2; see build_scheduled_export_bank), u the control and status the composite solver exit flag. The exported code links one library per member.

Usage ​

MPCComponents.Examples.LinearMPCScheduledExportExample()

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 `LinearMPCScheduledController` for the double integrator with a scheduled input gain, with its
clock and free top-level connectors, the shape a gain-scheduled controller takes to be exported as
standalone C (see `CCodeExport` and `LinearMPCScheduledExportDemo`). `y` is the sampled position,
`r` the position reference, `rho` the scheduling variable (the input gain, the bank has members at
0.5, 1 and 2; see `build_scheduled_export_bank`), `u` the control and `status` the composite
solver exit flag. The exported code links one library per member.
"""
example component LinearMPCScheduledExportExample
  "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}}}
  }
  "Composite solver status (DAQP exit flags of the active members)"
  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.LinearMPCScheduledController(mpc = bank) {
    "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 `LinearMPCScheduledController` for the double integrator with a scheduled input gain, with its
clock and free top-level connectors, the shape a gain-scheduled controller takes to be exported as
standalone C (see `CCodeExport` and `LinearMPCScheduledExportDemo`). `y` is the sampled position,
`r` the position reference, `rho` the scheduling variable (the input gain, the bank has members at
0.5, 1 and 2; see `build_scheduled_export_bank`), `u` the control and `status` the composite
solver exit flag. The exported code links one library per member.
"""
example component LinearMPCScheduledExportExample
  "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}}}
  }
  "Composite solver status (DAQP exit flags of the active members)"
  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.LinearMPCScheduledController(mpc = bank) {
    "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