Chapter 5: Full State Feedback Control
State Feedback Controller
Where K is the feedback gain matrix.
Pole Placement
Design K to place closed-loop poles at desired locations.
from scipy import signal
def pole_placement(A, B, desired_poles):
K = signal.place_poles(A, B, desired_poles).gain_matrix
return K
LQR (Linear Quadratic Regulator)
Minimize cost function:
from scipy import linalg
def lqr(A, B, Q, R):
P = linalg.solve_continuous_are(A, B, Q, R)
K = np.linalg.inv(R) @ B.T @ P
return K
# Example
Q = np.diag([10, 1]) # State cost
R = np.array([[1]]) # Control cost
K = lqr(A, B, Q, R)
Next: Chapter 6 - Model Predictive Control!