summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--templates/LQR.m6
1 files changed, 6 insertions, 0 deletions
diff --git a/templates/LQR.m b/templates/LQR.m
index 2a79da9..c84a670 100644
--- a/templates/LQR.m
+++ b/templates/LQR.m
@@ -16,11 +16,17 @@ classdef LQR
function obj = LQR(Q,R,params)
% YOUR CODE HERE
% obj.K = ... (save feedback matrix for use in eval function)
+ A = params.model.A;
+ B = params.model.B;
+ [X, L, G] = dare(A,B,Q,R);
+ % obj.K = -inv(B'*P_inf*B+R)*B'*P_inf*A;
+ obj.K = -G;
end
function [u, ctrl_info] = eval(obj,x)
% YOUR CODE HERE
% u = ...
+ u = obj.K*x;
ctrl_info = struct('ctrl_feas',true);
end
end