2018-06-16 22:57:54 +02:00
|
|
|
function [inputs] = initializeInputs(opts_param)
|
|
|
|
%% Default values for opts
|
|
|
|
opts = struct('setpoint', false, ...
|
|
|
|
'ground_motion', false, ...
|
|
|
|
'ty', false, ...
|
|
|
|
'ry', false, ...
|
2018-06-21 14:16:08 +02:00
|
|
|
'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-06-21 14:16:08 +02:00
|
|
|
if opts.ground_motion == true
|
2018-06-16 22:57:54 +02:00
|
|
|
load('./mat/weight_Wxg.mat', 'Wxg');
|
|
|
|
ground_motion = 1/sqrt(2)*100*random('norm', 0, 1, length(time_vector), 3);
|
|
|
|
ground_motion(:, 1) = lsim(Wxg, ground_motion(:, 1), time_vector);
|
|
|
|
ground_motion(:, 2) = lsim(Wxg, ground_motion(:, 2), time_vector);
|
|
|
|
ground_motion(:, 3) = lsim(Wxg, ground_motion(:, 3), time_vector);
|
2018-06-21 14:16:08 +02:00
|
|
|
elseif opts.ground_motion == false
|
2018-06-16 22:57:54 +02:00
|
|
|
ground_motion = zeros(length(time_vector), 3);
|
2018-06-21 14:16:08 +02:00
|
|
|
else
|
|
|
|
ground_motion = opts.ground_motion;
|
2018-06-16 22:57:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
inputs.ground_motion = timeseries(ground_motion, time_vector);
|
|
|
|
|
|
|
|
%% Translation stage [m]
|
2018-06-21 14:16:08 +02:00
|
|
|
if opts.ty == true
|
2018-06-16 22:57:54 +02:00
|
|
|
ty = zeros(length(time_vector), 1);
|
2018-06-21 14:16:08 +02:00
|
|
|
elseif 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-06-21 14:16:08 +02:00
|
|
|
if opts.ry == true
|
2018-06-16 22:57:54 +02:00
|
|
|
ry = 3*(2*pi/360)*sin(2*pi*0.2*time_vector);
|
2018-06-21 14:16:08 +02:00
|
|
|
elseif 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-06-21 14:16:08 +02:00
|
|
|
if opts.rz == true
|
2018-06-16 22:57:54 +02:00
|
|
|
rz = 2*pi*0.5*time_vector;
|
2018-06-21 14:16:08 +02:00
|
|
|
elseif opts.rz == true
|
2018-06-16 22:57:54 +02:00
|
|
|
rz = zeros(length(time_vector), 1);
|
2018-06-21 14:16:08 +02:00
|
|
|
else
|
|
|
|
rz = opts.rz;
|
2018-06-16 22:57:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
inputs.rz = timeseries(rz, time_vector);
|
|
|
|
|
|
|
|
%% Micro Hexapod
|
2018-06-21 14:16:08 +02:00
|
|
|
if opts.setpoint == true
|
|
|
|
u_hexa = zeros(length(time_vector), 6);
|
|
|
|
elseif opts.setpoint == false
|
|
|
|
u_hexa = zeros(length(time_vector), 6);
|
|
|
|
else
|
|
|
|
u_hexa = opts.u_hexa;
|
|
|
|
end
|
2018-06-16 22:57:54 +02:00
|
|
|
|
|
|
|
inputs.micro_hexapod = timeseries(u_hexa, time_vector);
|
|
|
|
|
|
|
|
%% Center of gravity compensation
|
2018-06-21 14:16:08 +02:00
|
|
|
if opts.setpoint == true
|
|
|
|
mass = zeros(length(time_vector), 2);
|
|
|
|
elseif opts.setpoint == false
|
|
|
|
mass = zeros(length(time_vector), 2);
|
|
|
|
else
|
|
|
|
mass = opts.mass;
|
|
|
|
end
|
2018-06-16 22:57:54 +02:00
|
|
|
|
|
|
|
inputs.axisc = timeseries(mass, time_vector);
|
|
|
|
|
|
|
|
%% Nano Hexapod
|
2018-06-21 14:16:08 +02:00
|
|
|
if opts.setpoint == true
|
|
|
|
n_hexa = zeros(length(time_vector), 6);
|
|
|
|
elseif opts.setpoint == false
|
|
|
|
n_hexa = zeros(length(time_vector), 6);
|
|
|
|
else
|
|
|
|
n_hexa = opts.n_hexa;
|
|
|
|
end
|
2018-06-16 22:57:54 +02:00
|
|
|
|
|
|
|
inputs.nano_hexapod = timeseries(n_hexa, time_vector);
|
|
|
|
|
2018-06-21 11:42:46 +02:00
|
|
|
%% Set point [m, rad]
|
2018-06-21 14:16:08 +02:00
|
|
|
if opts.setpoint == true
|
2018-06-21 11:42:46 +02:00
|
|
|
setpoint = zeros(length(time_vector), 6);
|
|
|
|
setpoint(ceil(10/sim_conf.Ts):end, 2) = 1e-6; % Step of 1 micro-meter in y direction
|
2018-06-21 14:16:08 +02:00
|
|
|
elseif 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
|
|
|
|
|
2018-06-21 14:16:08 +02:00
|
|
|
% The setpoint in rotation should be the same as the rotation of the Spindle
|
|
|
|
% Should change that. And think how to include all the setpoint of each stage in this
|
|
|
|
% global setpoint. Maybe do everything in simulink
|
2018-06-21 11:42:46 +02:00
|
|
|
setpoint(:, 6) = rz;
|
|
|
|
|
|
|
|
inputs.setpoint = timeseries(setpoint, time_vector);
|
|
|
|
|
2018-06-16 22:57:54 +02:00
|
|
|
%% Save if no output argument
|
|
|
|
if nargout == 0
|
|
|
|
save('./mat/inputs.mat', 'inputs');
|
|
|
|
end
|
|
|
|
end
|