Use new argument function validation technique

This commit is contained in:
2020-01-13 11:42:31 +01:00
parent 994fe2ccc7
commit a2917a50e9
20 changed files with 770 additions and 660 deletions

View File

@@ -53,60 +53,81 @@
This Matlab function is accessible [[file:../src/initializeInputs.m][here]].
*** Function Declaration and Documentation
#+begin_src matlab
function [ref] = initializeReferences(opts_param)
%% Default values for opts
opts = struct( ...
'Ts', 1e-3, ... % Sampling Frequency [s]
'Tmax', 100, ... % Maximum simulation time [s]
'Dy_type', 'constant', ... % Either "constant" / "triangular" / "sinusoidal"
'Dy_amplitude', 0, ... % Amplitude of the displacement [m]
'Dy_period', 1, ... % Period of the displacement [s]
'Ry_type', 'constant', ... % Either "constant" / "triangular" / "sinusoidal"
'Ry_amplitude', 0, ... % Amplitude [rad]
'Ry_period', 1, ... % Period of the displacement [s]
'Rz_type', 'constant', ... % Either "constant" / "rotating"
'Rz_amplitude', 0, ... % Initial angle [rad]
'Rz_period', 1, ... % Period of the rotating [s]
'Dh_type', 'constant', ... % For now, only constant is implemented
'Dh_pos', zeros(6, 1), ... % Initial position [m,m,m,rad,rad,rad] of the top platform (Pitch-Roll-Yaw Euler angles)
'Rm_type', 'constant', ... % For now, only constant is implemented
'Rm_pos', [0; pi], ... % Initial position of the two masses
'Dn_type', 'constant', ... % For now, only constant is implemented
'Dn_pos', zeros(6,1) ... % Initial position [m,m,m,rad,rad,rad] of the top platform
);
function [ref] = initializeReferences(args)
#+end_src
%% Populate opts with input parameters
if exist('opts_param','var')
for opt = fieldnames(opts_param)'
opts.(opt{1}) = opts_param.(opt{1});
end
end
*** Optional Parameters
#+begin_src matlab
arguments
% Sampling Frequency [s]
args.Ts (1,1) double {mustBeNumeric, mustBePositive} = 1e-3
% Maximum simulation time [s]
args.Tmax (1,1) double {mustBeNumeric, mustBePositive} = 100
% Either "constant" / "triangular" / "sinusoidal"
args.Dy_type char {mustBeMember(args.Dy_type,{'constant', 'triangular', 'sinusoidal'})} = 'constant'
% Amplitude of the displacement [m]
args.Dy_amplitude (1,1) double {mustBeNumeric} = 0
% Period of the displacement [s]
args.Dy_period (1,1) double {mustBeNumeric, mustBePositive} = 1
% Either "constant" / "triangular" / "sinusoidal"
args.Ry_type char {mustBeMember(args.Ry_type,{'constant', 'triangular', 'sinusoidal'})} = 'constant'
% Amplitude [rad]
args.Ry_amplitude (1,1) double {mustBeNumeric} = 0
% Period of the displacement [s]
args.Ry_period (1,1) double {mustBeNumeric, mustBePositive} = 1
% Either "constant" / "rotating"
args.Rz_type char {mustBeMember(args.Rz_type,{'constant', 'rotating'})} = 'constant'
% Initial angle [rad]
args.Rz_amplitude (1,1) double {mustBeNumeric} = 0
% Period of the rotating [s]
args.Rz_period (1,1) double {mustBeNumeric, mustBePositive} = 1
% For now, only constant is implemented
args.Dh_type char {mustBeMember(args.Dh_type,{'constant'})} = 'constant'
% Initial position [m,m,m,rad,rad,rad] of the top platform (Pitch-Roll-Yaw Euler angles)
args.Dh_pos (6,1) double {mustBeNumeric} = zeros(6, 1), ...
% For now, only constant is implemented
args.Rm_type char {mustBeMember(args.Rm_type,{'constant'})} = 'constant'
% Initial position of the two masses
args.Rm_pos (2,1) double {mustBeNumeric} = [0; pi]
% For now, only constant is implemented
args.Dn_type char {mustBeMember(args.Dn_type,{'constant'})} = 'constant'
% Initial position [m,m,m,rad,rad,rad] of the top platform
args.Dn_pos (6,1) double {mustBeNumeric} = zeros(6,1)
end
#+end_src
*** Initialize Parameters
#+begin_src matlab
%% Set Sampling Time
Ts = opts.Ts;
Tmax = opts.Tmax;
Ts = args.Ts;
Tmax = args.Tmax;
%% Low Pass Filter to filter out the references
s = zpk('s');
w0 = 2*pi*100;
xi = 1;
H_lpf = 1/(1 + 2*xi/w0*s + s^2/w0^2);
#+end_src
*** Translation Stage
#+begin_src matlab
%% Translation stage - Dy
t = 0:Ts:Tmax; % Time Vector [s]
Dy = zeros(length(t), 1);
Dyd = zeros(length(t), 1);
Dydd = zeros(length(t), 1);
switch opts.Dy_type
switch args.Dy_type
case 'constant'
Dy(:) = opts.Dy_amplitude;
Dy(:) = args.Dy_amplitude;
Dyd(:) = 0;
Dydd(:) = 0;
case 'triangular'
% This is done to unsure that we start with no displacement
Dy_raw = opts.Dy_amplitude*sawtooth(2*pi*t/opts.Dy_period,1/2);
i0 = find(t>=opts.Dy_period/4,1);
Dy_raw = args.Dy_amplitude*sawtooth(2*pi*t/args.Dy_period,1/2);
i0 = find(t>=args.Dy_period/4,1);
Dy(1:end-i0+1) = Dy_raw(i0:end);
Dy(end-i0+2:end) = Dy_raw(end); % we fix the last value
@@ -115,29 +136,32 @@ This Matlab function is accessible [[file:../src/initializeInputs.m][here]].
Dyd = lsim(H_lpf*s, Dy, t);
Dydd = lsim(H_lpf*s^2, Dy, t);
case 'sinusoidal'
Dy(:) = opts.Dy_amplitude*sin(2*pi/opts.Dy_period*t);
Dyd = opts.Dy_amplitude*2*pi/opts.Dy_period*cos(2*pi/opts.Dy_period*t);
Dydd = -opts.Dy_amplitude*(2*pi/opts.Dy_period)^2*sin(2*pi/opts.Dy_period*t);
Dy(:) = args.Dy_amplitude*sin(2*pi/args.Dy_period*t);
Dyd = args.Dy_amplitude*2*pi/args.Dy_period*cos(2*pi/args.Dy_period*t);
Dydd = -args.Dy_amplitude*(2*pi/args.Dy_period)^2*sin(2*pi/args.Dy_period*t);
otherwise
warning('Dy_type is not set correctly');
end
Dy = struct('time', t, 'signals', struct('values', Dy), 'deriv', Dyd, 'dderiv', Dydd);
#+end_src
*** Tilt Stage
#+begin_src matlab
%% Tilt Stage - Ry
t = 0:Ts:Tmax; % Time Vector [s]
Ry = zeros(length(t), 1);
Ryd = zeros(length(t), 1);
Rydd = zeros(length(t), 1);
switch opts.Ry_type
switch args.Ry_type
case 'constant'
Ry(:) = opts.Ry_amplitude;
Ry(:) = args.Ry_amplitude;
Ryd(:) = 0;
Rydd(:) = 0;
case 'triangular'
Ry_raw = opts.Ry_amplitude*sawtooth(2*pi*t/opts.Ry_period,1/2);
i0 = find(t>=opts.Ry_period/4,1);
Ry_raw = args.Ry_amplitude*sawtooth(2*pi*t/args.Ry_period,1/2);
i0 = find(t>=args.Ry_period/4,1);
Ry(1:end-i0+1) = Ry_raw(i0:end);
Ry(end-i0+2:end) = Ry_raw(end); % we fix the last value
@@ -146,29 +170,32 @@ This Matlab function is accessible [[file:../src/initializeInputs.m][here]].
Ryd = lsim(H_lpf*s, Ry, t);
Rydd = lsim(H_lpf*s^2, Ry, t);
case 'sinusoidal'
Ry(:) = opts.Ry_amplitude*sin(2*pi/opts.Ry_period*t);
Ry(:) = args.Ry_amplitude*sin(2*pi/args.Ry_period*t);
Ryd = opts.Ry_amplitude*2*pi/opts.Ry_period*cos(2*pi/opts.Ry_period*t);
Rydd = -opts.Ry_amplitude*(2*pi/opts.Ry_period)^2*sin(2*pi/opts.Ry_period*t);
Ryd = args.Ry_amplitude*2*pi/args.Ry_period*cos(2*pi/args.Ry_period*t);
Rydd = -args.Ry_amplitude*(2*pi/args.Ry_period)^2*sin(2*pi/args.Ry_period*t);
otherwise
warning('Ry_type is not set correctly');
end
Ry = struct('time', t, 'signals', struct('values', Ry), 'deriv', Ryd, 'dderiv', Rydd);
#+end_src
*** Spindle
#+begin_src matlab
%% Spindle - Rz
t = 0:Ts:Tmax; % Time Vector [s]
Rz = zeros(length(t), 1);
Rzd = zeros(length(t), 1);
Rzdd = zeros(length(t), 1);
switch opts.Rz_type
switch args.Rz_type
case 'constant'
Rz(:) = opts.Rz_amplitude;
Rz(:) = args.Rz_amplitude;
Rzd(:) = 0;
Rzdd(:) = 0;
case 'rotating'
Rz(:) = opts.Rz_amplitude+2*pi/opts.Rz_period*t;
Rz(:) = args.Rz_amplitude+2*pi/args.Rz_period*t;
% The signal is filtered out
Rz = lsim(H_lpf, Rz, t);
@@ -179,29 +206,32 @@ This Matlab function is accessible [[file:../src/initializeInputs.m][here]].
end
Rz = struct('time', t, 'signals', struct('values', Rz), 'deriv', Rzd, 'dderiv', Rzdd);
#+end_src
*** Micro Hexapod
#+begin_src matlab
%% Micro-Hexapod
t = [0, Ts];
Dh = zeros(length(t), 6);
Dhl = zeros(length(t), 6);
switch opts.Dh_type
switch args.Dh_type
case 'constant'
Dh = [opts.Dh_pos, opts.Dh_pos];
Dh = [args.Dh_pos, args.Dh_pos];
load('./mat/stages.mat', 'micro_hexapod');
load('mat/stages.mat', 'micro_hexapod');
AP = [opts.Dh_pos(1) ; opts.Dh_pos(2) ; opts.Dh_pos(3)];
AP = [args.Dh_pos(1) ; args.Dh_pos(2) ; args.Dh_pos(3)];
tx = opts.Dh_pos(4);
ty = opts.Dh_pos(5);
tz = opts.Dh_pos(6);
tx = args.Dh_pos(4);
ty = args.Dh_pos(5);
tz = args.Dh_pos(6);
ARB = [cos(tz) -sin(tz) 0;
sin(tz) cos(tz) 0;
0 0 1]*...
[ cos(ty) 0 sin(ty);
0 1 0;
0 1 0;
-sin(ty) 0 cos(ty)]*...
[1 0 0;
0 cos(tx) -sin(tx);
@@ -215,28 +245,37 @@ This Matlab function is accessible [[file:../src/initializeInputs.m][here]].
Dh = struct('time', t, 'signals', struct('values', Dh));
Dhl = struct('time', t, 'signals', struct('values', Dhl));
#+end_src
*** Axis Compensation
#+begin_src matlab
%% Axis Compensation - Rm
t = [0, Ts];
Rm = [opts.Rm_pos, opts.Rm_pos];
Rm = [args.Rm_pos, args.Rm_pos];
Rm = struct('time', t, 'signals', struct('values', Rm));
#+end_src
*** Nano Hexapod
#+begin_src matlab
%% Nano-Hexapod
t = [0, Ts];
Dn = zeros(length(t), 6);
switch opts.Dn_type
switch args.Dn_type
case 'constant'
Dn = [opts.Dn_pos, opts.Dn_pos];
Dn = [args.Dn_pos, args.Dn_pos];
otherwise
warning('Dn_type is not set correctly');
end
Dn = struct('time', t, 'signals', struct('values', Dn));
#+end_src
*** Save
#+begin_src matlab
%% Save
save('./mat/nass_references.mat', 'Dy', 'Ry', 'Rz', 'Dh', 'Dhl', 'Rm', 'Dn', 'Ts');
save('mat/nass_references.mat', 'Dy', 'Ry', 'Rz', 'Dh', 'Dhl', 'Rm', 'Dn', 'Ts');
end
#+end_src
@@ -252,36 +291,35 @@ This Matlab function is accessible [[file:src/initDisturbances.m][here]].
*** Function Declaration and Documentation
#+begin_src matlab
function [] = initDisturbances(opts_param)
function [] = initDisturbances(args)
% initDisturbances - Initialize the disturbances
%
% Syntax: [] = initDisturbances(opts_param)
% Syntax: [] = initDisturbances(args)
%
% Inputs:
% - opts_param -
% - args -
#+end_src
*** Default values for the Options
*** Optional Parameters
#+begin_src matlab
%% Default values for opts
opts = struct(...
'Dwx', true, ... % Ground Motion - X direction
'Dwy', true, ... % Ground Motion - Y direction
'Dwz', true, ... % Ground Motion - Z direction
'Fty_x', true, ... % Translation Stage - X direction
'Fty_z', true, ... % Translation Stage - Z direction
'Frz_z', true ... % Spindle - Z direction
);
%% Populate opts with input parameters
if exist('opts_param','var')
for opt = fieldnames(opts_param)'
opts.(opt{1}) = opts_param.(opt{1});
end
arguments
% Ground Motion - X direction
args.Dwx logical {mustBeNumericOrLogical} = true
% Ground Motion - Y direction
args.Dwy logical {mustBeNumericOrLogical} = true
% Ground Motion - Z direction
args.Dwz logical {mustBeNumericOrLogical} = true
% Translation Stage - X direction
args.Fty_x logical {mustBeNumericOrLogical} = true
% Translation Stage - Z direction
args.Fty_z logical {mustBeNumericOrLogical} = true
% Spindle - Z direction
args.Frz_z logical {mustBeNumericOrLogical} = true
end
#+end_src
*** Load Data
#+begin_src matlab
load('./disturbances/mat/dist_psd.mat', 'dist_f');
@@ -317,7 +355,7 @@ We define some parameters that will be used in the algorithm.
#+end_src
#+begin_src matlab
if opts.Dwx
if args.Dwx
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
Cx = [Cx; flipud(conj(Cx(2:end)))];;
@@ -328,7 +366,7 @@ We define some parameters that will be used in the algorithm.
#+end_src
#+begin_src matlab
if opts.Dwy
if args.Dwy
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
Cx = [Cx; flipud(conj(Cx(2:end)))];;
@@ -339,7 +377,7 @@ We define some parameters that will be used in the algorithm.
#+end_src
#+begin_src matlab
if opts.Dwy
if args.Dwy
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
Cx = [Cx; flipud(conj(Cx(2:end)))];;
@@ -351,7 +389,7 @@ We define some parameters that will be used in the algorithm.
*** Translation Stage - X direction
#+begin_src matlab
if opts.Fty_x
if args.Fty_x
phi = dist_f.psd_ty; % TODO - we take here the vertical direction which is wrong but approximate
C = zeros(N/2,1);
for i = 1:N/2
@@ -369,7 +407,7 @@ We define some parameters that will be used in the algorithm.
*** Translation Stage - Z direction
#+begin_src matlab
if opts.Fty_z
if args.Fty_z
phi = dist_f.psd_ty;
C = zeros(N/2,1);
for i = 1:N/2
@@ -387,7 +425,7 @@ We define some parameters that will be used in the algorithm.
*** Spindle - Z direction
#+begin_src matlab
if opts.Frz_z
if args.Frz_z
phi = dist_f.psd_rz;
C = zeros(N/2,1);
for i = 1:N/2
@@ -421,7 +459,7 @@ We define some parameters that will be used in the algorithm.
*** Save
#+begin_src matlab
save('./mat/nass_disturbances.mat', 'Dwx', 'Dwy', 'Dwz', 'Fty_x', 'Fty_z', 'Frz_z', 'Fd', 'Ts', 't');
save('mat/nass_disturbances.mat', 'Dwx', 'Dwy', 'Dwz', 'Fty_x', 'Fty_z', 'Frz_z', 'Fd', 'Ts', 't');
#+end_src
* Initialize Elements
@@ -462,15 +500,9 @@ end
This Matlab function is accessible [[file:../src/initializeGranite.m][here]].
#+begin_src matlab
function [granite] = initializeGranite(opts_param)
%% Default values for opts
opts = struct('rigid', false);
%% Populate opts with input parameters
if exist('opts_param','var')
for opt = fieldnames(opts_param)'
opts.(opt{1}) = opts_param.(opt{1});
end
function [granite] = initializeGranite(args)
arguments
args.rigid logical {mustBeNumericOrLogical} = false
end
%%
@@ -486,7 +518,7 @@ This Matlab function is accessible [[file:../src/initializeGranite.m][here]].
granite.mass_top = 4000; % [kg] TODO
%% Dynamical Properties
if opts.rigid
if args.rigid
granite.k.x = 1e12; % [N/m]
granite.k.y = 1e12; % [N/m]
granite.k.z = 1e12; % [N/m]
@@ -527,15 +559,9 @@ This Matlab function is accessible [[file:../src/initializeGranite.m][here]].
This Matlab function is accessible [[file:../src/initializeTy.m][here]].
#+begin_src matlab
function [ty] = initializeTy(opts_param)
%% Default values for opts
opts = struct('rigid', false);
%% Populate opts with input parameters
if exist('opts_param','var')
for opt = fieldnames(opts_param)'
opts.(opt{1}) = opts_param.(opt{1});
end
function [ty] = initializeTy(args)
arguments
args.rigid logical {mustBeNumericOrLogical} = false
end
%%
@@ -582,7 +608,7 @@ This Matlab function is accessible [[file:../src/initializeTy.m][here]].
ty.m = 1000; % TODO [kg]
%% Y-Translation - Dynamicals Properties
if opts.rigid
if args.rigid
ty.k.ax = 1e12; % Axial Stiffness for each of the 4 guidance (y) [N/m]
ty.k.rad = 1e12; % Radial Stiffness for each of the 4 guidance (x-z) [N/m]
else
@@ -608,15 +634,9 @@ This Matlab function is accessible [[file:../src/initializeTy.m][here]].
This Matlab function is accessible [[file:../src/initializeRy.m][here]].
#+begin_src matlab
function [ry] = initializeRy(opts_param)
%% Default values for opts
opts = struct('rigid', false);
%% Populate opts with input parameters
if exist('opts_param','var')
for opt = fieldnames(opts_param)'
opts.(opt{1}) = opts_param.(opt{1});
end
function [ry] = initializeRy(args)
arguments
args.rigid logical {mustBeNumericOrLogical} = false
end
%%
@@ -643,7 +663,7 @@ This Matlab function is accessible [[file:../src/initializeRy.m][here]].
ry.m = 800; % TODO [kg]
%% Tilt Stage - Dynamical Properties
if opts.rigid
if args.rigid
ry.k.tilt = 1e10; % Rotation stiffness around y [N*m/deg]
ry.k.h = 1e12; % Stiffness in the direction of the guidance [N/m]
ry.k.rad = 1e12; % Stiffness in the top direction [N/m]
@@ -678,15 +698,9 @@ This Matlab function is accessible [[file:../src/initializeRy.m][here]].
This Matlab function is accessible [[file:../src/initializeRz.m][here]].
#+begin_src matlab
function [rz] = initializeRz(opts_param)
%% Default values for opts
opts = struct('rigid', false);
%% Populate opts with input parameters
if exist('opts_param','var')
for opt = fieldnames(opts_param)'
opts.(opt{1}) = opts_param.(opt{1});
end
function [rz] = initializeRz(args)
arguments
args.rigid logical {mustBeNumericOrLogical} = false
end
%%
@@ -711,7 +725,7 @@ This Matlab function is accessible [[file:../src/initializeRz.m][here]].
%% Spindle - Dynamical Properties
if opts.rigid
if args.rigid
rz.k.rot = 1e10; % Rotational Stiffness (Rz) [N*m/deg]
rz.k.tilt = 1e10; % Rotational Stiffness (Rx, Ry) [N*m/deg]
rz.k.ax = 1e12; % Axial Stiffness (Z) [N/m]
@@ -744,19 +758,11 @@ This Matlab function is accessible [[file:../src/initializeRz.m][here]].
This Matlab function is accessible [[file:../src/initializeMicroHexapod.m][here]].
#+begin_src matlab
function [micro_hexapod] = initializeMicroHexapod(opts_param)
%% Default values for opts
opts = struct(...
'rigid', false, ...
'AP', zeros(3, 1), ... % Wanted position in [m] of OB with respect to frame {A}
'ARB', eye(3) ... % Rotation Matrix that represent the wanted orientation of frame {B} with respect to frame {A}
);
%% Populate opts with input parameters
if exist('opts_param','var')
for opt = fieldnames(opts_param)'
opts.(opt{1}) = opts_param.(opt{1});
end
function [micro_hexapod] = initializeMicroHexapod(args)
arguments
args.rigid logical {mustBeNumericOrLogical} = false
args.AP (3,1) double {mustBeNumeric} = zeros(3,1)
args.ARB (3,3) double {mustBeNumeric} = eye(3)
end
%% Stewart Object
@@ -792,7 +798,7 @@ This Matlab function is accessible [[file:../src/initializeMicroHexapod.m][here]
Leg = struct();
Leg.stroke = 10e-3; % Maximum Stroke of each leg [m]
if opts.rigid
if args.rigid
Leg.k.ax = 1e12; % Stiffness of each leg [N/m]
else
Leg.k.ax = 2e7; % Stiffness of each leg [N/m]
@@ -844,7 +850,7 @@ This Matlab function is accessible [[file:../src/initializeMicroHexapod.m][here]
micro_hexapod = initializeParameters(micro_hexapod);
%% Setup equilibrium position of each leg
micro_hexapod.L0 = inverseKinematicsHexapod(micro_hexapod, opts.AP, opts.ARB);
micro_hexapod.L0 = inverseKinematicsHexapod(micro_hexapod, args.AP, args.ARB);
%% Save
save('./mat/stages.mat', 'micro_hexapod', '-append');
@@ -1003,18 +1009,10 @@ This Matlab function is accessible [[file:../src/initializeAxisc.m][here]].
This Matlab function is accessible [[file:../src/initializeMirror.m][here]].
#+begin_src matlab
function [] = initializeMirror(opts_param)
%% Default values for opts
opts = struct(...
'shape', 'spherical', ... % spherical or conical
'angle', 45 ...
);
%% Populate opts with input parameters
if exist('opts_param','var')
for opt = fieldnames(opts_param)'
opts.(opt{1}) = opts_param.(opt{1});
end
function [] = initializeMirror(args)
arguments
args.shape char {mustBeMember(args.shape,{'spherical', 'conical'})} = 'spherical'
args.angle (1,1) double {mustBeNumeric, mustBePositive} = 45
end
%%
@@ -1029,7 +1027,7 @@ This Matlab function is accessible [[file:../src/initializeMirror.m][here]].
mirror.density = 2400; % Density of the mirror [kg/m3]
mirror.color = [0.4 1.0 1.0]; % Color of the mirror
mirror.cone_length = mirror.rad*tand(opts.angle)+mirror.h+mirror.jacobian; % Distance from Apex point of the cone to jacobian point
mirror.cone_length = mirror.rad*tand(args.angle)+mirror.h+mirror.jacobian; % Distance from Apex point of the cone to jacobian point
%% Shape
mirror.shape = [...
@@ -1039,14 +1037,14 @@ This Matlab function is accessible [[file:../src/initializeMirror.m][here]].
mirror.rad 0 ...
];
if strcmp(opts.shape, 'spherical')
if strcmp(args.shape, 'spherical')
mirror.sphere_radius = sqrt((mirror.jacobian+mirror.h)^2+mirror.rad^2); % Radius of the sphere [mm]
for z = linspace(0, mirror.h, 101)
mirror.shape = [mirror.shape; sqrt(mirror.sphere_radius^2-(z-mirror.jacobian-mirror.h)^2) z];
end
elseif strcmp(opts.shape, 'conical')
mirror.shape = [mirror.shape; mirror.rad+mirror.h/tand(opts.angle) mirror.h];
elseif strcmp(args.shape, 'conical')
mirror.shape = [mirror.shape; mirror.rad+mirror.h/tand(args.angle) mirror.h];
else
error('Shape should be either conical or spherical');
end
@@ -1068,22 +1066,17 @@ This Matlab function is accessible [[file:../src/initializeMirror.m][here]].
This Matlab function is accessible [[file:../src/initializeNanoHexapod.m][here]].
#+begin_src matlab
function [nano_hexapod] = initializeNanoHexapod(opts_param)
%% Default values for opts
opts = struct('actuator', 'piezo');
%% Populate opts with input parameters
if exist('opts_param','var')
for opt = fieldnames(opts_param)'
opts.(opt{1}) = opts_param.(opt{1});
end
function [nano_hexapod] = initializeNanoHexapod(args)
arguments
args.actuator char {mustBeMember(args.actuator,{'piezo', 'lorentz'})} = 'piezo'
args.AP (3,1) double {mustBeNumeric} = zeros(3,1)
args.ARB (3,3) double {mustBeNumeric} = eye(3)
end
%% Stewart Object
nano_hexapod = struct();
nano_hexapod.h = 90; % Total height of the platform [mm]
nano_hexapod.jacobian = 175; % Point where the Jacobian is computed => Center of rotation [mm]
% nano_hexapod.jacobian = 174.26; % Point where the Jacobian is computed => Center of rotation [mm]
%% Bottom Plate
BP = struct();
@@ -1113,12 +1106,12 @@ This Matlab function is accessible [[file:../src/initializeNanoHexapod.m][here]]
Leg = struct();
Leg.stroke = 80e-6; % Maximum Stroke of each leg [m]
if strcmp(opts.actuator, 'piezo')
if strcmp(args.actuator, 'piezo')
Leg.k.ax = 1e7; % Stiffness of each leg [N/m]
elseif strcmp(opts.actuator, 'lorentz')
elseif strcmp(args.actuator, 'lorentz')
Leg.k.ax = 1e4; % Stiffness of each leg [N/m]
else
error('opts.actuator should be piezo or lorentz');
error('args.actuator should be piezo or lorentz');
end
Leg.ksi.ax = 10; % Maximum amplification at resonance []
Leg.rad.bottom = 12; % Radius of the cylinder of the bottom part [mm]
@@ -1167,6 +1160,9 @@ This Matlab function is accessible [[file:../src/initializeNanoHexapod.m][here]]
%%
nano_hexapod = initializeParameters(nano_hexapod);
%% Setup equilibrium position of each leg
nano_hexapod.L0 = inverseKinematicsHexapod(nano_hexapod, args.AP, args.ARB);
%% Save
save('./mat/stages.mat', 'nano_hexapod', '-append');
@@ -1284,17 +1280,7 @@ This Matlab function is accessible [[file:../src/initializeNanoHexapod.m][here]]
This Matlab function is accessible [[file:../src/initializeCedratPiezo.m][here]].
#+begin_src matlab
function [cedrat] = initializeCedratPiezo(opts_param)
%% Default values for opts
opts = struct();
%% Populate opts with input parameters
if exist('opts_param','var')
for opt = fieldnames(opts_param)'
opts.(opt{1}) = opts_param.(opt{1});
end
end
function [cedrat] = initializeCedratPiezo()
%% Stewart Object
cedrat = struct();
cedrat.k = 10e7; % Linear Stiffness of each "blade" [N/m]
@@ -1323,20 +1309,13 @@ This Matlab function is accessible [[file:../src/initializeCedratPiezo.m][here]]
This Matlab function is accessible [[file:../src/initializeSample.m][here]].
#+begin_src matlab
function [sample] = initializeSample(opts_param)
%% Default values for opts
sample = struct('radius', 100, ...
'height', 300, ...
'mass', 50, ...
'offset', 0, ...
'color', [0.45, 0.45, 0.45] ...
);
%% Populate opts with input parameters
if exist('opts_param','var')
for opt = fieldnames(opts_param)'
sample.(opt{1}) = opts_param.(opt{1});
end
function [sample] = initializeSample(sample)
arguments
sample.radius (1,1) double {mustBeNumeric, mustBePositive} = 100
sample.height (1,1) double {mustBeNumeric, mustBePositive} = 300
sample.mass (1,1) double {mustBeNumeric, mustBePositive} = 50
sample.offset (1,1) double {mustBeNumeric} = 0
sample.color (1,3) double {mustBeNumeric} = [0.45, 0.45, 0.45]
end
%%