control.lqr
- control.lqr(A, B, Q, R[, N])[source]
Linear quadratic regulator design.
The lqr() function computes the optimal state feedback controller u = -K x that minimizes the quadratic cost
The function can be called with either 3, 4, or 5 arguments:
K, S, E = lqr(sys, Q, R)
K, S, E = lqr(sys, Q, R, N)
K, S, E = lqr(A, B, Q, R)
K, S, E = lqr(A, B, Q, R, N)
where
sys
is anLTI
object, andA
,B
,Q
,R
, andN
are 2D arrays or matrices of appropriate dimension.- Parameters
- A, B2D array_like
Dynamics and input matrices.
- sysLTI
StateSpace
system Linear system.
- Q, R2D array
State and input weight matrices.
- N2D array, optional
Cross weight matrix.
- integral_actionndarray, optional
If this keyword is specified, the controller includes integral action in addition to state feedback. The value of the
integral_action
keyword should be an ndarray that will be multiplied by the current state to generate the error for the internal integrator states of the control law. The number of outputs that are to be integrated must match the number of additional rows and columns in theQ
matrix.- methodstr, optional
Set the method used for computing the result. Current methods are ‘slycot’ and ‘scipy’. If set to None (default), try ‘slycot’ first and then ‘scipy’.
- Returns
- K2D array
State feedback gains.
- S2D array
Solution to Riccati equation.
- E1D array
Eigenvalues of the closed loop system.
Notes
If the first argument is an LTI object, then this object will be used to define the dynamics and input matrices. Furthermore, if the LTI object corresponds to a discrete-time system, the
dlqr
function will be called.Examples
>>> K, S, E = lqr(sys, Q, R, [N]) >>> K, S, E = lqr(A, B, Q, R, [N])