summaryrefslogtreecommitdiffstats
path: root/Submission files/simulate_uncertain.m
blob: f74f7af49b0161e33cc07b74c6783d7c9dfd873d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (c) 2023, Amon Lahr, Simon Muntwiler, Antoine Leeman & Fabian Flürenbrock Institute for Dynamic Systems and Control, ETH Zurich.
%
% All rights reserved.
%
% Please see the LICENSE file that has been included as part of this package.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [Xt,Ut,ctrl_info] = simulate_uncertain(x0, ctrl, Wt, params)
	% YOUR CODE HERE
	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 + Wt(:,i);
        Xt = [Xt x];
    end
    % plot_trajectory(Xt, Ut, ctrl_info, params);
end