summaryrefslogtreecommitdiffstats
path: root/templates/LQR.m
diff options
context:
space:
mode:
authorYuan Xu <yuanxu@student.ethz.ch>2023-05-11 12:00:59 +0200
committerYuan Xu <yuanxu@student.ethz.ch>2023-05-11 12:00:59 +0200
commitfeb6ec844cf2d0cdb07acd609615675141e2706a (patch)
tree1a411c04d693358a6ffc2d2a07e09bb819a8f6cc /templates/LQR.m
parentRevert mistakenly pushed to master (diff)
downloadmpc_pe-feb6ec844cf2d0cdb07acd609615675141e2706a.tar.gz
mpc_pe-feb6ec844cf2d0cdb07acd609615675141e2706a.zip
update previous filesyuanxu
Diffstat (limited to '')
-rw-r--r--templates/LQR.m12
1 files changed, 3 insertions, 9 deletions
diff --git a/templates/LQR.m b/templates/LQR.m
index c05237d..d23e64a 100644
--- a/templates/LQR.m
+++ b/templates/LQR.m
@@ -14,20 +14,14 @@ classdef LQR
methods
%constructor
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);
- [K,S,e] = dlqr(A,B,Q,R)
- % obj.K = -inv(B'*P_inf*B+R)*B'*P_inf*A;
- obj.K = -K;
+ [K,~,~] = dlqr(A,B,Q,R);
+ obj.K = K;
end
function [u, ctrl_info] = eval(obj,x)
- % YOUR CODE HERE
- % u = ...
- u = obj.K*x;
+ u = -obj.K * x;
ctrl_info = struct('ctrl_feas',true);
end
end