summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorYanzhenXiangRobotics <xyz000327@gmail.com>2023-04-26 11:14:56 +0200
committerYanzhenXiangRobotics <xyz000327@gmail.com>2023-04-26 11:14:56 +0200
commitda53e14088c5a48b22739e9f147de2aabd6ddb01 (patch)
treebb5673022963d65c7ca612b9cf30151c2b0f7e74 /templates
parentADD: another approach passing task 6 (diff)
downloadmpc_pe-da53e14088c5a48b22739e9f147de2aabd6ddb01.tar.gz
mpc_pe-da53e14088c5a48b22739e9f147de2aabd6ddb01.zip
ADD: pass task 7
Diffstat (limited to 'templates')
-rw-r--r--templates/simulate.m14
1 files changed, 14 insertions, 0 deletions
diff --git a/templates/simulate.m b/templates/simulate.m
index 3138cd1..20c77b2 100644
--- a/templates/simulate.m
+++ b/templates/simulate.m
@@ -10,5 +10,19 @@ function [Xt,Ut,ctrl_info] = simulate(x0, ctrl, params)
% YOUR CODE HERE
% Hint: you can access the control command with ctrl.eval(x(:,i))
+ Xt = [x0];
+ Ut = [];
+ x = x0
+ ctrl_info = [];
+ % obj = LQR();
+ for i = 1:params.model.HorizonLength
+ [u, ctrl_info_] = ctrl.eval(x);
+ Ut = [Ut u];
+ ctrl_info = [ctrl_info ctrl_info_];
+ x = params.model.A*x + params.model.B*u;
+ Xt = [Xt x];
+ end
+% Ut = u;
+% Xt = x;
end \ No newline at end of file