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
% :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+: :eval no :results none
% :END:
% <<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)

View File

@ -1,12 +1,12 @@
% computeSetpoint
% :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+: :eval no :results none
% :END:
% <<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)

View File

@ -1,12 +1,12 @@
% converErrorBasis
% :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+: :eval no :results none
% :END:
% <<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)

View File

@ -1,12 +1,12 @@
% generateDiagPidControl
% :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+: :eval no :results none
% :END:
% <<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)

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
% :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeAxisc.m
% :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none
% :END:
% <<sec:initializeAxisc>>
% :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeAxisc.m
% :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none
% :END:
% <<sec:initializeAxisc>>
% This Matlab function is accessible [[file:../src/initializeAxisc.m][here]].

View File

@ -1,10 +1,10 @@
% Cedrat Actuator
% :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeCedratPiezo.m
% :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none
% :END:
% <<sec:initializeCedratPiezo>>
% :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeCedratPiezo.m
% :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none
% :END:
% <<sec:initializeCedratPiezo>>
% 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.ka = 10e7; % Linear Stiffness of the stack [N/m]
cedrat.c = 0.1*sqrt(50*cedrat.k); % [N/(m/s)]
cedrat.ca = 0.1*sqrt(50*cedrat.ka); % [N/(m/s)]
cedrat.c = 0.1*sqrt(1*cedrat.k); % [N/(m/s)]
cedrat.ca = 0.1*sqrt(1*cedrat.ka); % [N/(m/s)]
cedrat.L = 80; % Total Width of the Actuator[mm]
cedrat.H = 45; % Total Height of the Actuator [mm]

View File

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

View File

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

View File

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

View File

@ -1,10 +1,12 @@
% Inputs
% :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeInputs.m
% :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none
% :END:
% <<sec:initializeInputs>>
% TODO Inputs
% :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeInputs.m
% :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none
% :END:
% <<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]].

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,10 @@
% Sample
% :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeSample.m
% :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none
% :END:
% <<sec:initializeSample>>
% :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeSample.m
% :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none
% :END:
% <<sec:initializeSample>>
% 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
% :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeTy.m
% :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none
% :END:
% <<sec:initializeTy>>
% :PROPERTIES:
% :header-args:matlab+: :tangle ../src/initializeTy.m
% :header-args:matlab+: :comments org :mkdirp yes
% :header-args:matlab+: :eval no :results none
% :END:
% <<sec:initializeTy>>
% 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.
% 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;
projectRoot = project.RootFolder;

View File

@ -1,56 +1,56 @@
% runSimulation
% :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+: :eval no :results none
% :END:
% <<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)
%% Load the controller and save it for the simulation
if strcmp(ctrl_type, 'cl') && strcmp(act_damp, 'none')
K_obj = load('./mat/K_fb.mat');
K = K_obj.(sprintf('K_%s_%s', sys_mass, sys_name)); %#ok
save('./mat/controllers.mat', 'K');
K_obj = load('./mat/K_fb.mat');
K = K_obj.(sprintf('K_%s_%s', sys_mass, sys_name)); %#ok
save('./mat/controllers.mat', 'K');
elseif strcmp(ctrl_type, 'cl') && strcmp(act_damp, 'iff')
K_obj = load('./mat/K_fb_iff.mat');
K = K_obj.(sprintf('K_%s_%s_iff', sys_mass, sys_name)); %#ok
save('./mat/controllers.mat', 'K');
K_obj = load('./mat/K_fb_iff.mat');
K = K_obj.(sprintf('K_%s_%s_iff', sys_mass, sys_name)); %#ok
save('./mat/controllers.mat', 'K');
elseif strcmp(ctrl_type, 'ol')
K = tf(zeros(6)); %#ok
save('./mat/controllers.mat', 'K');
K = tf(zeros(6)); %#ok
save('./mat/controllers.mat', 'K');
else
error('ctrl_type should be cl or ol');
error('ctrl_type should be cl or ol');
end
%% Active Damping
if strcmp(act_damp, 'iff')
K_iff_crit = load('./mat/K_iff_crit.mat');
K_iff = K_iff_crit.(sprintf('K_iff_%s_%s', sys_mass, sys_name)); %#ok
save('./mat/controllers.mat', 'K_iff', '-append');
K_iff_crit = load('./mat/K_iff_crit.mat');
K_iff = K_iff_crit.(sprintf('K_iff_%s_%s', sys_mass, sys_name)); %#ok
save('./mat/controllers.mat', 'K_iff', '-append');
elseif strcmp(act_damp, 'none')
K_iff = tf(zeros(6)); %#ok
save('./mat/controllers.mat', 'K_iff', '-append');
K_iff = tf(zeros(6)); %#ok
save('./mat/controllers.mat', 'K_iff', '-append');
end
%%
if strcmp(sys_name, 'pz')
initializeNanoHexapod(struct('actuator', 'piezo'));
elseif strcmp(sys_name, 'vc')
initializeNanoHexapod(struct('actuator', 'lorentz'));
initializeNanoHexapod(struct('actuator', 'lorentz'));
else
error('sys_name should be pz or vc');
error('sys_name should be pz or vc');
end
if strcmp(sys_mass, 'light')
initializeSample(struct('mass', 1));
elseif strcmp(sys_mass, 'heavy')
initializeSample(struct('mass', 50));
initializeSample(struct('mass', 50));
else
error('sys_mass should be light or heavy');
error('sys_mass should be light or heavy');
end
%% Run the simulation