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

fix(sync)!: improve starting point of tunnel data

parent 9720e014
No related branches found
No related tags found
No related merge requests found
......@@ -81,7 +81,7 @@ function [startIdx, startTime] = getstartardu(arduData)
% Get a first approximation for the starting point of each wing set
startIdx = [NaN, NaN];
for i = 1:2
startIdx(i) = findsignalstart(arduData(:, ANGLE_IDX(i)), N_STABLE_VAL, DCRIT);
startIdx(i) = findsignalstart(arduData(:, ANGLE_IDX(i)), N_STABLE_VAL, 'ardu', DCRIT);
end
startIdx = min(startIdx);
startTime = arduData(startIdx, 1);
......@@ -101,21 +101,21 @@ function [startIdx, startTime] = getstarttunnel(tunnelData)
startIdx = [NaN, NaN];
for i = 1:2
startIdx(i) = findsignalstart(tunnelData(:, FZ_IDX(i)), SAMPLING / 2, DCRIT);
startIdx(i) = findsignalstart(tunnelData(:, FZ_IDX(i)), SAMPLING / 2, 'tunnel', DCRIT);
end
startIdx = TRIM_MS + min(startIdx);
startTime = startIdx / SAMPLING;
end
function startIdx = findsignalstart(signal, stableIdx, fixCrit)
function startIdx = findsignalstart(signal, stableIdx, type, fixCrit)
% FINDSIGNALSTART Find start of motion by looking at deviations from a 'stable' signal
% Constants and defaults
LARGE_DEV_STD = 10; % Multiplier of std to be considered 'large deviation'
DEBUG = false;
if nargin < 3
if nargin < 4
fixCrit = 0;
end
......@@ -133,6 +133,12 @@ function startIdx = findsignalstart(signal, stableIdx, fixCrit)
inflexPts = find([0; diff(sign(dSignal))] ~= 0); % Zeros to get idx in signal and not dSignal
startIdx = inflexPts(end);
% For WT, the start is not the last extremum, but the last minimum in the derivate
if strcmp(type, 'tunnel')
[~, newIdx] = min(meanDev(startIdx:largeDevIdx(1)));
startIdx = (startIdx - 1) + newIdx;
end
if DEBUG
cutoff = ones(size(signal)) * devCrit;
figure;
......
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