[major changes] Add some control on the system

Add many scripts to:
- define all the inputs for various experiments
- plot the time and frequency data
- identify the plant
This commit is contained in:
Thomas Dehaeze
2018-06-07 18:27:02 +02:00
parent 1335f23dc5
commit 5587309cfa
23 changed files with 309 additions and 12 deletions

View File

@@ -0,0 +1,71 @@
%% Load open loop data
gm_ol = load('../data/ground_motion_001.mat');
%%
Dmeas.Data = Dmeas.Data - Dmeas.Data(1, :);
%% Time domain X-Y-Z
figure;
hold on;
plot(Dmeas.Time, Dmeas.Data(:, 1));
plot(Dmeas.Time, Dmeas.Data(:, 2));
plot(Dmeas.Time, Dmeas.Data(:, 3));
legend({'x', 'y', 'z'})
hold off;
xlabel('Time [s]'); ylabel('Displacement [m]');
exportFig('tomo_time_translations', 'normal-normal')
%% Time domain angles
figure;
hold on;
plot(Dmeas.Time, Dmeas.Data(:, 4));
plot(Dmeas.Time, Dmeas.Data(:, 5));
plot(Dmeas.Time, Dmeas.Data(:, 6));
legend({'$\theta_x$', '$\theta_y$', '$\theta_z$'})
hold off;
xlabel('Time [s]'); ylabel('Displacement [m]');
exportFig('tomo_time_rotations', 'normal-normal')
%% PSD X-Y-Z
han_windows = hanning(ceil(length(Dmeas.Time)/10));
[psd_x, freqs_x] = pwelch(Dmeas.Data(:, 1), han_windows, 0, [], 1/Ts);
[psd_y, freqs_y] = pwelch(Dmeas.Data(:, 2), han_windows, 0, [], 1/Ts);
[psd_z, freqs_z] = pwelch(Dmeas.Data(:, 3), han_windows, 0, [], 1/Ts);
figure;
hold on;
plot(freqs_x, sqrt(psd_x));
plot(freqs_y, sqrt(psd_y));
plot(freqs_z, sqrt(psd_z));
set(gca,'xscale','log'); set(gca,'yscale','log');
xlabel('Frequency [Hz]'); ylabel('PSD [$m/\sqrt{Hz}$]');
legend({'x', 'y', 'z'})
hold off;
exportFig('tomo_psd_translations', 'normal-normal')
%% PSD X-Y-Z
han_windows = hanning(ceil(length(Dmeas.Time)/10));
[psd_x, freqs_x] = pwelch(Dmeas.Data(:, 4), han_windows, 0, [], 1/Ts);
[psd_y, freqs_y] = pwelch(Dmeas.Data(:, 5), han_windows, 0, [], 1/Ts);
[psd_z, freqs_z] = pwelch(Dmeas.Data(:, 6), han_windows, 0, [], 1/Ts);
figure;
hold on;
plot(freqs_x, sqrt(psd_x));
plot(freqs_y, sqrt(psd_y));
plot(freqs_z, sqrt(psd_z));
set(gca,'xscale','log'); set(gca,'yscale','log');
xlabel('Frequency [Hz]'); ylabel('PSD [$rad/s/\sqrt{Hz}$]');
legend({'$\theta_x$', '$\theta_y$', '$\theta_z$'})
hold off;
exportFig('tomo_psd_rotations', 'normal-normal')
%%
save('../data/ground_motion.mat', 'Dmeas')

View File

@@ -0,0 +1,33 @@
gm_ol = load('../data/ground_motion_ol.mat', 'Dmeas');
gm_cl = load('../data/ground_motion_001.mat', 'Dmeas');
%% Compare OL and CL - Time
figure;
hold on;
plot(gm_ol.Dmeas.Time, gm_ol.Dmeas.Data(:, 2));
plot(gm_cl.Dmeas.Time, gm_cl.Dmeas.Data(:, 2));
legend({'y - OL', 'y - CL'})
hold off;
xlabel('Time [s]'); ylabel('Displacement [m]');
exportFig('gm_control_time_y', 'normal-normal')
%% Compare OL and CL - PSD
han_windows_ol = hanning(ceil(length(gm_ol.Dmeas.Time)/10));
[psd_y_ol, freqs_y_ol] = pwelch(gm_ol.Dmeas.Data(:, 2), han_windows, 0, [], 1/Ts);
han_windows = hanning(ceil(length(gm_cl.Dmeas.Time)/10));
[psd_y, freqs_y] = pwelch(gm_cl.Dmeas.Data(:, 2), han_windows, 0, [], 1/Ts);
figure;
hold on;
plot(freqs_y_ol, sqrt(psd_y_ol));
plot(freqs_y, sqrt(psd_y));
set(gca,'xscale','log'); set(gca,'yscale','log');
xlabel('Frequency [Hz]'); ylabel('PSD [$m/\sqrt{Hz}$]');
legend({'y - OL', 'y - CL'})
hold off;
exportFig('gm_control_psd_y', 'normal-normal')

View File

@@ -0,0 +1,65 @@
%%
Dmeas.Data = Dmeas.Data - Dmeas.Data(1, :);
%% Time domain X-Y-Z
figure;
hold on;
plot(Dmeas.Time, Dmeas.Data(:, 1));
plot(Dmeas.Time, Dmeas.Data(:, 2));
plot(Dmeas.Time, Dmeas.Data(:, 3));
legend({'x', 'y', 'z'})
hold off;
xlabel('Time [s]'); ylabel('Displacement [m]');
exportFig('tomo_time_translations', 'normal-normal')
%% Time domain angles
figure;
hold on;
plot(Dmeas.Time, Dmeas.Data(:, 4));
plot(Dmeas.Time, Dmeas.Data(:, 5));
legend({'$\theta_x$', '$\theta_y$'})
hold off;
xlabel('Time [s]'); ylabel('Displacement [m]');
exportFig('tomo_time_rotations', 'normal-normal')
%% PSD X-Y-Z
han_windows = hanning(ceil(length(Dmeas.Time)/10));
[psd_x, freqs_x] = pwelch(Dmeas.Data(:, 1), han_windows, 0, [], 1/Ts);
[psd_y, freqs_y] = pwelch(Dmeas.Data(:, 2), han_windows, 0, [], 1/Ts);
[psd_z, freqs_z] = pwelch(Dmeas.Data(:, 3), han_windows, 0, [], 1/Ts);
figure;
hold on;
plot(freqs_x, sqrt(psd_x));
plot(freqs_y, sqrt(psd_y));
plot(freqs_z, sqrt(psd_z));
set(gca,'xscale','log'); set(gca,'yscale','log');
xlabel('Frequency [Hz]'); ylabel('PSD [$m/\sqrt{Hz}$]');
legend({'x', 'y', 'z'})
hold off;
exportFig('tomo_psd_translations', 'normal-normal')
%% PSD X-Y-Z
han_windows = hanning(ceil(length(Dmeas.Time)/10));
[psd_x, freqs_x] = pwelch(Dmeas.Data(:, 4), han_windows, 0, [], 1/Ts);
[psd_y, freqs_y] = pwelch(Dmeas.Data(:, 5), han_windows, 0, [], 1/Ts);
figure;
hold on;
plot(freqs_x, sqrt(psd_x));
plot(freqs_y, sqrt(psd_y));
set(gca,'xscale','log'); set(gca,'yscale','log');
xlabel('Frequency [Hz]'); ylabel('PSD [$rad/s/\sqrt{Hz}$]');
legend({'$\theta_x$', '$\theta_y$'})
hold off;
exportFig('tomo_psd_rotations', 'normal-normal')
%%
save('../data/tomography_exp_ol.mat', 'Dmeas')

View File

@@ -0,0 +1,32 @@
tomo_ol = load('../data/tomography_exp_ol.mat', 'Dmeas');
tomo_cl = load('../data/tomography_exp_001.mat', 'Dmeas');
%% Compare OL and CL - Time
figure;
hold on;
plot(tomo_ol.Dmeas.Time, tomo_ol.Dmeas.Data(:, 2));
plot(tomo_cl.Dmeas.Time, tomo_cl.Dmeas.Data(:, 2));
legend({'y - OL', 'y - CL'})
hold off;
xlabel('Time [s]'); ylabel('Displacement [m]');
exportFig('tomo_control_time_y', 'normal-normal')
%% Compare OL and CL - PSD
han_windows_ol = hanning(ceil(length(tomo_ol.Dmeas.Time)/10));
[psd_y_ol, freqs_y_ol] = pwelch(tomo_ol.Dmeas.Data(:, 2), han_windows, 0, [], 1/Ts);
han_windows = hanning(ceil(length(tomo_cl.Dmeas.Time)/10));
[psd_y, freqs_y] = pwelch(tomo_cl.Dmeas.Data(:, 2), han_windows, 0, [], 1/Ts);
figure;
hold on;
plot(freqs_y_ol, sqrt(psd_y_ol));
plot(freqs_y, sqrt(psd_y));
set(gca,'xscale','log'); set(gca,'yscale','log');
xlabel('Frequency [Hz]'); ylabel('PSD [$m/\sqrt{Hz}$]');
legend({'y - OL', 'y - CL'})
hold off;
exportFig('tomo_control_psd_y', 'normal-normal')