Created
April 13, 2017 16:41
-
-
Save superjax/2a55f11a292cd7b53624cc8dc36bef8e to your computer and use it in GitHub Desktop.
LQR Controller for Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lqr(A,B,Q,R): | |
#first, try to solve the ricatti equation | |
X = np.matrix(solve_continuous_are(A, B, Q, R)) | |
#compute the LQR gain | |
K = np.matrix(inv(R)*(B.T*X)) | |
eigVals, eigVecs = eig(A-B*K) | |
return K, X, eigVals |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment