You further have the function kalman
and the helper type LQG
available, see docs for LGQ
below
julia> using ControlSystems
help?> LQG
search: LQG lqg lqgi
G = LQG(A,B,C,D, Q1, Q2, R1, R2; qQ=0, qR=0, integrator=false)
G = LQG(sys, args...; kwargs...)
Return an LQG object that describes the closed control loop around the process sys=ss(A,B,C,D) where the controller is of LQG-type. The
controller is specified by weight matrices R1,R2 that penalizes state deviations and control signal variance respectively, and
covariance matrices Q1,Q2 which specify state drift and measurement covariance respectively. This constructor calls lqr and kalman and
forms the closed-loop system.
If integrator=true, the resulting controller will have intregral action. This is achieved by adding a model of a constant disturbance on
the inputs to the system described by A,B,C,D.
qQ and qR can be set to incorporate loop transfer recovery, i.e.,
L = lqr(A, B, Q1+qQ*C'C, Q2)
K = kalman(A, C, R1+qR*B*B', R2)
Fields
≡≡≡≡≡≡≡≡
When the LQG-object is populated by the lqg-function, the following fields have been made available
• L is the feedback matrix, such that A-BL is stable. Note that the length of the state vector (and the width of L) is increased
by the number of inputs if the option integrator=true.
• K is the kalman gain such that A-KC is stable
• sysc is a dynamical system describing the controller u=L*inv(A-BL-KC+KDL)Ky
Functions
≡≡≡≡≡≡≡≡≡≡≡
Several other properties of the object are accessible with the indexing function getindex() and are called with the syntax G[:function].
The available functions are (some have many alternative names, separated with / )
-G[:cl] / G[:closedloop] is the closed-loop system, including observer, from reference to output, precompensated to have static gain 1
(u = −Lx + lᵣr). -G[:S] / G[:Sin] Input sensitivity function -G[:T] / G[:Tin] Input complementary sensitivity function -G[:Sout] Output
sensitivity function -G[:Tout] Output complementary sensitivity function -G[:CS] The transfer function from measurement noise to control
signal -G[:DS] The transfer function from input load disturbance to output -G[:lt] / G[:looptransfer] / G[:loopgain] = PC -G[:rd] /
G[:returndifference] = I + PC -G[:sr] / G[:stabilityrobustness] = I + inv(PC) -G[:sysc] / G[:controller] Returns the controller as a
StateSpace-system
It is also possible to access all fileds using the G[:symbol] syntax, the fields are P ,Q1,Q2,R1,R2,qQ,qR,sysc,L,K,integrator
Example
≡≡≡≡≡≡≡≡≡
qQ = 1
qR = 1
Q1 = 10eye(4)
Q2 = 1eye(2)
R1 = 1eye(6)
R2 = 1eye(2)
G = LQG(sys, Q1, Q2, R1, R2, qQ=qQ, qR=qR, integrator=true)
Gcl = G[:cl]
T = G[:T]
S = G[:S]
sigmaplot([S,T],logspace(-3,3,1000))
stepplot(Gcl)
If you check the implementation of kalman
you see that it uses the above described duality
function kalman(sys::StateSpace, R1,R2)
if iscontinuous(sys)
return lqr(sys.A', sys.C', R1,R2)'
else
return dlqr(sys.A', sys.C', R1,R2)'
end
end