Update all the functions

This commit is contained in:
Thomas Dehaeze 2019-12-06 12:03:34 +01:00
parent 7032f05ef5
commit f73becd5c9
27 changed files with 111 additions and 184 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,12 +1,12 @@
% computePsdDispl % computePsdDispl
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle src/computePsdDispl.m % :header-args:matlab+: :tangle ../src/computePsdDispl.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:computePsdDispl>> % <<sec:computePsdDispl>>
% This Matlab function is accessible [[file:src/computePsdDispl.m][here]]. % This Matlab function is accessible [[file:../src/computePsdDispl.m][here]].
function [psd_object] = computePsdDispl(sys_data, t_init, n_av) function [psd_object] = computePsdDispl(sys_data, t_init, n_av)

View File

@ -1,12 +1,12 @@
% computeSetpoint % computeSetpoint
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle src/computeSetpoint.m % :header-args:matlab+: :tangle ../src/computeSetpoint.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:computeSetpoint>> % <<sec:computeSetpoint>>
% This Matlab function is accessible [[file:src/computeSetpoint.m][here]]. % This Matlab function is accessible [[file:../src/computeSetpoint.m][here]].
function setpoint = computeSetpoint(ty, ry, rz) function setpoint = computeSetpoint(ty, ry, rz)

View File

@ -1,12 +1,12 @@
% converErrorBasis % converErrorBasis
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle src/converErrorBasis.m % :header-args:matlab+: :tangle ../src/converErrorBasis.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:converErrorBasis>> % <<sec:converErrorBasis>>
% This Matlab function is accessible [[file:src/converErrorBasis.m][here]]. % This Matlab function is accessible [[file:../src/converErrorBasis.m][here]].
function error_nass = convertErrorBasis(pos, setpoint, ty, ry, rz) function error_nass = convertErrorBasis(pos, setpoint, ty, ry, rz)

View File

@ -1,12 +1,12 @@
% generateDiagPidControl % generateDiagPidControl
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle src/generateDiagPidControl.m % :header-args:matlab+: :tangle ../src/generateDiagPidControl.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:generateDiagPidControl>> % <<sec:generateDiagPidControl>>
% This Matlab function is accessible [[file:src/generateDiagPidControl.m][here]]. % This Matlab function is accessible [[file:../src/generateDiagPidControl.m][here]].
function [K] = generateDiagPidControl(G, fs) function [K] = generateDiagPidControl(G, fs)

View File

@ -1,19 +0,0 @@
% Simulation Initialization
% :PROPERTIES:
% :header-args:matlab+: :tangle ../src/init_simulation.m
% :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none
% :END:
% <<sec:init_simulation>>
% This Matlab script is accessible [[file:../src/init_simulation.m][here]].
% This script runs just before the simulation is started.
% It is used to load the simulation configuration and the controllers used for the simulation.
%% Load all the data used for the simulation
load('sim_conf.mat');
%% Load Controller
load('controllers.mat');

View File

@ -1,10 +1,10 @@
% Center of gravity compensation % Center of gravity compensation
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeAxisc.m % :header-args:matlab+: :tangle ../src/initializeAxisc.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:initializeAxisc>> % <<sec:initializeAxisc>>
% This Matlab function is accessible [[file:../src/initializeAxisc.m][here]]. % This Matlab function is accessible [[file:../src/initializeAxisc.m][here]].

View File

@ -1,10 +1,10 @@
% Cedrat Actuator % Cedrat Actuator
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeCedratPiezo.m % :header-args:matlab+: :tangle ../src/initializeCedratPiezo.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:initializeCedratPiezo>> % <<sec:initializeCedratPiezo>>
% This Matlab function is accessible [[file:../src/initializeCedratPiezo.m][here]]. % This Matlab function is accessible [[file:../src/initializeCedratPiezo.m][here]].
@ -25,8 +25,8 @@ function [cedrat] = initializeCedratPiezo(opts_param)
cedrat.k = 10e7; % Linear Stiffness of each "blade" [N/m] cedrat.k = 10e7; % Linear Stiffness of each "blade" [N/m]
cedrat.ka = 10e7; % Linear Stiffness of the stack [N/m] cedrat.ka = 10e7; % Linear Stiffness of the stack [N/m]
cedrat.c = 0.1*sqrt(50*cedrat.k); % [N/(m/s)] cedrat.c = 0.1*sqrt(1*cedrat.k); % [N/(m/s)]
cedrat.ca = 0.1*sqrt(50*cedrat.ka); % [N/(m/s)] cedrat.ca = 0.1*sqrt(1*cedrat.ka); % [N/(m/s)]
cedrat.L = 80; % Total Width of the Actuator[mm] cedrat.L = 80; % Total Width of the Actuator[mm]
cedrat.H = 45; % Total Height of the Actuator [mm] cedrat.H = 45; % Total Height of the Actuator [mm]

View File

@ -1,22 +1,16 @@
% Experiment % Experiment
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeExperiment.m % :header-args:matlab+: :tangle ../src/initializeExperiment.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:initializeExperiment>> % <<sec:initializeExperiment>>
% This Matlab function is accessible [[file:../src/initializeExperiment.m][here]]. % This Matlab function is accessible [[file:../src/initializeExperiment.m][here]].
function [] = initializeExperiment(exp_name, sys_mass) function [] = initializeExperiment(exp_name, sys_mass)
if strcmp(exp_name, 'tomography') if strcmp(exp_name, 'tomography')
opts_sim = struct(...
'Tsim', 5, ...
'cl_time', 5 ...
);
initializeSimConf(opts_sim);
if strcmp(sys_mass, 'light') if strcmp(sys_mass, 'light')
opts_inputs = struct(... opts_inputs = struct(...
'Dw', true, ... 'Dw', true, ...

View File

@ -1,10 +1,10 @@
% Granite % Granite
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeGranite.m % :header-args:matlab+: :tangle ../src/initializeGranite.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:initializeGranite>> % <<sec:initializeGranite>>
% This Matlab function is accessible [[file:../src/initializeGranite.m][here]]. % This Matlab function is accessible [[file:../src/initializeGranite.m][here]].

View File

@ -1,10 +1,10 @@
% Ground % Ground
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeGround.m % :header-args:matlab+: :tangle ../src/initializeGround.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:initializeGround>> % <<sec:initializeGround>>
% This Matlab function is accessible [[file:../src/initializeGround.m][here]]. % This Matlab function is accessible [[file:../src/initializeGround.m][here]].

View File

@ -1,10 +1,12 @@
% Inputs % TODO Inputs
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeInputs.m % :header-args:matlab+: :tangle ../src/initializeInputs.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:initializeInputs>> % <<sec:initializeInputs>>
% - [ ] *This function should not be used anymore*. Now there are two functions to initialize disturbances and references.
% This Matlab function is accessible [[file:../src/initializeInputs.m][here]]. % This Matlab function is accessible [[file:../src/initializeInputs.m][here]].

View File

@ -1,10 +1,10 @@
% Micro Hexapod % Micro Hexapod
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeMicroHexapod.m % :header-args:matlab+: :tangle ../src/initializeMicroHexapod.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:initializeMicroHexapod>> % <<sec:initializeMicroHexapod>>
% This Matlab function is accessible [[file:../src/initializeMicroHexapod.m][here]]. % This Matlab function is accessible [[file:../src/initializeMicroHexapod.m][here]].

View File

@ -1,10 +1,10 @@
% Mirror % Mirror
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeMirror.m % :header-args:matlab+: :tangle ../src/initializeMirror.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:initializeMirror>> % <<sec:initializeMirror>>
% This Matlab function is accessible [[file:../src/initializeMirror.m][here]]. % This Matlab function is accessible [[file:../src/initializeMirror.m][here]].

View File

@ -1,10 +1,10 @@
% Nano Hexapod % Nano Hexapod
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeNanoHexapod.m % :header-args:matlab+: :tangle ../src/initializeNanoHexapod.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:initializeNanoHexapod>> % <<sec:initializeNanoHexapod>>
% This Matlab function is accessible [[file:../src/initializeNanoHexapod.m][here]]. % This Matlab function is accessible [[file:../src/initializeNanoHexapod.m][here]].

View File

@ -1,10 +1,10 @@
% Tilt Stage % Tilt Stage
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeRy.m % :header-args:matlab+: :tangle ../src/initializeRy.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:initializeRy>> % <<sec:initializeRy>>
% This Matlab function is accessible [[file:../src/initializeRy.m][here]]. % This Matlab function is accessible [[file:../src/initializeRy.m][here]].

View File

@ -1,10 +1,10 @@
% Spindle % Spindle
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeRz.m % :header-args:matlab+: :tangle ../src/initializeRz.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:initializeRz>> % <<sec:initializeRz>>
% This Matlab function is accessible [[file:../src/initializeRz.m][here]]. % This Matlab function is accessible [[file:../src/initializeRz.m][here]].

View File

@ -1,10 +1,10 @@
% Sample % Sample
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeSample.m % :header-args:matlab+: :tangle ../src/initializeSample.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:initializeSample>> % <<sec:initializeSample>>
% This Matlab function is accessible [[file:../src/initializeSample.m][here]]. % This Matlab function is accessible [[file:../src/initializeSample.m][here]].

View File

@ -1,44 +0,0 @@
% Simulation Configuration
% :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeSimConf.m
% :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none
% :END:
% <<sec:initializeSimConf>>
% This Matlab function is accessible [[file:../src/initializeSimConf.m][here]].
function [] = initializeSimConf(opts_param)
%% Default values for opts
opts = struct('Ts', 1e-4, ... % Sampling time [s]
'Tsim', 10, ... % Simulation time [s]
'cl_time', 0, ... % Close Loop time [s]
'gravity', false ... % Gravity along the z axis
);
%% Populate opts with input parameters
if exist('opts_param','var')
for opt = fieldnames(opts_param)'
opts.(opt{1}) = opts_param.(opt{1});
end
end
%%
sim_conf = struct();
%%
sim_conf.Ts = opts.Ts;
sim_conf.Tsim = opts.Tsim;
sim_conf.cl_time = opts.cl_time;
%% Gravity
if opts.gravity
sim_conf.g = -9.8; %#ok
else
sim_conf.g = 0; %#ok
end
%% Save
save('./mat/sim_conf.mat', 'sim_conf');
end

View File

@ -1,10 +1,10 @@
% Translation Stage % Translation Stage
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeTy.m % :header-args:matlab+: :tangle ../src/initializeTy.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:initializeTy>> % <<sec:initializeTy>>
% This Matlab function is accessible [[file:../src/initializeTy.m][here]]. % This Matlab function is accessible [[file:../src/initializeTy.m][here]].

View File

@ -3,12 +3,6 @@
% When the project opens, a startup script is ran. % When the project opens, a startup script is ran.
% The startup script is defined below and is exported to the =project_startup.m= script. % The startup script is defined below and is exported to the =project_startup.m= script.
%%
freqs = logspace(-1, 3, 1000);
save_fig = false;
save('./mat/config.mat', 'freqs', 'save_fig');
%%
project = simulinkproject; project = simulinkproject;
projectRoot = project.RootFolder; projectRoot = project.RootFolder;

View File

@ -1,56 +1,56 @@
% runSimulation % runSimulation
% :PROPERTIES: % :PROPERTIES:
% :header-args:matlab+: :tangle src/runSimulation.m % :header-args:matlab+: :tangle ../src/runSimulation.m
% :header-args:matlab+: :comments org :mkdirp yes % :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none % :header-args:matlab+: :eval no :results none
% :END: % :END:
% <<sec:runSimulation>> % <<sec:runSimulation>>
% This Matlab function is accessible [[file:src/runSimulation.m][here]]. % This Matlab function is accessible [[file:../src/runSimulation.m][here]].
function [] = runSimulation(sys_name, sys_mass, ctrl_type, act_damp) function [] = runSimulation(sys_name, sys_mass, ctrl_type, act_damp)
%% Load the controller and save it for the simulation %% Load the controller and save it for the simulation
if strcmp(ctrl_type, 'cl') && strcmp(act_damp, 'none') if strcmp(ctrl_type, 'cl') && strcmp(act_damp, 'none')
K_obj = load('./mat/K_fb.mat'); K_obj = load('./mat/K_fb.mat');
K = K_obj.(sprintf('K_%s_%s', sys_mass, sys_name)); %#ok K = K_obj.(sprintf('K_%s_%s', sys_mass, sys_name)); %#ok
save('./mat/controllers.mat', 'K'); save('./mat/controllers.mat', 'K');
elseif strcmp(ctrl_type, 'cl') && strcmp(act_damp, 'iff') elseif strcmp(ctrl_type, 'cl') && strcmp(act_damp, 'iff')
K_obj = load('./mat/K_fb_iff.mat'); K_obj = load('./mat/K_fb_iff.mat');
K = K_obj.(sprintf('K_%s_%s_iff', sys_mass, sys_name)); %#ok K = K_obj.(sprintf('K_%s_%s_iff', sys_mass, sys_name)); %#ok
save('./mat/controllers.mat', 'K'); save('./mat/controllers.mat', 'K');
elseif strcmp(ctrl_type, 'ol') elseif strcmp(ctrl_type, 'ol')
K = tf(zeros(6)); %#ok K = tf(zeros(6)); %#ok
save('./mat/controllers.mat', 'K'); save('./mat/controllers.mat', 'K');
else else
error('ctrl_type should be cl or ol'); error('ctrl_type should be cl or ol');
end end
%% Active Damping %% Active Damping
if strcmp(act_damp, 'iff') if strcmp(act_damp, 'iff')
K_iff_crit = load('./mat/K_iff_crit.mat'); K_iff_crit = load('./mat/K_iff_crit.mat');
K_iff = K_iff_crit.(sprintf('K_iff_%s_%s', sys_mass, sys_name)); %#ok K_iff = K_iff_crit.(sprintf('K_iff_%s_%s', sys_mass, sys_name)); %#ok
save('./mat/controllers.mat', 'K_iff', '-append'); save('./mat/controllers.mat', 'K_iff', '-append');
elseif strcmp(act_damp, 'none') elseif strcmp(act_damp, 'none')
K_iff = tf(zeros(6)); %#ok K_iff = tf(zeros(6)); %#ok
save('./mat/controllers.mat', 'K_iff', '-append'); save('./mat/controllers.mat', 'K_iff', '-append');
end end
%% %%
if strcmp(sys_name, 'pz') if strcmp(sys_name, 'pz')
initializeNanoHexapod(struct('actuator', 'piezo')); initializeNanoHexapod(struct('actuator', 'piezo'));
elseif strcmp(sys_name, 'vc') elseif strcmp(sys_name, 'vc')
initializeNanoHexapod(struct('actuator', 'lorentz')); initializeNanoHexapod(struct('actuator', 'lorentz'));
else else
error('sys_name should be pz or vc'); error('sys_name should be pz or vc');
end end
if strcmp(sys_mass, 'light') if strcmp(sys_mass, 'light')
initializeSample(struct('mass', 1)); initializeSample(struct('mass', 1));
elseif strcmp(sys_mass, 'heavy') elseif strcmp(sys_mass, 'heavy')
initializeSample(struct('mass', 50)); initializeSample(struct('mass', 50));
else else
error('sys_mass should be light or heavy'); error('sys_mass should be light or heavy');
end end
%% Run the simulation %% Run the simulation