Examples.EKFExportExample ​
An EKFObserver of the pendulum with free measurement and control inputs and the estimate as outputs, on the C backend, so that the model carries its own clock and is purely discrete. Exported to standalone C by the EKFExportDemo analysis. Without a plant subcomponent, the model of the filter is named by the component constructor of the plant, dynamics = ACADOSPendulumPlant.
Usage ​
MPCComponents.Examples.EKFExportExample()
Connectors ​
y- This connector represents a real signal as an input to a component (RealInput)u- This connector represents a real signal as an input to a component (RealInput)theta_hat- This connector represents a real signal as an output from a component (RealOutput)omega_hat- 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 ​
"""
An `EKFObserver` of the pendulum with free measurement and control inputs and the estimate as
outputs, on the C backend, so that the model carries its own clock and is purely discrete. Exported
to standalone C by the `EKFExportDemo` analysis. Without a plant subcomponent, the model of the
filter is named by the component constructor of the plant, `dynamics = ACADOSPendulumPlant`.
"""
example component EKFExportExample
"Sampled angle"
y = RealInput() {
"Dyad": {"placement": {"diagram": {"x1": 50, "y1": 400, "x2": 150, "y2": 500}}}
}
"Torque applied at the current tick"
u = RealInput() {
"Dyad": {"placement": {"diagram": {"x1": 50, "y1": 200, "x2": 150, "y2": 300}}}
}
"Estimated angle"
theta_hat = RealOutput() {
"Dyad": {"placement": {"diagram": {"x1": 600, "y1": 250, "x2": 700, "y2": 350}}}
}
"Estimated angular velocity"
omega_hat = RealOutput() {
"Dyad": {"placement": {"diagram": {"x1": 600, "y1": 400, "x2": 700, "y2": 500}}}
}
periodicclock = DiscreteComponents.PeriodicClock(dt = 0.05) {
"Dyad": {"placement": {"diagram": {"x1": 300, "y1": 100, "x2": 400, "y2": 200}}}
}
ekf = MPCComponents.EKFObserver(dynamics = ACADOSPendulumPlant, inputs = ["tau"], outputs = ["theta"], state_variables = ["th", "om"], Ts = 0.05, R1 = diagonal([1e-4, 1e-4]), R2 = diagonal([1e-3]), x0 = [0.0, 0.0], R0 = diagonal([1.0, 1.0]), backend = MPCComponents.Backend.C()) {
"Dyad": {"placement": {"diagram": {"x1": 300, "y1": 300, "x2": 400, "y2": 400}}}
}
relations
connect(y, ekf.y[1], periodicclock.y)
connect(u, ekf.u[1])
connect(ekf.xhat[1], theta_hat)
connect(ekf.xhat[2], omega_hat)
metadata {"Dyad": {"doc": {"behavior": false}}}
endFlattened Source
"""
An `EKFObserver` of the pendulum with free measurement and control inputs and the estimate as
outputs, on the C backend, so that the model carries its own clock and is purely discrete. Exported
to standalone C by the `EKFExportDemo` analysis. Without a plant subcomponent, the model of the
filter is named by the component constructor of the plant, `dynamics = ACADOSPendulumPlant`.
"""
example component EKFExportExample
"Sampled angle"
y = RealInput() {
"Dyad": {"placement": {"diagram": {"x1": 50, "y1": 400, "x2": 150, "y2": 500}}}
}
"Torque applied at the current tick"
u = RealInput() {
"Dyad": {"placement": {"diagram": {"x1": 50, "y1": 200, "x2": 150, "y2": 300}}}
}
"Estimated angle"
theta_hat = RealOutput() {
"Dyad": {"placement": {"diagram": {"x1": 600, "y1": 250, "x2": 700, "y2": 350}}}
}
"Estimated angular velocity"
omega_hat = RealOutput() {
"Dyad": {"placement": {"diagram": {"x1": 600, "y1": 400, "x2": 700, "y2": 500}}}
}
periodicclock = DiscreteComponents.PeriodicClock(dt = 0.05) {
"Dyad": {"placement": {"diagram": {"x1": 300, "y1": 100, "x2": 400, "y2": 200}}}
}
ekf = MPCComponents.EKFObserver(dynamics = ACADOSPendulumPlant, inputs = ["tau"], outputs = ["theta"], state_variables = ["th", "om"], Ts = 0.05, R1 = diagonal([1e-4, 1e-4]), R2 = diagonal([1e-3]), x0 = [0.0, 0.0], R0 = diagonal([1.0, 1.0]), backend = MPCComponents.Backend.C()) {
"Dyad": {"placement": {"diagram": {"x1": 300, "y1": 300, "x2": 400, "y2": 400}}}
}
relations
connect(y, ekf.y[1], periodicclock.y)
connect(u, ekf.u[1])
connect(ekf.xhat[1], theta_hat)
connect(ekf.xhat[2], omega_hat)
metadata {"Dyad": {"doc": {"behavior": false}}}
endTest Cases ​
No test cases defined.
Related ​
Examples
Experiments
Analyses