functionlqr
Information
Syntax
(K, sslqr, X, ev) = StateSpace.lqr(ss, Q, R, true)
Description
The optimal and stabilizing gain matrix K for a state-feedback law u = -K*x is designed such that the cost function
J = Integral {x'*Q*x + u'*R*u} dt
of the continuous time case or
Jd = Sum {x'k*Q*xk + u'k*R*uk}
of the discrete time case is minimized. The cases are chosen by the input iscontinuousSystem This is done by solving the continuous-time algebraic Riccati equation (CARE)
Q + A'*X + X*A - X*B*R-1*B'*X = 0
or the discrete-time algebraic Riccati equation (DARE)
X - A'*X*A + A'*X*B*(R + B'*X*B)-1*B'*X*A - Q = 0
for X using the Schur vector approach. See care and dare respectively for more details.
The gain matrix K of the continuous-time case is calculated from
K = R-1*B'*X
or from
K = (R + B'*X*B)-1*B'*X*A
for the discrete-time case. The output state space system sslqr represents the closed loop system
. x = [A - BK] x + Bu y = [C - DK] x + Du
The output S is the solution of the Riccati equation
The eigenvalues of the closed loop system A - B*K are computed as complex output ev.
Example
StateSpace ss=StateSpace(
A=[0, 1, 0, 0; 0, 0, 39.2, 0; 0, 0, 0, 1; 0, 0, 49, 0],
B=[0; 1; 0; 1],
C=[1, 0, 0, 0],
D=[0]);
Real Q[:,:]=identity(4);
Real R[:,:]=identity(1);
Real K[size(ss.B, 2),size(ss.A, 1)];
algorithm
K := StateSpace.Design.lqr(ss, Q, R);
// K = [-1, -3.63271, 108.763, 18.3815]
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| StateSpace | ss | Open loop system in state space form | |
| Real[size(ss.A, 1),size(ss.A, 2)] | Q | identity(size(ss.A, 1)) | State weighting matrix |
| Real[size(ss.B, 2),size(ss.B, 2)] | R | identity(size(ss.B, 2)) | Input weighting matrix |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[size(ss.B, 2),size(ss.A, 1)] | K | Feedback gain matrix | |
| StateSpace | sslqr | closed loop system | |
| Real[size(ss.A, 1),size(ss.A, 1)] | S | solution of the Riccati equation | |
| Complex[:] | ev | Eigenvalues of the closed loop system |
Revisions
| Date | Author | Comment |
|---|---|---|
| 2010-05-31 | Marcus Baur, DLR-RM | Realization |