SimpleLQR Icon
Examples.SimpleLQR
State feedback of a double integrator, computed on a periodic clock.
The two integrators form the plant, the two samplers read its states onto a 10 Hz clock, MatrixGain applies the feedback gain to the stacked state vector and the zero-order hold returns the control signal to the continuous plant. The first integrator starts at x0 = 1, so the response is the regulation of that initial state to zero.
Usage
DiscreteComponents.Examples.SimpleLQR()
Behavior
19-element Vector{Symbolics.Equation}:
connect(integrator.y(t), sampler.u(t), integrator1.u(t))
connect(sampler.y(t), mux.u1(t), periodicclock.y(t))
connect(sampler1.y(t), mux.u2(t))
connect(integrator1.y(t), sampler1.u(t))
connect(zeroorderhold.y(t), integrator.u(t))
connect(mux.y(t), matrixgain.u(t))
connect(matrixgain.y(t), selector.u(t))
connect(selector.y(t), zeroorderhold.u(t))
zeroorderhold₊y(t) ~ ModelingToolkitBase.Hold()(zeroorderhold₊u(t))
sampler₊y(t) ~ Sample(InferredClock.InferredDiscrete(0))(sampler₊u(t))
Differential(t, 1)(integrator₊x(t)) ~ integrator₊k*integrator₊u(t)
integrator₊y(t) ~ integrator₊x(t)
Differential(t, 1)(integrator1₊x(t)) ~ integrator1₊k*integrator1₊u(t)
integrator1₊y(t) ~ integrator1₊x(t)
(mux₊y(t))[1] ~ mux₊u1(t)
(mux₊y(t))[2] ~ mux₊u2(t)
sampler1₊y(t) ~ Sample(InferredClock.InferredDiscrete(0))(sampler1₊u(t))
(matrixgain₊y(t))[1] ~ matrixgain₊K[1, 1]*(matrixgain₊u(t))[1] + matrixgain₊K[1, 2]*(matrixgain₊u(t))[2]
selector₊y(t) ~ (selector₊u(t))[1]Source
"""
State feedback of a double integrator, computed on a periodic clock.
The two integrators form the plant, the two samplers read its states onto a 10 Hz clock,
`MatrixGain` applies the feedback gain to the stacked state vector and the zero-order hold
returns the control signal to the continuous plant. The first integrator starts at
`x0 = 1`, so the response is the regulation of that initial state to zero.
"""
component SimpleLQR
zeroorderhold = DiscreteComponents.ZeroOrderHold() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 380, "y1": 320, "x2": 470, "y2": 410, "rot": 0}
},
"tags": []
}
}
sampler = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 720, "y1": 460, "x2": 630, "y2": 550, "rot": 270}
},
"tags": []
}
}
periodicclock = DiscreteComponents.PeriodicClock(dt = 0.1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 860, "y1": 700, "x2": 950, "y2": 790, "rot": 0}
},
"tags": []
}
}
integrator = BlockComponents.Continuous.Integrator(x0 = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 530, "y1": 310, "x2": 630, "y2": 410, "rot": 0}
},
"tags": []
}
}
integrator1 = BlockComponents.Continuous.Integrator() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 760, "y1": 310, "x2": 860, "y2": 410, "rot": 0}
},
"tags": []
}
}
"Feedback gain"
mux = DiscreteComponents.Examples.Mux() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 650, "y1": 600, "x2": 570, "y2": 680, "rot": 0}
},
"tags": []
}
}
sampler1 = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 870, "y1": 460, "x2": 950, "y2": 540, "rot": 90}
},
"tags": []
}
}
matrixgain = DiscreteComponents.Examples.MatrixGain(ny = 1, K = [[-1, -1]]) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 510, "y1": 590, "x2": 410, "y2": 690, "rot": 0}
},
"tags": []
}
}
"Picks a scalar index from an array"
selector = DiscreteComponents.Examples.Selector() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 260, "y1": 480, "x2": 360, "y2": 580, "rot": 270}
},
"tags": []
}
}
relations
connect(integrator.y, sampler.u, integrator1.u) {
"Dyad": {
"edges": [
{"S": 1, "M": [], "E": -1},
{"S": 2, "M": [{"x": 675, "y": 410}, {"x": 670, "y": 410}], "E": -1},
{"S": -1, "M": [], "E": 3}
],
"junctions": [{"x": 670, "y": 360}],
"renderStyle": "standard"
}
}
connect(sampler.y, mux.u1, periodicclock.y) {
"Dyad": {
"edges": [
{"S": 1, "M": [], "E": -1},
{"S": -1, "M": [], "E": 2},
{"S": 3, "M": [{"x": 675, "y": 745}], "E": -1}
],
"junctions": [{"x": 675, "y": 619.2}],
"renderStyle": "standard"
}
}
connect(sampler1.y, mux.u2) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 910, "y": 660.8}], "E": 2}],
"renderStyle": "standard"
}
}
connect(integrator1.y, sampler1.u) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 910, "y": 360}], "E": 2}],
"renderStyle": "standard"
}
}
connect(zeroorderhold.y, integrator.u) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 497.95, "y": 365}, {"x": 497.95, "y": 360}], "E": 2}],
"renderStyle": "standard"
}
}
connect(mux.y, matrixgain.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(matrixgain.y, selector.u) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 310, "y": 640}], "E": 2}]
}
}
connect(selector.y, zeroorderhold.u) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 310, "y": 365}], "E": 2}]
}
}
metadata {
"Dyad": {
"experiments": {},
"tests": {},
"labels": [],
"icons": {"default": "dyad://Dyad/Default.svg"},
"path": {},
"doc": {"behavior": true}
}
}
end
Flattened Source
"""
State feedback of a double integrator, computed on a periodic clock.
The two integrators form the plant, the two samplers read its states onto a 10 Hz clock,
`MatrixGain` applies the feedback gain to the stacked state vector and the zero-order hold
returns the control signal to the continuous plant. The first integrator starts at
`x0 = 1`, so the response is the regulation of that initial state to zero.
"""
component SimpleLQR
zeroorderhold = DiscreteComponents.ZeroOrderHold() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 380, "y1": 320, "x2": 470, "y2": 410, "rot": 0}
},
"tags": []
}
}
sampler = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 720, "y1": 460, "x2": 630, "y2": 550, "rot": 270}
},
"tags": []
}
}
periodicclock = DiscreteComponents.PeriodicClock(dt = 0.1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 860, "y1": 700, "x2": 950, "y2": 790, "rot": 0}
},
"tags": []
}
}
integrator = BlockComponents.Continuous.Integrator(x0 = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 530, "y1": 310, "x2": 630, "y2": 410, "rot": 0}
},
"tags": []
}
}
integrator1 = BlockComponents.Continuous.Integrator() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 760, "y1": 310, "x2": 860, "y2": 410, "rot": 0}
},
"tags": []
}
}
"Feedback gain"
mux = DiscreteComponents.Examples.Mux() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 650, "y1": 600, "x2": 570, "y2": 680, "rot": 0}
},
"tags": []
}
}
sampler1 = DiscreteComponents.Sampler() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 870, "y1": 460, "x2": 950, "y2": 540, "rot": 90}
},
"tags": []
}
}
matrixgain = DiscreteComponents.Examples.MatrixGain(ny = 1, K = [[-1, -1]]) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 510, "y1": 590, "x2": 410, "y2": 690, "rot": 0}
},
"tags": []
}
}
"Picks a scalar index from an array"
selector = DiscreteComponents.Examples.Selector() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 260, "y1": 480, "x2": 360, "y2": 580, "rot": 270}
},
"tags": []
}
}
relations
connect(integrator.y, sampler.u, integrator1.u) {
"Dyad": {
"edges": [
{"S": 1, "M": [], "E": -1},
{"S": 2, "M": [{"x": 675, "y": 410}, {"x": 670, "y": 410}], "E": -1},
{"S": -1, "M": [], "E": 3}
],
"junctions": [{"x": 670, "y": 360}],
"renderStyle": "standard"
}
}
connect(sampler.y, mux.u1, periodicclock.y) {
"Dyad": {
"edges": [
{"S": 1, "M": [], "E": -1},
{"S": -1, "M": [], "E": 2},
{"S": 3, "M": [{"x": 675, "y": 745}], "E": -1}
],
"junctions": [{"x": 675, "y": 619.2}],
"renderStyle": "standard"
}
}
connect(sampler1.y, mux.u2) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 910, "y": 660.8}], "E": 2}],
"renderStyle": "standard"
}
}
connect(integrator1.y, sampler1.u) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 910, "y": 360}], "E": 2}],
"renderStyle": "standard"
}
}
connect(zeroorderhold.y, integrator.u) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 497.95, "y": 365}, {"x": 497.95, "y": 360}], "E": 2}],
"renderStyle": "standard"
}
}
connect(mux.y, matrixgain.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(matrixgain.y, selector.u) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 310, "y": 640}], "E": 2}]
}
}
connect(selector.y, zeroorderhold.u) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 310, "y": 365}], "E": 2}]
}
}
metadata {
"Dyad": {
"experiments": {},
"tests": {},
"labels": [],
"icons": {"default": "dyad://Dyad/Default.svg"},
"path": {},
"doc": {"behavior": true}
}
}
endTest Cases
No test cases defined.
Related
- Examples
- Experiments
- Analyses