test-bench-nano-hexapod/matlab/init_hac_iff.m

71 lines
1.7 KiB
Mathematica
Raw Permalink Normal View History

2021-07-01 17:45:57 +02:00
%%
2021-08-11 18:03:35 +02:00
clear; close all; clc;
2021-07-01 17:45:57 +02:00
%% Saved HAC
% load('mat/Khac_iff_struts.mat', 'Khac_iff_struts');
2021-08-11 18:03:35 +02:00
% load('mat/Khac_iff_struts_rob.mat', 'Kd');
load('mat/Khac_iff_struts_svd.mat', 'Kd');
% load('mat/Khac_iff_struts_jacobian_cok.mat', 'Kd');
2021-07-01 17:45:57 +02:00
%% Save Controller
load('sim_data/data_sim.mat', 'Ts')
2021-08-11 18:03:35 +02:00
Khac_iff_struts = c2d(Kd, Ts, 'Tustin');
2021-07-01 17:45:57 +02:00
save('sim_data/Khac_iff_struts.mat', 'Khac_iff_struts');
%% Loop Gain
2021-08-11 18:03:35 +02:00
load('mat/frf_iff_vib_table_m.mat', 'f', 'G_dL');
2021-07-01 17:45:57 +02:00
2021-08-11 18:03:35 +02:00
L_frf = zeros(size(G_dL{3}));
2021-07-01 17:45:57 +02:00
2021-08-11 18:03:35 +02:00
for i = 1:length(f)
L_frf(i, :, :) = squeeze(G_dL{3}(i,:,:))*freqresp(Khac_iff_struts, f(i), 'Hz');
2021-07-01 17:45:57 +02:00
end
colors = colororder;
freqs = 2*logspace(1, 3, 1000);
figure;
tiledlayout(3, 1, 'TileSpacing', 'None', 'Padding', 'None');
ax1 = nexttile([2,1]);
hold on;
% Diagonal Elements FRF
plot(f, abs(L_frf(:,1,1)), 'color', colors(1,:), ...
'DisplayName', 'Diagonal');
for i = 2:6
plot(f, abs(L_frf(:,i,i)), 'color', colors(1,:), ...
'HandleVisibility', 'off');
end
plot(f, abs(L_frf(:,1,2)), 'color', [colors(2,:), 0.2], ...
'DisplayName', 'Off-Diag');
for i = 1:5
for j = i+1:6
plot(f, abs(L_frf(:,i,j)), 'color', [colors(2,:), 0.2], ...
'HandleVisibility', 'off');
end
end
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Loop Gain [-]'); set(gca, 'XTickLabel',[]);
ylim([1e-3, 1e2]);
legend('location', 'northeast');
grid;
ax2 = nexttile;
hold on;
for i =1:6
plot(f, 180/pi*angle(L_frf(:,i,i)), 'color', colors(1,:));
end
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'lin');
xlabel('Frequency [Hz]'); ylabel('Phase [deg]');
hold off;
yticks(-360:90:360);
ylim([-180, 180]);
grid;
linkaxes([ax1,ax2],'x');
xlim([1, 2e3]);