summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorYanzhenXiangRobotics <xyz000327@gmail.com>2023-04-26 10:57:19 +0200
committerYanzhenXiangRobotics <xyz000327@gmail.com>2023-04-26 10:57:19 +0200
commit253ac1306a5e6ec4ecef0ccd83dd660a38a1b194 (patch)
treee8ba22bb2ce2ae2bbd4865b96a676be5efc04588 /templates
parentFIX: .gitignore (diff)
downloadmpc_pe-253ac1306a5e6ec4ecef0ccd83dd660a38a1b194.tar.gz
mpc_pe-253ac1306a5e6ec4ecef0ccd83dd660a38a1b194.zip
ADD: pass task 6
Diffstat (limited to '')
-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