% Plotting and averaging data from various conditions for the VN-100S

%% Read in data
load('\\atlas\ProjectLibrary\CPF\CharlieWatkins\VectorNav VN-100s IMU\Data\Jun18Test\motorOff1RPM\motorOff1RPM.mat');
motorOff1RPM = yba;
clear('yba');
motorOff1RPM.linAccBody = double(motorOff1RPM.linAccBody);

load('\\atlas\ProjectLibrary\CPF\CharlieWatkins\VectorNav VN-100s IMU\Data\Jun18Test\motorOn\motorOn.mat');
motorOn = yba;
clear('yba');
motorOn.linAccBody = double(motorOn.linAccBody);

load('\\atlas\ProjectLibrary\CPF\CharlieWatkins\VectorNav VN-100s IMU\Data\Jun18Test\motor1RPM\motor1RPM.mat');
motor1RPM = yba;
clear('yba');
motor1RPM.linAccBody = double(motor1RPM.linAccBody);

load('\\atlas\ProjectLibrary\CPF\CharlieWatkins\VectorNav VN-100s IMU\Data\Jun18Test\motor3RPM\motor3RPM.mat');
motor3RPM = yba;
clear('yba');
motor3RPM.linAccBody = double(motor3RPM.linAccBody);

% load('\\atlas\ProjectLibrary\CPF\CharlieWatkins\VectorNav VN-100s IMU\Data\Jun17Test2\motor1RPMOffset\motor1RPMOffset.mat');
% motor1RPMOffset = yba;
% clear('yba');

%% Plot data
t = 0:.01:(length(motorOff1RPM.linAccBody)-1)/100.0;
subplot(5,1,1);
plot(t,motorOff1RPM.linAccBody(:,1));
title('x acceleration with motor off then at 1 RPM');
xlabel('Time (s)');
ylabel('Acceleration (m/s^2)');
axis([0 inf -0.4 0.4]);
grid;

t = 0:.01:(length(motorOn.linAccBody)-1)/100.0;
subplot(5,1,2);
plot(t,motorOn.linAccBody(:,1));
title('x acceleration with motor holding (m/s^2)');
xlabel('Time (s)');
ylabel('Acceleration (m/s^2)');
axis([0 inf -0.4 0.4]);
grid;

t = 0:.01:(length(motor1RPM.linAccBody)-1)/100.0;
subplot(5,1,3);
plot(t,motor1RPM.linAccBody(:,1));
title('x acceleration with motor at 1 RPM (m/s^2)');
xlabel('Time (s)');
ylabel('Acceleration (m/s^2)');
axis([0 inf -0.4 0.4]);
grid;

t = 0:.01:(length(motor3RPM.linAccBody)-1)/100.0;
subplot(5,1,4);
plot(t,motor3RPM.linAccBody(:,1));
title('x acceleration with motor at 3 RPM (m/s^2)');
xlabel('Time (s)');
ylabel('Acceleration (m/s^2)');
axis([0 inf -0.4 0.4]);
grid;

%% Print average values
% fprintf('All data sets collected over roughly 5 minute intervals\n');
% 
% fprintf('Motor off then 1 RPM, mean x accel: %f m/s^2\n', mean(motorOff1RPM.linAccBody(:,1)));
% 
% fprintf('Motor on, mean x accel: %f m/s^2\n', mean(motorOn.linAccBody(:,1)));
% 
% fprintf('Motor at 1 RPM, mean x accel: %f m/s^2\n', mean(motor1RPM.linAccBody(:,1)));
% 
% fprintf('Motor at 3 RPM, mean x accel: %f m/s^2\n', mean(motor3RPM.linAccBody(:,1)));

% fprintf('Motor at 1 RPM with IMU offset, mean x accel: %f m/s^2\n', mean(motor1RPMOffset.linAccBody(:,1)));
