From c30079b64d19e8b46b111fb2110dbebf9ed32c37 Mon Sep 17 00:00:00 2001 From: YanzhenXiangRobotics Date: Tue, 25 Apr 2023 20:41:27 +0200 Subject: ADD: .gitignore --- .MATLABDriveTag | 1 - .gitignore | 1 + install_mpt3.m | 108 --------------------- project2023.pdf | Bin 360222 -> 0 bytes templates/.MATLABDriveTag | 1 - templates/LICENSE.txt | 7 -- templates/LQR.m | 27 ------ templates/MPC.m | 45 --------- templates/MPC_TE.m | 36 ------- templates/MPC_TE_forces.m | 38 -------- templates/MPC_TS.m | 36 ------- templates/MPC_TS_SC.m | 36 ------- templates/MPC_TUBE.m | 40 -------- templates/compute_minRPI.m | 11 --- templates/compute_tightening.m | 11 --- templates/compute_tube_controller.m | 11 --- templates/generate_constraints.m | 19 ---- templates/generate_disturbances.m | 11 --- templates/generate_params.m | 73 -------------- templates/generate_params_z.m | 55 ----------- templates/generate_system.m | 19 ---- templates/generate_system_cont.m | 22 ----- templates/generate_system_scaled.m | 15 --- templates/lqr_maxPI.m | 12 --- templates/lqr_tuning.m | 11 --- templates/plot_trajectory.m | 126 ------------------------- templates/plot_trajectory_z.m | 78 --------------- templates/simulate.m | 14 --- templates/simulate_uncertain.m | 11 --- templates/traj_constraints.m | 12 --- templates/traj_cost.m | 11 --- testing/.MATLABDriveTag | 1 - testing/TestFunction.p | Bin 3855 -> 0 bytes testing/TestFunction_LQR.p | Bin 970 -> 0 bytes testing/TestFunction_MPC.p | Bin 1717 -> 0 bytes testing/TestFunction_MPC_TE.p | Bin 1659 -> 0 bytes testing/TestFunction_MPC_TE_forces.p | Bin 1670 -> 0 bytes testing/TestFunction_MPC_TS.p | Bin 1761 -> 0 bytes testing/TestFunction_MPC_TS_SC.p | Bin 2187 -> 0 bytes testing/TestFunction_MPC_TS_SC_script.p | Bin 1179 -> 0 bytes testing/TestFunction_MPC_TUBE.p | Bin 1857 -> 0 bytes testing/TestFunction_MPC_TUBE_script.p | Bin 1033 -> 0 bytes testing/TestFunction_compute_minRPI.p | Bin 593 -> 0 bytes testing/TestFunction_compute_tightening.p | Bin 1000 -> 0 bytes testing/TestFunction_compute_tube_controller.p | Bin 647 -> 0 bytes testing/TestFunction_generate_constraints.p | Bin 763 -> 0 bytes testing/TestFunction_generate_disturbances.p | Bin 864 -> 0 bytes testing/TestFunction_generate_params.p | Bin 1247 -> 0 bytes testing/TestFunction_generate_system.p | Bin 840 -> 0 bytes testing/TestFunction_generate_system_cont.p | Bin 852 -> 0 bytes testing/TestFunction_generate_system_scaled.p | Bin 886 -> 0 bytes testing/TestFunction_lqr_maxPI.p | Bin 785 -> 0 bytes testing/TestFunction_lqr_tuning.p | Bin 1529 -> 0 bytes testing/TestFunction_lqr_tuning_script.p | Bin 906 -> 0 bytes testing/TestFunction_simulate.p | Bin 983 -> 0 bytes testing/TestFunction_simulate_uncertain.p | Bin 1251 -> 0 bytes testing/TestFunction_traj_constraints.p | Bin 1405 -> 0 bytes testing/TestFunction_traj_cost.p | Bin 694 -> 0 bytes testing/linearController.p | Bin 183 -> 0 bytes testing/run_tests.p | Bin 3072 -> 0 bytes 60 files changed, 1 insertion(+), 898 deletions(-) delete mode 100644 .MATLABDriveTag create mode 100644 .gitignore delete mode 100644 install_mpt3.m delete mode 100644 project2023.pdf delete mode 100644 templates/.MATLABDriveTag delete mode 100644 templates/LICENSE.txt delete mode 100644 templates/LQR.m delete mode 100644 templates/MPC.m delete mode 100644 templates/MPC_TE.m delete mode 100644 templates/MPC_TE_forces.m delete mode 100644 templates/MPC_TS.m delete mode 100644 templates/MPC_TS_SC.m delete mode 100644 templates/MPC_TUBE.m delete mode 100644 templates/compute_minRPI.m delete mode 100644 templates/compute_tightening.m delete mode 100644 templates/compute_tube_controller.m delete mode 100644 templates/generate_constraints.m delete mode 100644 templates/generate_disturbances.m delete mode 100644 templates/generate_params.m delete mode 100644 templates/generate_params_z.m delete mode 100644 templates/generate_system.m delete mode 100644 templates/generate_system_cont.m delete mode 100644 templates/generate_system_scaled.m delete mode 100644 templates/lqr_maxPI.m delete mode 100644 templates/lqr_tuning.m delete mode 100644 templates/plot_trajectory.m delete mode 100644 templates/plot_trajectory_z.m delete mode 100644 templates/simulate.m delete mode 100644 templates/simulate_uncertain.m delete mode 100644 templates/traj_constraints.m delete mode 100644 templates/traj_cost.m delete mode 100644 testing/.MATLABDriveTag delete mode 100644 testing/TestFunction.p delete mode 100644 testing/TestFunction_LQR.p delete mode 100644 testing/TestFunction_MPC.p delete mode 100644 testing/TestFunction_MPC_TE.p delete mode 100644 testing/TestFunction_MPC_TE_forces.p delete mode 100644 testing/TestFunction_MPC_TS.p delete mode 100644 testing/TestFunction_MPC_TS_SC.p delete mode 100644 testing/TestFunction_MPC_TS_SC_script.p delete mode 100644 testing/TestFunction_MPC_TUBE.p delete mode 100644 testing/TestFunction_MPC_TUBE_script.p delete mode 100644 testing/TestFunction_compute_minRPI.p delete mode 100644 testing/TestFunction_compute_tightening.p delete mode 100644 testing/TestFunction_compute_tube_controller.p delete mode 100644 testing/TestFunction_generate_constraints.p delete mode 100644 testing/TestFunction_generate_disturbances.p delete mode 100644 testing/TestFunction_generate_params.p delete mode 100644 testing/TestFunction_generate_system.p delete mode 100644 testing/TestFunction_generate_system_cont.p delete mode 100644 testing/TestFunction_generate_system_scaled.p delete mode 100644 testing/TestFunction_lqr_maxPI.p delete mode 100644 testing/TestFunction_lqr_tuning.p delete mode 100644 testing/TestFunction_lqr_tuning_script.p delete mode 100644 testing/TestFunction_simulate.p delete mode 100644 testing/TestFunction_simulate_uncertain.p delete mode 100644 testing/TestFunction_traj_constraints.p delete mode 100644 testing/TestFunction_traj_cost.p delete mode 100644 testing/linearController.p delete mode 100644 testing/run_tests.p diff --git a/.MATLABDriveTag b/.MATLABDriveTag deleted file mode 100644 index af1004a..0000000 --- a/.MATLABDriveTag +++ /dev/null @@ -1 +0,0 @@ -9f0ef51f-d175-4c24-a3c1-c33c3e5da8cc \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d69bff0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +./tbxmanager \ No newline at end of file diff --git a/install_mpt3.m b/install_mpt3.m deleted file mode 100644 index 97981dd..0000000 --- a/install_mpt3.m +++ /dev/null @@ -1,108 +0,0 @@ -%% installation of tbxmanager with all submodels required for MPT -% - -clc; -disp('----------------------------------------------'); -disp('Installation of MPT using the Toolbox manager.'); -disp('----------------------------------------------'); -disp(' '); -fprintf(['Choose the installation directory where to install the Toolbox manager.\n',... - 'A new folder "tbxmanager" is going to be created in the specified location.\n',... - 'If you do not specify the folder, the Toolbox manager will be installed in the current directory.\n']); - -% get the installation folder -default_dir = pwd; -c = uigetdir(pwd); -if isequal(c,0); - fprintf(['No directory has been provided.\n',... - 'Installing the toolbox manager in the current directory "%s"?\n'],default_dir); - c = default_dir; -end - -% create a new directory in that folder -d = [c,filesep,'tbxmanager']; -if isequal(exist(d,'dir'),7) - error('The installation directory "%s" already exists.\nPlease, remove or rename the folder or change the installation path.',d); -end -disp('Creating the directory "tbxmanager".'); -out = mkdir(d); -if ~out - error(['An error appear when trying to create the folder "%s".\n',... - 'Please, install the Toolbox manager manually.'],c); -end - -% enter that directory -cd(d); - -% remove MPT2 or YALMIP -disp(' '); -disp('Removing toolboxes that may conflict with MPT from the Matlab path.'); -rmpath(genpath(fileparts(which('mpt_init')))); -rmpath(genpath(fileparts(which('yalmipdemo')))); - - -% download the tbxmanager -disp(' '); -disp('Downloading the Toolbox manager from the internet.'); -[f, c] = urlwrite('http://www.tbxmanager.com/tbxmanager.m', 'tbxmanager.m'); -rehash; - -if isequal(c,0) - error('Could not download the Toolbox manager from the internet. The installation cannot continue.'); -end - -% install all required modules -tbxmanager install mpt mptdoc cddmex fourier glpkmex hysdel lcp sedumi yalmip - -% create the initialization file to set the path -disp(' '); -disp('Creating the initialization file "startup.m".'); -p = which('startup.m'); -if isempty(p) - p = [d,filesep,'startup.m']; -end -fid = fopen(p,'a'); -if isequal(fid,-1) - error(['Could not modify the initialization file "startup.m".',... - 'Edit this file in the folder "%s" manually and insert there the line: tbxmanager restorepath.'],p); -end -fprintf(fid,'tbxmanager restorepath\n'); -fclose(fid); -disp('File has been created.'); - -% get back to the original directory -cd(default_dir); - -% add path to tbxmanager -disp(' '); -disp('Adding path to Matlab.'); -addpath(d); - -% save path for future -disp(' '); -disp('Saving path for future sessions.'); -status = savepath; - -if status - fprintf('Could not save the path to a default location,\nplease provide a location where you want to save the path.'); - cn = uigetdir(pwd); - if isequal(cn,0) - disp(' '); - fprintf('No directory specified, saving the path to the current directory "%s".\n\n',default_dir); - cn = default_dir; - end - sn = savepath([cn,filesep,'pathdef.m']); - if sn - error(['Could not save the path automatically.\n',... - 'Please, open the "Set Path" button in the Matlab menu and save the path manually to some location.']); - end -end - -disp(' '); -disp('Installation finished.'); -disp('Next time you start Matlab the toolboxes will be automatically initialized.'); - -% initialize MPT -disp(' '); -disp('Initializing the MPT.') -mpt_init; diff --git a/project2023.pdf b/project2023.pdf deleted file mode 100644 index bde0b0a..0000000 Binary files a/project2023.pdf and /dev/null differ diff --git a/templates/.MATLABDriveTag b/templates/.MATLABDriveTag deleted file mode 100644 index 7aad4f3..0000000 --- a/templates/.MATLABDriveTag +++ /dev/null @@ -1 +0,0 @@ -f7c7757b-ada0-4bff-af70-1240edb65e6d \ No newline at end of file diff --git a/templates/LICENSE.txt b/templates/LICENSE.txt deleted file mode 100644 index 685f12c..0000000 --- a/templates/LICENSE.txt +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (c) 2023, Amon Lahr, Simon Muntwiler, Antoine Leeman & Fabian Flürenbrock Institute for Dynamic Systems and Control, ETH Zurich. - -All rights reserved. - -The files are provided for educational purposes only and should be distributed only to the attendees of the class "151-0660-00L Model Predictive Control FS2023". - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/templates/LQR.m b/templates/LQR.m deleted file mode 100644 index 2a79da9..0000000 --- a/templates/LQR.m +++ /dev/null @@ -1,27 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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. -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -classdef LQR - properties - K - end - - methods - %constructor - function obj = LQR(Q,R,params) - % YOUR CODE HERE - % obj.K = ... (save feedback matrix for use in eval function) - end - - function [u, ctrl_info] = eval(obj,x) - % YOUR CODE HERE - % u = ... - ctrl_info = struct('ctrl_feas',true); - end - end -end \ No newline at end of file diff --git a/templates/MPC.m b/templates/MPC.m deleted file mode 100644 index 3e9d2f1..0000000 --- a/templates/MPC.m +++ /dev/null @@ -1,45 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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. -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -classdef MPC - properties - yalmip_optimizer - end - - methods - function obj = MPC(Q,R,N,params) - nu = params.model.nu; - nx = params.model.nx; - - % define optimization variables - U = sdpvar(repmat(nu,1,N),ones(1,N),'full'); - X0 = sdpvar(nx,1,'full'); - - % YOUR CODE HERE - - opts = sdpsettings('verbose',1,'solver','quadprog'); - obj.yalmip_optimizer = optimizer(constraints,objective,opts,X0,{U{1} objective}); - end - - function [u, ctrl_info] = eval(obj,x) - %% evaluate control action by solving MPC problem, e.g. - tic; - [optimizer_out,errorcode] = obj.yalmip_optimizer(x); - solvetime = toc; - - [u, objective] = optimizer_out{:}; - - feasible = true; - if (errorcode ~= 0) - feasible = false; - end - - ctrl_info = struct('ctrl_feas',feasible,'objective',objective,'solvetime',solvetime); - end - end -end \ No newline at end of file diff --git a/templates/MPC_TE.m b/templates/MPC_TE.m deleted file mode 100644 index e0b55d2..0000000 --- a/templates/MPC_TE.m +++ /dev/null @@ -1,36 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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. -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -classdef MPC_TE - properties - yalmip_optimizer - end - - methods - function obj = MPC_TE(Q,R,N,params) - % YOUR CODE HERE - opts = sdpsettings('verbose',1,'solver','quadprog'); - obj.yalmip_optimizer = optimizer(constraints,objective,opts,X0,{U{1} objective}); - end - - function [u, ctrl_info] = eval(obj,x) - %% evaluate control action by solving MPC problem, e.g. - tic; - [optimizer_out,errorcode] = obj.yalmip_optimizer(x); - solvetime = toc; - [u, objective] = optimizer_out{:}; - - feasible = true; - if (errorcode ~= 0) - feasible = false; - end - - ctrl_info = struct('ctrl_feas',feasible,'objective',objective,'solvetime',solvetime); - end - end -end \ No newline at end of file diff --git a/templates/MPC_TE_forces.m b/templates/MPC_TE_forces.m deleted file mode 100644 index 5625f32..0000000 --- a/templates/MPC_TE_forces.m +++ /dev/null @@ -1,38 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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. -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -classdef MPC_TE_forces - properties - forces_optimizer - end - - methods - function obj = MPC_TE_forces(Q,R,N,params) - % YOUR CODE HERE - opts = getOptions('forcesSolver'); - opts.printlevel = 0; - obj.forces_optimizer = % YOUR CODE HERE - end - - function [u, ctrl_info] = eval(obj,x) - %% evaluate control action by solving MPC problem, e.g. - [optimizer_out,errorcode,info] = obj.forces_optimizer(x); - u = optimizer_out; - objective = info.pobj; - solvetime = info.solvetime; - - feasible = true; - if any(errorcode ~= 1) - feasible = false; - warning('MPC infeasible'); - end - - ctrl_info = struct('ctrl_feas',feasible,'objective',objective,'solvetime',solvetime); - end - end -end \ No newline at end of file diff --git a/templates/MPC_TS.m b/templates/MPC_TS.m deleted file mode 100644 index 05f92ff..0000000 --- a/templates/MPC_TS.m +++ /dev/null @@ -1,36 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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. -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -classdef MPC_TS - properties - yalmip_optimizer - end - - methods - function obj = MPC_TS(Q,R,N,H,h,params) - % YOUR CODE HERE - opts = sdpsettings('verbose',1,'solver','quadprog'); - obj.yalmip_optimizer = optimizer(constraints,objective,opts,X0,{U{1} objective}); - end - - function [u, ctrl_info] = eval(obj,x) - %% evaluate control action by solving MPC problem, e.g. - tic; - [optimizer_out,errorcode] = obj.yalmip_optimizer(x); - solvetime = toc; - [u, objective] = optimizer_out{:}; - - feasible = true; - if (errorcode ~= 0) - feasible = false; - end - - ctrl_info = struct('ctrl_feas',feasible,'objective',objective,'solvetime',solvetime); - end - end -end \ No newline at end of file diff --git a/templates/MPC_TS_SC.m b/templates/MPC_TS_SC.m deleted file mode 100644 index 0e64767..0000000 --- a/templates/MPC_TS_SC.m +++ /dev/null @@ -1,36 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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. -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -classdef MPC_TS_SC - properties - yalmip_optimizer - end - - methods - function obj = MPC_TS_SC(Q,R,N,H,h,S,v,params) - % YOUR CODE HERE - opts = sdpsettings('verbose',1,'solver','quadprog','quadprog.TolFun',1e-8); - obj.yalmip_optimizer = optimizer(constraints,objective,opts,X0,{U{1} objective}); - end - - function [u, ctrl_info] = eval(obj,x) - %% evaluate control action by solving MPC problem, e.g. - tic; - [optimizer_out,errorcode] = obj.yalmip_optimizer(x); - solvetime = toc; - [u, objective] = optimizer_out{:}; - - feasible = true; - if (errorcode ~= 0) - feasible = false; - end - - ctrl_info = struct('ctrl_feas',feasible,'objective',objective,'solvetime',solvetime); - end - end -end \ No newline at end of file diff --git a/templates/MPC_TUBE.m b/templates/MPC_TUBE.m deleted file mode 100644 index bd62044..0000000 --- a/templates/MPC_TUBE.m +++ /dev/null @@ -1,40 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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. -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -classdef MPC_TUBE - properties - yalmip_optimizer - K_tube - end - - methods - function obj = MPC_TUBE(Q,R,N,H_N,h_N,H_tube,h_tube,K_tube,params) - obj.K_tube = K_tube; - - % YOUR CODE HERE - - opts = sdpsettings('verbose',1,'solver','quadprog'); - obj.yalmip_optimizer = optimizer(constraints,objective,opts,X0,{V{1} Z{1} objective}); - end - - function [u, ctrl_info] = eval(obj,x) - %% evaluate control action by solving MPC problem, e.g. - tic; - [optimizer_out,errorcode] = obj.yalmip_optimizer(x); - solvetime = toc; - % YOUR CODE HERE - - feasible = true; - if (errorcode ~= 0) - feasible = false; - end - - ctrl_info = struct('ctrl_feas',feasible,'objective',objective,'solvetime',solvetime); - end - end -end \ No newline at end of file diff --git a/templates/compute_minRPI.m b/templates/compute_minRPI.m deleted file mode 100644 index 0b4ffdb..0000000 --- a/templates/compute_minRPI.m +++ /dev/null @@ -1,11 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 [H_tube,h_tube,n_iter] = compute_minRPI(K_tube,params) - % YOUR CODE HERE -end \ No newline at end of file diff --git a/templates/compute_tightening.m b/templates/compute_tightening.m deleted file mode 100644 index 8919d12..0000000 --- a/templates/compute_tightening.m +++ /dev/null @@ -1,11 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 params = compute_tightening(K_tube,H_tube,h_tube,params) - % YOUR CODE HERE -end \ No newline at end of file diff --git a/templates/compute_tube_controller.m b/templates/compute_tube_controller.m deleted file mode 100644 index adca95d..0000000 --- a/templates/compute_tube_controller.m +++ /dev/null @@ -1,11 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 K_tube = compute_tube_controller(p,params) - % YOUR CODE HERE -end \ No newline at end of file diff --git a/templates/generate_constraints.m b/templates/generate_constraints.m deleted file mode 100644 index f87ac26..0000000 --- a/templates/generate_constraints.m +++ /dev/null @@ -1,19 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 [H_u, h_u, H_x, h_x] = generate_constraints(params) - % YOUR CODE HERE - u_max = params.constraints.MaxAbsThrust; - h_u = u_max * ones(6,1); - H_u = [eye(3);-eye(3)]; - - s_max = params.constraints.MaxAbsPositionXZ; - y_max = params.constraints.MaxAbsPositionY; - h_x = [s_max;y_max;s_max;s_max;y_max;s_max]; - H_x = [eye(3);-eye(3)]; -end \ No newline at end of file diff --git a/templates/generate_disturbances.m b/templates/generate_disturbances.m deleted file mode 100644 index 570a4c9..0000000 --- a/templates/generate_disturbances.m +++ /dev/null @@ -1,11 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 Wt = generate_disturbances(params) - % YOUR CODE HERE -end \ No newline at end of file diff --git a/templates/generate_params.m b/templates/generate_params.m deleted file mode 100644 index e2e6024..0000000 --- a/templates/generate_params.m +++ /dev/null @@ -1,73 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 [params] = generate_params() -params = struct(); - -Tf = 60*60*24 * 2; % = 2 days -dt = 60 * 10; % = 10 minutes - -% model -params.model = struct(... - 'nx', 6, ... - 'nu', 3, ... - 'Mass', 300, ... - 'GravitationalParameter', 3.986e14, ... - 'ScalingMatrix', [1e-6*eye(3), zeros(3); zeros(3), 1e-3*eye(3)], ... - 'TargetRadius', 7000e3, ... - 'TimeStep', dt, ... - 'HorizonLength', ceil(Tf / dt), ... - 'InitialConditionA', [-15e-3; -400e-3; 24.4e-3; 0; 0.0081; 0], ... - 'InitialConditionB', [-20e-3; 400e-3; 24.4e-3; 0; 0.0108; 0], ... - 'InitialConditionC', [0.02; 0.01; -0.005; 0; 0; 0] ... -); - -% constraints -params.constraints = struct(... - 'MaxAbsPositionXZ', 0.1, ... - 'MaxAbsPositionY', 1, ... - 'MaxAbsThrust', 1, ... - 'MaxFinalPosDiff' , 3e-4, ... - 'MaxFinalVelDiff', 1e-3 ... -); - -params.exercise = struct( ... - 'QdiagOptA', [94.0; 0.1579; 300; 0.01; 0.10; 0.10] ... -); - -% YOUR CODE HERE -[Ac, Bc] = generate_system_cont(params); -[A_tilta, B_tilta] = generate_system(Ac, Bc, params); -[A, B] = generate_system_scaled(A_tilta, B_tilta, params); -[Hu, hu, Hx, hx] = generate_constraints(params); - -params.model.A = A; -params.model.B = B; - -params.constraints.InputMatrix = Hu; -params.constraints.InputRHS = hu; -params.constraints.StateMatrix = Hx; -params.constraints.StateRHS = hx; - -% new_model_struct = struct(... -% 'A', A, ... -% 'B', B ... -% ); - -% new_constr_struct = struct(... -% 'InputMatrix', Hu,... -% 'InputRHS', hu,... -% 'StateMatrix', Hx,... -% 'StateRHS', hx ... -% ) - - -% params.model = [params.model new_model_struct]; -% params.constraints = [params.constraints, new_constr_struct]; - -end diff --git a/templates/generate_params_z.m b/templates/generate_params_z.m deleted file mode 100644 index a7cfaa9..0000000 --- a/templates/generate_params_z.m +++ /dev/null @@ -1,55 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 [params_z] = generate_params_z(params) -% initialize params_z -params_z = params; - -% add initial condition of z-subsystem -params_z.model = rmfield(params_z.model,{'InitialConditionA', ... - 'InitialConditionB', ... - 'InitialConditionC'}); -params_z.model.InitialConditionA_z = [-0.07;0.04]; % TODO: tune - -% define projection matrices -T_z_x = [0 0 1 0 0 0; - 0 0 0 0 0 1]; -T_z_u = [0 0 1]; - -% projected system dynamics -params_z.model.A = T_z_x*params.model.A*T_z_x'; -params_z.model.B = T_z_x*params.model.B*T_z_u'; -params_z.model.nx = 2; -params_z.model.nu = 1; - -% state constraints -Hx = params.constraints.StateMatrix * T_z_x'; -hx = params.constraints.StateRHS; -X = Polyhedron('A',Hx,'b',hx); -X.minHRep(); - -params_z.constraints.StateMatrix = X.A; -params_z.constraints.StateRHS = X.b; - -% input constraints -Hu = params.constraints.InputMatrix * T_z_u'; -hu = params.constraints.InputRHS; -U = Polyhedron('A',Hu,'b',hu); - -params_z.constraints.InputMatrix = U.A; -params_z.constraints.InputRHS = U.b; - -% disturbance constraints -max_disturbance = 1e-4; % TODO: chose -params_z.constraints.MaxAbsDisturbance = max_disturbance; -H_w = kron(eye(params_z.model.nx),[1;-1]); -h_w = ones(2*params_z.model.nx, 1) * max_disturbance; - -params_z.constraints.DisturbanceMatrix = H_w; -params_z.constraints.DisturbanceRHS = h_w; -end diff --git a/templates/generate_system.m b/templates/generate_system.m deleted file mode 100644 index c4dadc2..0000000 --- a/templates/generate_system.m +++ /dev/null @@ -1,19 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 [A, B] = generate_system(Ac, Bc, params) - % YOUR CODE HERE - % Ts = 600; - sysc = ss(Ac, Bc, [], []); - Ts = params.model.TimeStep; - sysd = c2d(sysc,Ts); - % A = eye(params.model.nx) + Ac * Ts; - % B = Bc * Ts; - A = sysd.A; - B = sysd.B; -end \ No newline at end of file diff --git a/templates/generate_system_cont.m b/templates/generate_system_cont.m deleted file mode 100644 index 770fd8e..0000000 --- a/templates/generate_system_cont.m +++ /dev/null @@ -1,22 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 [Ac, Bc] = generate_system_cont(params) - % YOUR CODE HERE - miu = params.model.GravitationalParameter; - r = params.model.TargetRadius; - omega_n = sqrt(miu/(r^3)); - m = params.model.Mass; - Ac = [0,0,0,1,0,0; - 0,0,0,0,1,0; - 0,0,0,0,0,1; - 3*omega_n^2,0,0,0,2*omega_n,0; - 0,0,0,-2*omega_n,0,0; - 0,0,-omega_n^2,0,0,0]; - Bc = [zeros(3,3);1/m*eye(3)]; -end \ No newline at end of file diff --git a/templates/generate_system_scaled.m b/templates/generate_system_scaled.m deleted file mode 100644 index 38714d2..0000000 --- a/templates/generate_system_scaled.m +++ /dev/null @@ -1,15 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 [A,B] = generate_system_scaled(At,Bt,params) - % YOUR CODE HERE - % V = diag([1e-6, 1e-6, 1e-6, 1e-3, 1e-3, 1e-3]); - V = params.model.ScalingMatrix; - A = V*At*inv(V); - B = V*Bt; -end \ No newline at end of file diff --git a/templates/lqr_maxPI.m b/templates/lqr_maxPI.m deleted file mode 100644 index efa335a..0000000 --- a/templates/lqr_maxPI.m +++ /dev/null @@ -1,12 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 [H, h] = lqr_maxPI(Q,R,params) - % YOUR CODE HERE -end - diff --git a/templates/lqr_tuning.m b/templates/lqr_tuning.m deleted file mode 100644 index 4a26158..0000000 --- a/templates/lqr_tuning.m +++ /dev/null @@ -1,11 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 [tuning_struct, i_opt] = lqr_tuning(x0,Q,params) - % YOUR CODE HERE -end \ No newline at end of file diff --git a/templates/plot_trajectory.m b/templates/plot_trajectory.m deleted file mode 100644 index 9bcb696..0000000 --- a/templates/plot_trajectory.m +++ /dev/null @@ -1,126 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 [fig_time,axes_time,fig_pos,axes_pos] = plot_trajectory(x,u,ctrl_info,params) - fig_time = figure; - - % check if input is 3-dimensional - n_traj = size(x,3); - assert(size(u,3) == n_traj); - assert(size(ctrl_info,3) == n_traj); - - nx = params.model.nx; - assert(nx == size(x,1)); - - t = 0:params.model.TimeStep:params.model.TimeStep*params.model.HorizonLength; - - % plot - axes_time = cell(5,1); - axes_time{1} = subplot(5,1,1); - hold on; - - for i = 1:n_traj - plot(axes_time{1},t,x(1,:,i),'DisplayName',sprintf('x_%d',i)); - plot(axes_time{1},t,x(3,:,i),'DisplayName',sprintf('z_%d',i)); - end - legend('Location','EastOutside') - - % max position - x_max = params.constraints.MaxAbsPositionXZ; - plot(axes_time{1}, [t(1); t(end)],[x_max; x_max],'k--','HandleVisibility','off'); - plot(axes_time{1}, [t(1); t(end)],[-x_max; -x_max],'k--','HandleVisibility','off'); - ylabel('Position [Mm]') - - axes_time{2} = subplot(5,1,2); - hold on; - for i = 1:n_traj - plot(axes_time{2},t,x(2,:,i),'DisplayName',sprintf('y_%d',i)); - end - - % max position - y_max = params.constraints.MaxAbsPositionY; - plot(axes_time{2},[t(1); t(end)],[y_max; y_max],'k--','HandleVisibility','off'); - plot(axes_time{2},[t(1); t(end)],[-y_max; -y_max],'k--','HandleVisibility','off'); - - legend('Location','EastOutside') - ylabel('Position [Mm]') - - axes_time{3} = subplot(5,1,3); - hold on; - for i = 1:n_traj - plot(axes_time{3},t,x(4,:,i),'DisplayName',sprintf('v_{x%d}',i)); - plot(axes_time{3},t,x(5,:,i),'DisplayName',sprintf('v_{y%d}',i)); - plot(axes_time{3},t,x(6,:,i),'DisplayName',sprintf('v_{z%d}',i)); - end - - legend('Location','EastOutside') - ylabel('Velocity [km/s]') - - axes_time{4} = subplot(5,1,4); - hold on; - % append one input value for plotting - u(:,length(t),:) = u(:,length(t)-1,:); - for i = 1:n_traj - stairs(axes_time{4},t,u(1,:,i)','DisplayName',sprintf('u_{x%d}',i)); - stairs(axes_time{4},t,u(2,:,i)','DisplayName',sprintf('u_{y%d}',i)); - stairs(axes_time{4},t,u(3,:,i)','DisplayName',sprintf('u_{z%d}',i)); - end - - % max thrust - thrust_max = params.constraints.MaxAbsThrust; - plot([t(1); t(end)],[thrust_max; thrust_max],'k--','HandleVisibility','off'); - plot([t(1); t(end)],[-thrust_max; -thrust_max],'k--','HandleVisibility','off'); - legend('Location','EastOutside') - ylabel('Thrust [N]') - - % feasibility - axes_time{5} = subplot(5,1,5); - hold on; - for i = 1:n_traj - % append one input value for plotting - ctrl_feas = [ctrl_info(:,:,i).ctrl_feas]; - ctrl_feas(length(t)) = ctrl_feas(length(t) - 1); - stairs(axes_time{5},t,ctrl_feas','DisplayName',sprintf('feas_%d',i)); - end - legend('Location','EastOutside') - ylabel('Controller feasible [0/1]') - - % link axes - axes_time = [axes_time{:}]; - linkaxes(axes_time,'x'); - xlabel('Time [s]') - - % plot without time - % YX-plane - fig_pos = figure; - axes_pos = cell(2,1); - axes_pos{1} = subplot(2,1,1); - hold on - colormap('hsv') - - for i = 1:n_traj - plot(axes_pos{1},x(2,:,i),x(1,:,i)); - end - - axis equal - xlabel('Y-Position [m]') - ylabel('X-Position [Mm]') - - % YZ plane - axes_pos{2} = subplot(2,1,2); - hold on - for i = 1:n_traj - plot(axes_pos{2},x(2,:,i),x(3,:,i)) - end - axis equal - xlabel('Y-Position [Mm]') - ylabel('Z-Position [Mm]') - - axes_pos = [axes_pos{:}]; - linkaxes(axes_pos,'x'); -end \ No newline at end of file diff --git a/templates/plot_trajectory_z.m b/templates/plot_trajectory_z.m deleted file mode 100644 index 1b5a842..0000000 --- a/templates/plot_trajectory_z.m +++ /dev/null @@ -1,78 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 [fig_time,axes_time,fig_pos,axes_pos] = plot_trajectory_z(x,u,ctrl_info,params) - fig_time = figure; - - % check if input is 3-dimensional - n_traj = size(x,3); - assert(size(u,3) == n_traj); - assert(size(ctrl_info,3) == n_traj); - - nx = params.model.nx; - assert(nx == size(x,1)); - - t = 0:params.model.TimeStep:params.model.TimeStep*params.model.HorizonLength; - - % plot - axes_time = cell(4,1); - axes_time{1} = subplot(4,1,1); - hold on; - - for i = 1:n_traj - plot(axes_time{1},t,x(1,:,i),'DisplayName',sprintf('z_%d',i)); - end - legend('Location','EastOutside') - - % max position - x_max = params.constraints.MaxAbsPositionXZ; %*T(1); - plot(axes_time{1}, [t(1); t(end)],[x_max; x_max],'k--','HandleVisibility','off'); - plot(axes_time{1}, [t(1); t(end)],[-x_max; -x_max],'k--','HandleVisibility','off'); - ylabel('Position [Mm]') - - axes_time{2} = subplot(4,1,2); - hold on; - for i = 1:n_traj - plot(axes_time{2},t,x(2,:,i),'DisplayName',sprintf('v_{z%d}',i)); - end - legend('Location','EastOutside') - ylabel('Velocity [km/s]') - - axes_time{3} = subplot(4,1,3); - hold on; - % append one input value for plotting - u(:,length(t),:) = u(:,length(t)-1,:); - for i = 1:n_traj - stairs(axes_time{3},t,u(1,:,i)','DisplayName',sprintf('u_{z%d}',i)); - end - - % max thrust - thrust_max = params.constraints.MaxAbsThrust; - plot([t(1); t(end)],[thrust_max; thrust_max],'k--','HandleVisibility','off'); - plot([t(1); t(end)],[-thrust_max; -thrust_max],'k--','HandleVisibility','off'); - legend('Location','EastOutside') - ylabel('Thrust [N]') - - % feasibility - axes_time{4} = subplot(4,1,4); - hold on; - for i = 1:n_traj - % append one input value for plotting - ctrl_feas = [ctrl_info(:,:,i).ctrl_feas]; - ctrl_feas(length(t)) = ctrl_feas(length(t) - 1); - stairs(axes_time{4},t,ctrl_feas','DisplayName',sprintf('feas_%d',i)); - end - legend('Location','EastOutside') - ylabel('Feasible [0/1]') - - % link axes - axes_time = [axes_time{:}]; - linkaxes(axes_time,'x') - xlabel('Time [s]') -end \ No newline at end of file diff --git a/templates/simulate.m b/templates/simulate.m deleted file mode 100644 index 3138cd1..0000000 --- a/templates/simulate.m +++ /dev/null @@ -1,14 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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(x0, ctrl, params) - -% YOUR CODE HERE -% Hint: you can access the control command with ctrl.eval(x(:,i)) - -end \ No newline at end of file diff --git a/templates/simulate_uncertain.m b/templates/simulate_uncertain.m deleted file mode 100644 index dc9df26..0000000 --- a/templates/simulate_uncertain.m +++ /dev/null @@ -1,11 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 -end \ No newline at end of file diff --git a/templates/traj_constraints.m b/templates/traj_constraints.m deleted file mode 100644 index 4b0a081..0000000 --- a/templates/traj_constraints.m +++ /dev/null @@ -1,12 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 [s_max, y_max, u_max, J_u, df_max, vf_max, traj_feas] = traj_constraints(x,u,params) - % YOUR CODE HERE -end - diff --git a/templates/traj_cost.m b/templates/traj_cost.m deleted file mode 100644 index 7e0b443..0000000 --- a/templates/traj_cost.m +++ /dev/null @@ -1,11 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 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 J_Nt = traj_cost(Xt,Ut,Q,R) - % YOUR CODE HERE -end \ No newline at end of file diff --git a/testing/.MATLABDriveTag b/testing/.MATLABDriveTag deleted file mode 100644 index 91a4f10..0000000 --- a/testing/.MATLABDriveTag +++ /dev/null @@ -1 +0,0 @@ -da537f63-b054-4058-9b41-6907e21d5531 \ No newline at end of file diff --git a/testing/TestFunction.p b/testing/TestFunction.p deleted file mode 100644 index 7bb108c..0000000 Binary files a/testing/TestFunction.p and /dev/null differ diff --git a/testing/TestFunction_LQR.p b/testing/TestFunction_LQR.p deleted file mode 100644 index 955ba03..0000000 Binary files a/testing/TestFunction_LQR.p and /dev/null differ diff --git a/testing/TestFunction_MPC.p b/testing/TestFunction_MPC.p deleted file mode 100644 index b802e23..0000000 Binary files a/testing/TestFunction_MPC.p and /dev/null differ diff --git a/testing/TestFunction_MPC_TE.p b/testing/TestFunction_MPC_TE.p deleted file mode 100644 index d035c80..0000000 Binary files a/testing/TestFunction_MPC_TE.p and /dev/null differ diff --git a/testing/TestFunction_MPC_TE_forces.p b/testing/TestFunction_MPC_TE_forces.p deleted file mode 100644 index 81ff7ba..0000000 Binary files a/testing/TestFunction_MPC_TE_forces.p and /dev/null differ diff --git a/testing/TestFunction_MPC_TS.p b/testing/TestFunction_MPC_TS.p deleted file mode 100644 index 23c4836..0000000 Binary files a/testing/TestFunction_MPC_TS.p and /dev/null differ diff --git a/testing/TestFunction_MPC_TS_SC.p b/testing/TestFunction_MPC_TS_SC.p deleted file mode 100644 index faef7e4..0000000 Binary files a/testing/TestFunction_MPC_TS_SC.p and /dev/null differ diff --git a/testing/TestFunction_MPC_TS_SC_script.p b/testing/TestFunction_MPC_TS_SC_script.p deleted file mode 100644 index e13715e..0000000 Binary files a/testing/TestFunction_MPC_TS_SC_script.p and /dev/null differ diff --git a/testing/TestFunction_MPC_TUBE.p b/testing/TestFunction_MPC_TUBE.p deleted file mode 100644 index 4bac841..0000000 Binary files a/testing/TestFunction_MPC_TUBE.p and /dev/null differ diff --git a/testing/TestFunction_MPC_TUBE_script.p b/testing/TestFunction_MPC_TUBE_script.p deleted file mode 100644 index 9946b16..0000000 Binary files a/testing/TestFunction_MPC_TUBE_script.p and /dev/null differ diff --git a/testing/TestFunction_compute_minRPI.p b/testing/TestFunction_compute_minRPI.p deleted file mode 100644 index 9390f12..0000000 Binary files a/testing/TestFunction_compute_minRPI.p and /dev/null differ diff --git a/testing/TestFunction_compute_tightening.p b/testing/TestFunction_compute_tightening.p deleted file mode 100644 index d2e60ea..0000000 Binary files a/testing/TestFunction_compute_tightening.p and /dev/null differ diff --git a/testing/TestFunction_compute_tube_controller.p b/testing/TestFunction_compute_tube_controller.p deleted file mode 100644 index 764bd90..0000000 Binary files a/testing/TestFunction_compute_tube_controller.p and /dev/null differ diff --git a/testing/TestFunction_generate_constraints.p b/testing/TestFunction_generate_constraints.p deleted file mode 100644 index 6bff694..0000000 Binary files a/testing/TestFunction_generate_constraints.p and /dev/null differ diff --git a/testing/TestFunction_generate_disturbances.p b/testing/TestFunction_generate_disturbances.p deleted file mode 100644 index 9dc80b6..0000000 Binary files a/testing/TestFunction_generate_disturbances.p and /dev/null differ diff --git a/testing/TestFunction_generate_params.p b/testing/TestFunction_generate_params.p deleted file mode 100644 index 1ab5f90..0000000 Binary files a/testing/TestFunction_generate_params.p and /dev/null differ diff --git a/testing/TestFunction_generate_system.p b/testing/TestFunction_generate_system.p deleted file mode 100644 index 74e80ac..0000000 Binary files a/testing/TestFunction_generate_system.p and /dev/null differ diff --git a/testing/TestFunction_generate_system_cont.p b/testing/TestFunction_generate_system_cont.p deleted file mode 100644 index 8c48d90..0000000 Binary files a/testing/TestFunction_generate_system_cont.p and /dev/null differ diff --git a/testing/TestFunction_generate_system_scaled.p b/testing/TestFunction_generate_system_scaled.p deleted file mode 100644 index 4176219..0000000 Binary files a/testing/TestFunction_generate_system_scaled.p and /dev/null differ diff --git a/testing/TestFunction_lqr_maxPI.p b/testing/TestFunction_lqr_maxPI.p deleted file mode 100644 index a2fc282..0000000 Binary files a/testing/TestFunction_lqr_maxPI.p and /dev/null differ diff --git a/testing/TestFunction_lqr_tuning.p b/testing/TestFunction_lqr_tuning.p deleted file mode 100644 index c97d218..0000000 Binary files a/testing/TestFunction_lqr_tuning.p and /dev/null differ diff --git a/testing/TestFunction_lqr_tuning_script.p b/testing/TestFunction_lqr_tuning_script.p deleted file mode 100644 index 09f6896..0000000 Binary files a/testing/TestFunction_lqr_tuning_script.p and /dev/null differ diff --git a/testing/TestFunction_simulate.p b/testing/TestFunction_simulate.p deleted file mode 100644 index 6751e46..0000000 Binary files a/testing/TestFunction_simulate.p and /dev/null differ diff --git a/testing/TestFunction_simulate_uncertain.p b/testing/TestFunction_simulate_uncertain.p deleted file mode 100644 index 9ec7139..0000000 Binary files a/testing/TestFunction_simulate_uncertain.p and /dev/null differ diff --git a/testing/TestFunction_traj_constraints.p b/testing/TestFunction_traj_constraints.p deleted file mode 100644 index 5805983..0000000 Binary files a/testing/TestFunction_traj_constraints.p and /dev/null differ diff --git a/testing/TestFunction_traj_cost.p b/testing/TestFunction_traj_cost.p deleted file mode 100644 index d05dae0..0000000 Binary files a/testing/TestFunction_traj_cost.p and /dev/null differ diff --git a/testing/linearController.p b/testing/linearController.p deleted file mode 100644 index ede2acc..0000000 Binary files a/testing/linearController.p and /dev/null differ diff --git a/testing/run_tests.p b/testing/run_tests.p deleted file mode 100644 index d233f5a..0000000 Binary files a/testing/run_tests.p and /dev/null differ -- cgit v1.2.1