Skip to content
Snippets Groups Projects
Verified Commit 7c7d37b1 authored by Thomas Lambert's avatar Thomas Lambert :helicopter:
Browse files

refact: use mean angle for each module

parent b1bae618
No related branches found
No related tags found
No related merge requests found
...@@ -52,24 +52,26 @@ function ExpData = processall(idFile) ...@@ -52,24 +52,26 @@ function ExpData = processall(idFile)
ExpData(iTest).tunnelFile = idTable(iTest, :).wtFile{:}; ExpData(iTest).tunnelFile = idTable(iTest, :).wtFile{:};
% Load and clean experimental data % Load and clean experimental data
arduData = loadardu(ExpData(iTest).arduFile); [arduShort, arduFull] = loadardu(ExpData(iTest).arduFile);
tunnelData = loadtunnel(ExpData(iTest).tunnelFile, ... tunnelData = loadtunnel(ExpData(iTest).tunnelFile, ...
CUTOFF_MULTIPLIER * idTable(iTest, :).freq); CUTOFF_MULTIPLIER * idTable(iTest, :).freq);
% Sync the two data sources % Sync the two data sources
[arduData, tunnelData, ExpData(iTest).arduStart, ExpData(iTest).tunnelStart] = ... [arduShort, tunnelData, ExpData(iTest).arduStart, ExpData(iTest).tunnelStart] = ...
syncdata(arduData, tunnelData); syncdata(arduShort, tunnelData);
% Save the cleaned data % Save the cleaned data
% Split datasets between front and aft % Split datasets between front and aft
ExpData(iTest).front.arduData = arduData(:, [1:3, 6]); ExpData(iTest).front.arduFull = arduFull(:, [1:3, 6]);
ExpData(iTest).aft.arduData = arduData(:, [1, 4:5, 7]); ExpData(iTest).aft.arduFull = arduFull(:, [1, 4:5, 7]);
ExpData(iTest).front.arduShort = arduShort(:, [1:2, 4]);
ExpData(iTest).aft.arduShort = arduShort(:, [1, 3, 5]);
ExpData(iTest).front.tunnelData = tunnelData(:, 1:6); ExpData(iTest).front.tunnelData = tunnelData(:, 1:6);
ExpData(iTest).aft.tunnelData = tunnelData(:, 7:end); ExpData(iTest).aft.tunnelData = tunnelData(:, 7:end);
end
% [FIXME] A few plots just to check plottime(ExpData(iTest), 'arduShort', true);
plottime(ExpData(1), false);
end
end end
function [arduSynced, tunnelSynced, arduStart, tunnelStart] = syncdata(arduData, tunnelData) function [arduSynced, tunnelSynced, arduStart, tunnelStart] = syncdata(arduShort, tunnelData)
% SYNCDATA Synchronize datasets from the Arduio and the Wind Tunnel. % SYNCDATA Synchronize datasets from the Arduio and the Wind Tunnel.
% ----- % -----
% The acquisition of data is realized from two different sources on two different machines: % The acquisition of data is realized from two different sources on two different machines:
...@@ -35,7 +35,7 @@ function [arduSynced, tunnelSynced, arduStart, tunnelStart] = syncdata(arduData, ...@@ -35,7 +35,7 @@ function [arduSynced, tunnelSynced, arduStart, tunnelStart] = syncdata(arduData,
ENC_PRECISION = 12; % 12-bits encoders ENC_PRECISION = 12; % 12-bits encoders
ATI_RESOL = 1 / 80; % Resolution of ATI sensor in Z direction, [N]; ATI_RESOL = 1 / 80; % Resolution of ATI sensor in Z direction, [N];
CRIT_ARDU = 3; % Start when we have a change > 3 times the encoder resolution CRIT_ARDU = 3; % Start when we have a change > 3 times the encoder resolution
CRIT_WT = 3; % Start when we have a change > 2 the resolution CRIT_WT = 40; % Start when we have a change > 2 the resolution
% Abbreviations % Abbreviations
nbits = 2^ENC_PRECISION; nbits = 2^ENC_PRECISION;
...@@ -43,28 +43,28 @@ function [arduSynced, tunnelSynced, arduStart, tunnelStart] = syncdata(arduData, ...@@ -43,28 +43,28 @@ function [arduSynced, tunnelSynced, arduStart, tunnelStart] = syncdata(arduData,
critWtDiff = CRIT_WT * ATI_RESOL / WT_SAMPLING; % Criterion for the WT differential critWtDiff = CRIT_WT * ATI_RESOL / WT_SAMPLING; % Criterion for the WT differential
% Detect start of wing motion in Arduino and wind tunnel datasets % Detect start of wing motion in Arduino and wind tunnel datasets
arduStart = getstartardu(arduData, CRIT_ARDU * encRes); arduStart = getstartardu(arduShort, CRIT_ARDU * encRes);
tunnelStart = getstarttunnel(tunnelData, critWtDiff); % [FIXME] Should probably start later? tunnelStart = getstarttunnel(tunnelData, critWtDiff); % [FIXME] USE FINDPEAKS
% Trim everything before wing starts in both datasets % Trim everything before wing starts in both datasets
% arduData = arduData(arduStart:end, :); % arduData = arduData(arduStart:end, :);
% tunnelData = tunnelData(tunnelStart:end, :); % tunnelData = tunnelData(tunnelStart:end, :);
% Set both datasets time to 0 for the first element % Set both datasets time to 0 for the first element
arduData(:, 1) = arduData(:, 1) - arduData(1, 1); arduShort(:, 1) = arduShort(:, 1) - arduShort(1, 1);
% Interpolate arduino over wt time sampling % Interpolate arduino over wt time sampling
time = 0:1 / WT_SAMPLING:size(tunnelData, 1) / WT_SAMPLING; time = 0:1 / WT_SAMPLING:size(tunnelData, 1) / WT_SAMPLING;
dummy = interp1(arduData(:, 1) / 1000, arduData(:, 2:end), time); dummy = interp1(arduShort(:, 1), arduShort(:, 2:end), time);
arduData = [time', dummy]; arduShort = [time', dummy];
% Cut longests dataset % Cut longests dataset
maxTime = max(size(arduData, 1), size(tunnelData, 1)); maxTime = max(size(arduShort, 1), size(tunnelData, 1));
arduData(maxTime:end, :) = []; arduShort(maxTime:end, :) = [];
tunnelData(maxTime:end, :) = []; tunnelData(maxTime:end, :) = [];
% Assign output properly now that we are synced % Assign output properly now that we are synced
arduSynced = arduData; arduSynced = arduShort;
tunnelSynced = tunnelData; tunnelSynced = tunnelData;
% Trim first and lasts seconds of datasets (remove possible transient effects) % Trim first and lasts seconds of datasets (remove possible transient effects)
...@@ -80,8 +80,8 @@ end ...@@ -80,8 +80,8 @@ end
function startArdu = getstartardu(arduData, dCrit) function startArdu = getstartardu(arduData, dCrit)
% GETSTARTARDU Get the starting point for the arduino dataset % GETSTARTARDU Get the starting point for the arduino dataset
FRONT_IDX = 2:3; % Indexes of the front module angles FRONT_IDX = 2; % Indexes of the front module angles
AFT_IDX = 4:5; % Indexes of the aft module angles AFT_IDX = 3; % Indexes of the aft module angles
% Get the starting index of each set separately % Get the starting index of each set separately
startFront = (mean(findallstarts(arduData(:, FRONT_IDX), dCrit))); startFront = (mean(findallstarts(arduData(:, FRONT_IDX), dCrit)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment