55 lines
1.7 KiB
Mathematica
55 lines
1.7 KiB
Mathematica
|
%% First make sure the model is open, and we are connected to the
|
||
|
% Speedgoat Machine.
|
||
|
|
||
|
labels = {'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz'};
|
||
|
|
||
|
%% Run Multiple Simulations
|
||
|
my_model = 'iff_measure';
|
||
|
tg = slrt;
|
||
|
|
||
|
%% For each strut
|
||
|
for i_dir = 1:6
|
||
|
%% Get excitation strut
|
||
|
p = Simulink.Mask.get([my_model, '/Subsystem5']);
|
||
|
p.Parameters.Value = sprintf('%i', i_dir);
|
||
|
|
||
|
%% Connect
|
||
|
set_param(my_model,'SimulationCommand','connect')
|
||
|
|
||
|
%% Run the simulation
|
||
|
sprintf('Start measurement in %s', labels{i_dir})
|
||
|
set_param(my_model,'SimulationCommand','start')
|
||
|
|
||
|
%% Wait for the simulation to finish
|
||
|
pause(1)
|
||
|
while strcmp(get_param(my_model,'SimulationStatus'), 'external')
|
||
|
pause(1)
|
||
|
end
|
||
|
sprintf('Finished excitation for %s', labels{i_dir})
|
||
|
|
||
|
%% Disconnect
|
||
|
set_param(my_model,'SimulationCommand','disconnect')
|
||
|
|
||
|
%% Save the data
|
||
|
f = SimulinkRealTime.openFTP(tg);
|
||
|
mget(f, 'data/data.dat');
|
||
|
close(f);
|
||
|
data = SimulinkRealTime.utils.getFileScopeData('data/data.dat').data;
|
||
|
|
||
|
de = data(:, 1:6); % Measurment displacement (encoder) [m]
|
||
|
Vs = data(:, 7:12); % Force Sensor [V]
|
||
|
u = data(:, 13:18); % Control Output [V]
|
||
|
Va = data(:, 19); % Excitation Signal [V]
|
||
|
Rx = data(:, 20:25); % Reference Signal [m/rad]
|
||
|
t = data(:, end); % Time [s]
|
||
|
|
||
|
load('sim_data/data_sim.mat', 'Ts'); % To save Sampling Period
|
||
|
load('sim_data/Kiff.mat', 'Kiff'); % To save Controller
|
||
|
load('sim_data/Khac_iff_struts.mat', 'Khac_iff_struts'); % To save Controller
|
||
|
|
||
|
save(sprintf('mat/T_S_meas_%s_2m_hac_svd_iff.mat', labels{i_dir}), ...
|
||
|
't', 'Ts', 'de', 'Vs', 'u', 'Va', 'Kiff', 'Khac_iff_struts');
|
||
|
|
||
|
sprintf('Saved Data for strut %s', labels{i_dir})
|
||
|
end
|