summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--templates/compute_minRPI.m23
-rw-r--r--templates/compute_tube_controller.m5
-rw-r--r--templates/simulate_uncertain.m13
3 files changed, 41 insertions, 0 deletions
diff --git a/templates/compute_minRPI.m b/templates/compute_minRPI.m
index 0b4ffdb..2ae7946 100644
--- a/templates/compute_minRPI.m
+++ b/templates/compute_minRPI.m
@@ -8,4 +8,27 @@
function [H_tube,h_tube,n_iter] = compute_minRPI(K_tube,params)
% YOUR CODE HERE
+ A = params.model.A+params.model.B*K_tube;
+ nx = params.model.nx;
+ omega = Polyhedron('A',[eye(nx);-eye(nx)],'b',zeros(1,2*nx)');
+ % display(omega.A)
+ % display(omega.b)
+ n_iter = 0;
+ Hw = params.constraints.DisturbanceMatrix;
+ hw = params.constraints.DisturbanceRHS;
+ while true
+ omega_last = copy(omega);
+ % display(n_iter)
+ % A_last = omega.A;
+ % b_last = omega.b;
+ omega = omega.plus(Polyhedron('A',Hw*(A^n_iter),'b',hw));
+
+ if eq(omega.minHRep(),omega_last.minHRep())
+ % if eq(omega,omega_last)
+ break
+ end
+ n_iter = n_iter+1;
+ end
+ H_tube = omega.A;
+ h_tube = omega.b;
end \ No newline at end of file
diff --git a/templates/compute_tube_controller.m b/templates/compute_tube_controller.m
index adca95d..2c567f0 100644
--- a/templates/compute_tube_controller.m
+++ b/templates/compute_tube_controller.m
@@ -8,4 +8,9 @@
function K_tube = compute_tube_controller(p,params)
% YOUR CODE HERE
+ Az = params.model.A;
+ Bz =params.model.B;
+ % Bz = [params.model.B,eye(params.model.nx)];
+ K_tube = -place(Az,Bz,p);
+ % K_tube = K(1:params.model.nu,:);
end \ No newline at end of file
diff --git a/templates/simulate_uncertain.m b/templates/simulate_uncertain.m
index dc9df26..f74f7af 100644
--- a/templates/simulate_uncertain.m
+++ b/templates/simulate_uncertain.m
@@ -8,4 +8,17 @@
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 \ No newline at end of file