You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/lqg.jl
+29-6Lines changed: 29 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,11 @@ Several functions are defined for instances of `LQGProblem`
68
68
- [`observer_controller`](@ref)
69
69
70
70
A video tutorial on how to use the LQG interface is available [here](https://youtu.be/NuAxN1mGCPs)
71
+
72
+
## Introduction of references
73
+
The most principled way of introducing references is to add references as measured inputs to the extended statespace model, and to let the performance output `z` be the differences between the references and the outputs for which references are provided.
74
+
75
+
A less cumbersome way is not not consider references when constructing the `LQGProblem`, and instead pass the `z` keyword arugment to [`extended_controller`](@ref) in order to obtain a closed-loop system from state references to controlled outputs, and use some form of inverse of the DC gain of this system (or one of its subsystems) to pre-compensate the reference input.
71
76
"""
72
77
struct LQGProblem
73
78
sys::ExtendedStateSpace
@@ -266,9 +271,9 @@ function extended_controller(K::AbstractStateSpace)
266
271
end
267
272
268
273
"""
269
-
extended_controller(l::LQGProblem, L = lqr(l), K = kalman(l))
274
+
extended_controller(l::LQGProblem, L = lqr(l), K = kalman(l); z = nothing)
270
275
271
-
Returns an expression for the controller that is obtained when state-feedback `u = L(xᵣ-x̂)` is combined with a Kalman filter with gain `K` that produces state estimates x̂. The controller is an instance of `ExtendedStateSpace` where `C2 = -L, D21 = L` and `B2 = K`.
276
+
Returns a statespace system representing the controller that is obtained when state-feedback `u = L(xᵣ-x̂)` is combined with a Kalman filter with gain `K` that produces state estimates x̂. The controller is an instance of `ExtendedStateSpace` where `C2 = -L, D21 = L` and `B2 = K`.
272
277
273
278
The returned system has *inputs* `[xᵣ; y]` and outputs the control signal `u`. If a reference model `R` is used to generate state references `xᵣ`, the controller from `(ry, y) -> u` where `ry - y = e` is given by
274
279
```julia
@@ -284,22 +289,30 @@ Ce = extended_controller(l)
284
289
system_mapping(Ce) == -C
285
290
```
286
291
287
-
Please note, without the reference pre-filter, the DC gain from references to controlled outputs may not be identity.
292
+
Please note, without the reference pre-filter, the DC gain from references to controlled outputs may not be identity. If a vector of output indices is provided through the keyword argument `z`, the closed-loop system from state reference `xᵣ` to outputs `z` is returned as a second return argument. The inverse of the DC-gain of this closed-loop system may be useful to compensate for the DC-gain of the controller.
288
293
"""
289
-
functionextended_controller(l::LQGProblem, L =lqr(l), K =kalman(l))
observer_controller(l::LQGProblem, L = lqr(l), K = kalman(l))
305
318
@@ -342,6 +355,16 @@ end
342
355
Return the feedforward controller ``C_{ff}`` that maps references to plant inputs:
343
356
``u = C_{fb}y + C_{ff}r``
344
357
358
+
The following should hold
359
+
```
360
+
Cff = RobustAndOptimalControl.ff_controller(l)
361
+
Cfb = observer_controller(l)
362
+
Gcl = feedback(system_mapping(l), Cfb) * Cff # Note the comma in feedback, P/(I + PC) * Cff
363
+
dcgain(Gcl) ≈ I # Or some I-like non-square matrix
364
+
```
365
+
366
+
Note, if [`extended_controller`](@ref) is used, the DC-gain compensation above cannot be used. The [`extended_controller`](@ref) assumes that the references enter like `u = L(xᵣ - x̂)`.
367
+
345
368
See also [`observer_controller`](@ref).
346
369
"""
347
370
functionff_controller(l::LQGProblem, L =lqr(l), K =kalman(l); comp_dc =true)
# Below we test that the closed-loop DC gain from references to cart position is 1
492
+
Ce =extended_controller(lqg)
493
+
494
+
495
+
# Method 1: compute DC gain compensation using ff_controller, this is used as reference for the others. I feel uneasy about the (undocumented) comp_dc = false argument here, ideally a more generally applicable function ff_controller would be implemented that can handle both state and output references etc.
0 commit comments