2018-06-16 22:57:54 +02:00
|
|
|
function [inputs] = initializeInputs(opts_param)
|
|
|
|
%% Default values for opts
|
2018-10-12 18:17:03 +02:00
|
|
|
opts = struct('setpoint', false, ...
|
|
|
|
'Dw', false, ...
|
|
|
|
'ty', false, ...
|
|
|
|
'ry', false, ...
|
|
|
|
'Rz', false, ...
|
|
|
|
'u_hexa', false, ...
|
|
|
|
'mass', false, ...
|
|
|
|
'n_hexa', false ...
|
2018-06-16 22:57:54 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
%% Populate opts with input parameters
|
|
|
|
if exist('opts_param','var')
|
|
|
|
for opt = fieldnames(opts_param)'
|
|
|
|
opts.(opt{1}) = opts_param.(opt{1});
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
%% Load Sampling Time and Simulation Time
|
2018-06-21 11:42:46 +02:00
|
|
|
load('./mat/sim_conf.mat', 'sim_conf');
|
2018-06-16 22:57:54 +02:00
|
|
|
|
|
|
|
%% Define the time vector
|
2018-06-21 11:42:46 +02:00
|
|
|
time_vector = 0:sim_conf.Ts:sim_conf.Tsim;
|
|
|
|
|
2018-06-16 22:57:54 +02:00
|
|
|
%% Create the input Structure that will contain all the inputs
|
|
|
|
inputs = struct();
|
|
|
|
|
|
|
|
%% Ground motion
|
2018-10-12 18:17:03 +02:00
|
|
|
if islogical(opts.Dw) && opts.Dw == true
|
2018-10-24 15:08:23 +02:00
|
|
|
load('./mat/perturbations.mat', 'Wxg');
|
2018-10-12 18:17:03 +02:00
|
|
|
Dw = 1/sqrt(2)*100*random('norm', 0, 1, length(time_vector), 3);
|
|
|
|
Dw(:, 1) = lsim(Wxg, Dw(:, 1), time_vector);
|
|
|
|
Dw(:, 2) = lsim(Wxg, Dw(:, 2), time_vector);
|
|
|
|
Dw(:, 3) = lsim(Wxg, Dw(:, 3), time_vector);
|
|
|
|
elseif islogical(opts.Dw) && opts.Dw == false
|
|
|
|
Dw = zeros(length(time_vector), 3);
|
2018-06-21 14:16:08 +02:00
|
|
|
else
|
2018-10-12 18:17:03 +02:00
|
|
|
Dw = opts.Dw;
|
2018-06-16 22:57:54 +02:00
|
|
|
end
|
|
|
|
|
2018-10-12 18:17:03 +02:00
|
|
|
inputs.Dw = timeseries(Dw, time_vector);
|
2018-06-16 22:57:54 +02:00
|
|
|
|
|
|
|
%% Translation stage [m]
|
2018-07-03 15:28:29 +02:00
|
|
|
if islogical(opts.ty) && opts.ty == true
|
2018-06-16 22:57:54 +02:00
|
|
|
ty = zeros(length(time_vector), 1);
|
2018-07-03 15:28:29 +02:00
|
|
|
elseif islogical(opts.ty) && opts.ty == false
|
2018-06-16 22:57:54 +02:00
|
|
|
ty = zeros(length(time_vector), 1);
|
2018-06-21 14:16:08 +02:00
|
|
|
else
|
|
|
|
ty = opts.ty;
|
2018-06-16 22:57:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
inputs.ty = timeseries(ty, time_vector);
|
|
|
|
|
|
|
|
%% Tilt Stage [rad]
|
2018-07-03 15:28:29 +02:00
|
|
|
if islogical(opts.ry) && opts.ry == true
|
2018-06-16 22:57:54 +02:00
|
|
|
ry = 3*(2*pi/360)*sin(2*pi*0.2*time_vector);
|
2018-07-03 15:28:29 +02:00
|
|
|
elseif islogical(opts.ry) && opts.ry == false
|
2018-06-16 22:57:54 +02:00
|
|
|
ry = zeros(length(time_vector), 1);
|
2018-06-21 14:16:08 +02:00
|
|
|
else
|
|
|
|
ry = opts.ry;
|
2018-06-16 22:57:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
inputs.ry = timeseries(ry, time_vector);
|
|
|
|
|
|
|
|
%% Spindle [rad]
|
2018-10-24 15:08:23 +02:00
|
|
|
if islogical(opts.rz) && opts.rz == true
|
|
|
|
rz = 2*pi*0.5*time_vector;
|
|
|
|
elseif islogical(opts.rz) && opts.rz == false
|
|
|
|
rz = zeros(length(time_vector), 1);
|
|
|
|
elseif isnumeric(opts.rz) && length(opts.rz) == 1
|
|
|
|
rz = 2*pi*(opts.rz/60)*time_vector;
|
2018-06-21 14:16:08 +02:00
|
|
|
else
|
2018-10-24 15:08:23 +02:00
|
|
|
rz = opts.rz;
|
2018-06-16 22:57:54 +02:00
|
|
|
end
|
|
|
|
|
2018-10-24 15:08:23 +02:00
|
|
|
inputs.rz = timeseries(rz, time_vector);
|
2018-06-16 22:57:54 +02:00
|
|
|
|
|
|
|
%% Micro Hexapod
|
2018-07-03 15:28:29 +02:00
|
|
|
if islogical(opts.u_hexa) && opts.setpoint == true
|
2018-06-21 14:16:08 +02:00
|
|
|
u_hexa = zeros(length(time_vector), 6);
|
2018-07-03 15:28:29 +02:00
|
|
|
elseif islogical(opts.u_hexa) && opts.setpoint == false
|
2018-06-21 14:16:08 +02:00
|
|
|
u_hexa = zeros(length(time_vector), 6);
|
|
|
|
else
|
|
|
|
u_hexa = opts.u_hexa;
|
|
|
|
end
|
2018-06-16 22:57:54 +02:00
|
|
|
|
2018-10-24 15:08:23 +02:00
|
|
|
inputs.u_hexa = timeseries(u_hexa, time_vector);
|
2018-06-16 22:57:54 +02:00
|
|
|
|
|
|
|
%% Center of gravity compensation
|
2018-07-03 15:28:29 +02:00
|
|
|
if islogical(opts.mass) && opts.setpoint == true
|
2018-10-24 15:08:23 +02:00
|
|
|
axisc = zeros(length(time_vector), 2);
|
2018-07-03 15:28:29 +02:00
|
|
|
elseif islogical(opts.mass) && opts.setpoint == false
|
2018-10-24 15:08:23 +02:00
|
|
|
axisc = zeros(length(time_vector), 2);
|
|
|
|
axisc(:, 2) = pi*ones(length(time_vector), 1);
|
2018-06-21 14:16:08 +02:00
|
|
|
else
|
2018-10-24 15:08:23 +02:00
|
|
|
axisc = opts.mass;
|
2018-06-21 14:16:08 +02:00
|
|
|
end
|
2018-06-16 22:57:54 +02:00
|
|
|
|
2018-10-24 15:08:23 +02:00
|
|
|
inputs.axisc = timeseries(axisc, time_vector);
|
2018-06-16 22:57:54 +02:00
|
|
|
|
|
|
|
%% Nano Hexapod
|
2018-07-03 15:28:29 +02:00
|
|
|
if islogical(opts.n_hexa) && opts.setpoint == true
|
2018-06-21 14:16:08 +02:00
|
|
|
n_hexa = zeros(length(time_vector), 6);
|
2018-07-03 15:28:29 +02:00
|
|
|
elseif islogical(opts.n_hexa) && opts.setpoint == false
|
2018-06-21 14:16:08 +02:00
|
|
|
n_hexa = zeros(length(time_vector), 6);
|
|
|
|
else
|
|
|
|
n_hexa = opts.n_hexa;
|
|
|
|
end
|
2018-06-16 22:57:54 +02:00
|
|
|
|
2018-10-24 15:08:23 +02:00
|
|
|
inputs.n_hexa = timeseries(n_hexa, time_vector);
|
2018-06-16 22:57:54 +02:00
|
|
|
|
2018-06-21 11:42:46 +02:00
|
|
|
%% Set point [m, rad]
|
2018-07-03 15:28:29 +02:00
|
|
|
if islogical(opts.setpoint) && opts.setpoint == true
|
2018-06-21 11:42:46 +02:00
|
|
|
setpoint = zeros(length(time_vector), 6);
|
2018-07-03 15:28:29 +02:00
|
|
|
elseif islogical(opts.setpoint) && opts.setpoint == false
|
2018-06-21 11:42:46 +02:00
|
|
|
setpoint = zeros(length(time_vector), 6);
|
2018-06-21 14:16:08 +02:00
|
|
|
else
|
|
|
|
setpoint = opts.setpoint;
|
2018-06-21 11:42:46 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
inputs.setpoint = timeseries(setpoint, time_vector);
|
|
|
|
|
2018-10-07 22:07:21 +02:00
|
|
|
%% Save
|
|
|
|
save('./mat/inputs.mat', 'inputs');
|
2018-06-16 22:57:54 +02:00
|
|
|
end
|