f0e83d7c39
- Add may folders - Add IFF and HAC-LAC scripts
126 lines
4.0 KiB
Matlab
126 lines
4.0 KiB
Matlab
function [inputs] = initializeInputs(opts_param)
|
|
%% Default values for opts
|
|
opts = struct('setpoint', false, ...
|
|
'ground_motion', false, ...
|
|
'ty', false, ...
|
|
'ry', false, ...
|
|
'rz', false, ... % If numerical value, rpm speed of the spindle
|
|
'u_hexa', false, ...
|
|
'mass', false, ...
|
|
'n_hexa', false ...
|
|
);
|
|
|
|
%% 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
|
|
load('./mat/sim_conf.mat', 'sim_conf');
|
|
|
|
%% Define the time vector
|
|
time_vector = 0:sim_conf.Ts:sim_conf.Tsim;
|
|
|
|
%% Create the input Structure that will contain all the inputs
|
|
inputs = struct();
|
|
|
|
%% Ground motion
|
|
if islogical(opts.ground_motion) && opts.ground_motion == true
|
|
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);
|
|
elseif islogical(opts.ground_motion) && opts.ground_motion == false
|
|
ground_motion = zeros(length(time_vector), 3);
|
|
else
|
|
ground_motion = opts.ground_motion;
|
|
end
|
|
|
|
inputs.ground_motion = timeseries(ground_motion, time_vector);
|
|
|
|
%% Translation stage [m]
|
|
if islogical(opts.ty) && opts.ty == true
|
|
ty = zeros(length(time_vector), 1);
|
|
elseif islogical(opts.ty) && opts.ty == false
|
|
ty = zeros(length(time_vector), 1);
|
|
else
|
|
ty = opts.ty;
|
|
end
|
|
|
|
inputs.ty = timeseries(ty, time_vector);
|
|
|
|
%% Tilt Stage [rad]
|
|
if islogical(opts.ry) && opts.ry == true
|
|
ry = 3*(2*pi/360)*sin(2*pi*0.2*time_vector);
|
|
elseif islogical(opts.ry) && opts.ry == false
|
|
ry = zeros(length(time_vector), 1);
|
|
else
|
|
ry = opts.ry;
|
|
end
|
|
|
|
inputs.ry = timeseries(ry, time_vector);
|
|
|
|
%% Spindle [rad]
|
|
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;
|
|
else
|
|
rz = opts.rz;
|
|
end
|
|
|
|
inputs.rz = timeseries(rz, time_vector);
|
|
|
|
%% Micro Hexapod
|
|
if islogical(opts.u_hexa) && opts.setpoint == true
|
|
u_hexa = zeros(length(time_vector), 6);
|
|
elseif islogical(opts.u_hexa) && opts.setpoint == false
|
|
u_hexa = zeros(length(time_vector), 6);
|
|
else
|
|
u_hexa = opts.u_hexa;
|
|
end
|
|
|
|
inputs.micro_hexapod = timeseries(u_hexa, time_vector);
|
|
|
|
%% Center of gravity compensation
|
|
if islogical(opts.mass) && opts.setpoint == true
|
|
mass = zeros(length(time_vector), 2);
|
|
elseif islogical(opts.mass) && opts.setpoint == false
|
|
mass = zeros(length(time_vector), 2);
|
|
else
|
|
mass = opts.mass;
|
|
end
|
|
|
|
inputs.axisc = timeseries(mass, time_vector);
|
|
|
|
%% Nano Hexapod
|
|
if islogical(opts.n_hexa) && opts.setpoint == true
|
|
n_hexa = zeros(length(time_vector), 6);
|
|
elseif islogical(opts.n_hexa) && opts.setpoint == false
|
|
n_hexa = zeros(length(time_vector), 6);
|
|
else
|
|
n_hexa = opts.n_hexa;
|
|
end
|
|
|
|
inputs.nano_hexapod = timeseries(n_hexa, time_vector);
|
|
|
|
%% Set point [m, rad]
|
|
if islogical(opts.setpoint) && opts.setpoint == true
|
|
setpoint = zeros(length(time_vector), 6);
|
|
elseif islogical(opts.setpoint) && opts.setpoint == false
|
|
setpoint = zeros(length(time_vector), 6);
|
|
else
|
|
setpoint = opts.setpoint;
|
|
end
|
|
|
|
inputs.setpoint = timeseries(setpoint, time_vector);
|
|
|
|
%% Save
|
|
save('./mat/inputs.mat', 'inputs');
|
|
end
|