diff options
Diffstat (limited to '')
-rw-r--r-- | templates/LQR.m | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/templates/LQR.m b/templates/LQR.m index 2a79da9..76d95c6 100644 --- a/templates/LQR.m +++ b/templates/LQR.m @@ -15,13 +15,16 @@ classdef LQR %constructor function obj = LQR(Q,R,params) % YOUR CODE HERE - % obj.K = ... (save feedback matrix for use in eval function) + E = np.zeros(params.model.nx); + S = np.zeros(params.model.nx); + Pinf = idare(params.model.A, params.model.B, Q, R, S, E, 'noscaling') + obj.K = -inv(R + B' * Pinf * B) * B' * Pinf * A; end function [u, ctrl_info] = eval(obj,x) % YOUR CODE HERE - % u = ... + u = obj.K * x; ctrl_info = struct('ctrl_feas',true); end end -end
\ No newline at end of file +end |