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

feat(tunnel): add calibration Fx-My

parent c09683c6
No related branches found
No related tags found
No related merge requests found
......@@ -76,8 +76,8 @@ function calibrated = calibrate(raw)
% Proceed to calibration using the calibration data
if isempty(kF) || isempty(kA)
kF = 0; % [FIXME] Temporary placeholder
kA = 0; % [FIXME] Temporary placeholder
kF = findcalibslope('data/wtFiles/2022/calibration/calibFront_*', 'Fx', 'My');
kA = findcalibslope('data/wtFiles/2022/calibration/calibAft_*', 'Fx', 'My');
end
% Calibrate Fx by removing parasitic force due to My
......@@ -94,3 +94,49 @@ function filtered = filterwt(raw, cutoff, sampling)
% Apply filter
filtered = filtfilt(bb, aa, raw(:, :));
end
function slope = findcalibslope(files, force, moment)
% FINDCALIBSLOPE Find the linear coefficient for the calibration of parasitic effects
% Constants and defaults
FORCES = {'Fx', 'Fy', 'Fz'}; % Order of forces in datafile
MOMENTS = {'Mx', 'My', 'Mz'}; % Order of moments in datafile
% Get all relevant calibration files
allFiles = dir(files);
iForce = find(strcmp(force, FORCES));
iMom = find(strcmp(moment, MOMENTS));
% Get mean forces and moment for each calibration point
meanF = zeros(1, length(allFiles));
meanM = zeros(1, length(allFiles));
for iFile = 1:length(allFiles)
% Determine if we must look at front or aft data columns
if contains(allFiles(iFile).name, 'calibFront')
idx = 1;
elseif contains(allFiles(iFile).name, 'calibAft')
idx = 2;
else
error('loadtunnel:findcalibslope:undefinedCalibType', ...
'Calibration filename must contain either ''calibFront'' or ''calibAft''.');
end
% Load raw forces and moments
calibTable = loadcsv(fullfile(allFiles(iFile).folder, allFiles(iFile).name));
rawCalib = table2array(calibTable);
% Isolate proper data
rawF = rawCalib(:, 6 * (idx - 1) + iForce);
rawM = rawCalib(:, 6 * (idx - 1) + (3 + iMom));
meanF(iFile) = mean(rawF);
meanM(iFile) = mean(rawM);
end
% Slope is mean value of the individual slope between each calibration point
slope = mean(diff(meanF) ./ diff(meanM));
end
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