Skip to content
Snippets Groups Projects
Commit 881b741f authored by leprob001's avatar leprob001
Browse files

Added a new column to the tracking parameter panel ReferencePositionEnd....

Added a new column to the tracking parameter panel ReferencePositionEnd. Adjusted the tracking algorithms accordingly.
parent 3d55ec71
No related branches found
No related tags found
No related merge requests found
273 274
\ No newline at end of file \ No newline at end of file
...@@ -8,6 +8,7 @@ variableNames = { ... ...@@ -8,6 +8,7 @@ variableNames = { ...
'combinationEnd', ... 'combinationEnd', ...
'soundsources', ... 'soundsources', ...
'referencePosition', ... 'referencePosition', ...
'referencePositionEnd', ...
'soundspeed1', ... 'soundspeed1', ...
'soundspeed2', ... 'soundspeed2', ...
'soundspeed3', ... 'soundspeed3', ...
......
...@@ -19,6 +19,7 @@ emptyCell = { ... ...@@ -19,6 +19,7 @@ emptyCell = { ...
endDate, ... endDate, ...
'', ... '', ...
referencePosition, ... referencePosition, ...
'', ...
1464, ... 1464, ...
1464, ... 1464, ...
1464, ... 1464, ...
......
...@@ -35,7 +35,8 @@ for i = 1:length(fieldNames) ...@@ -35,7 +35,8 @@ for i = 1:length(fieldNames)
end end
end end
if ~isnan(artoa.data.getMember(artoaWorkspace, {'trajectoryOutput', 'tableGeneratedTracksSelectedRow'}, NaN)) if ~isnan(artoa.data.getMember(artoaWorkspace, {'trajectoryOutput', 'tableGeneratedTracksSelectedRow'}, NaN)) ...
& ~isempty(artoaWorkspace.trajectoryOutput.trajectories)
artoa.controller.track.parameter.adjustTableColorsToTrajectory( ... artoa.controller.track.parameter.adjustTableColorsToTrajectory( ...
artoaWorkspace.trajectoryOutput.trajectories{artoaWorkspace.trajectoryOutput.tableGeneratedTracksSelectedRow} ... artoaWorkspace.trajectoryOutput.trajectories{artoaWorkspace.trajectoryOutput.tableGeneratedTracksSelectedRow} ...
); );
......
...@@ -34,55 +34,7 @@ if any(isempty(pCombinationsTable.trackingMethod)) ... ...@@ -34,55 +34,7 @@ if any(isempty(pCombinationsTable.trackingMethod)) ...
return; return;
end end
%% Check if interpolation method has been chosen
isInterpolationMethod = artoa.trajectory.isInterpolationMethod(pCombinationsTable.trackingMethod);
if sum(isInterpolationMethod) > 1
success = false;
message = 'Using more than one interpolation method is not supported!';
return;
end
if isInterpolationMethod(end) | isInterpolationMethod(1)
success = false;
message = 'The first or last tracking method must not be an interpolation method!';
return;
end
if sum(~isInterpolationMethod) < 2 & sum(isInterpolationMethod) > 1
success = false;
message = 'You require at least two tracking methods that surround an interpolation method!';
return;
end
if any(diff(find(isInterpolationMethod)) == 1)
% there are two interpolation methods after each other
success = false;
message = 'There are two interpolation methods connected. The trajectory cannot be calculated!';
return;
end
%% Check if the backward tracking is correct
backwardTracking = pCombinationsTable.backwardTracking;
if backwardTracking(1) & ~all(backwardTracking)
success = false;
message = 'If the first combination is to be tracked backwards, all combinations must be set as backward tracking!';
return;
end
if any(diff(backwardTracking) < 0)
success = false;
message = 'It is not possible to mix backward and forward tracking!';
return;
end
%% Check if there are interpolations methods used but no backward tracking
if sum(isInterpolationMethod) > 0 & ~any(backwardTracking)
success = false;
message = 'It is not possible to use an interpolation method without backward tracking!';
return;
end
success = true; success = true;
......
...@@ -30,169 +30,18 @@ for i = 1:size(soundVelocity, 1) ...@@ -30,169 +30,18 @@ for i = 1:size(soundVelocity, 1)
end end
end end
%% Get required variables %% Calculate trajectory
isInterpolationMethod = artoa.trajectory.isInterpolationMethod(artoaWorkspace.trackParameter.soundsourceCombinations.trackingMethod); [ ...
backwardTracking = artoaWorkspace.trackParameter.soundsourceCombinations.backwardTracking; trajectory, ...
trajectoryDates, ...
trajectoryClockError, ...
trajectoryResiduals, ...
trajectoryVelocities, ...
trajectoryTimeDivergenceToGps, ...
trajectorySegmentSize, ...
trajectoryVariationResults ...
] = calculateTrajectoryWithTrackParameter(artoaWorkspace.trackParameter, false);
%% Find all forward combinations
firstBackwardIndex = find(backwardTracking);
if any(diff(backwardTracking) ~= 0)
% there are at least both, forward and backward tracking methods
% first calculate all forward tracks
trackParameter = artoaWorkspace.trackParameter;
if sum(isInterpolationMethod) == 1
interpolationIndex = find(isInterpolationMethod);
else
interpolationIndex = firstBackwardIndex;
end
trackParameter.soundsourceCombinations = artoaWorkspace.trackParameter.soundsourceCombinations(1:interpolationIndex - 1, :);
[ ...
trajectory, ...
trajectoryDates, ...
trajectoryClockError, ...
trajectoryResiduals, ...
trajectoryVelocities, ...
trajectoryTimeDivergenceToGps, ...
trajectorySegmentSize, ...
trajectoryVariationResults ...
] = calculateTrajectoryWithTrackParameter(trackParameter, false);
% calculate all backward tracks then
trackParameter.soundsourceCombinations = artoaWorkspace.trackParameter.soundsourceCombinations(firstBackwardIndex:end, :);
[ ...
backwardTrajectory, ...
backwardTrajectoryDates, ...
backwardTrajectoryClockError, ...
backwardTrajectoryResiduals, ...
backwardTrajectoryVelocities, ...
backwardTrajectoryTimeDivergenceToGps, ...
backwardTrajectorySegmentSize, ...
backwardTrajectoryVariationResults ...
] = calculateTrajectoryWithTrackParameter(trackParameter, false);
% calculate the interpolation method
if sum(isInterpolationMethod) == 1 ...
& ~isempty(backwardTrajectory) & ~any(isnan(backwardTrajectory(1, :))) ...
& ~isempty(trajectory) & ~any(isnan(trajectory(end, :)))
trackParameter.soundsourceCombinations = artoaWorkspace.trackParameter.soundsourceCombinations(find(isInterpolationMethod), :);
startEndPosition = [ ...
trajectory(end, :);
backwardTrajectory(1, :)
];
[interpolatedTrajectory, ~] = artoa.plugins.tracking.callTrackingMethod( ...
trackParameter.soundsourceCombinations.trackingMethod{1}, ...
struct( ...
'combinationBegin', trackParameter.soundsourceCombinations.combinationBegin, ...
'combinationEnd', trackParameter.soundsourceCombinations.combinationEnd ...
), ...
false, ...
false, ...
startEndPosition ...
);
interpolatedTrajectoryDates = [trackParameter.soundsourceCombinations.combinationBegin:1:trackParameter.soundsourceCombinations.combinationEnd-1]';
interpolatedTrajectoryClockError = NaN(size(interpolatedTrajectoryDates));
interpolatedTrajectoryResiduals = trajectoryResiduals;
interpolatedTrajectoryResiduals = structfun(@(x) NaN(size(interpolatedTrajectoryDates)), interpolatedTrajectoryResiduals, 'UniformOutput', false);
interpolatedTrajectoryVelocities = trajectoryVelocities;
interpolatedTrajectoryVelocities = structfun(@(x) NaN(size(interpolatedTrajectoryDates)), interpolatedTrajectoryVelocities, 'UniformOutput', false);
interpolatedTrajectoryTimeDivergenceToGps = trajectoryTimeDivergenceToGps;
interpolatedTrajectoryTimeDivergenceToGps = structfun(@(x) NaN(size(interpolatedTrajectoryDates, 1), size(x, 2)), interpolatedTrajectoryTimeDivergenceToGps, 'UniformOutput', false);
interpolatedTrajectorySegmentSize = length(interpolatedTrajectoryDates);
interpolatedTrajectoryVariationResults = {};
% [ ...
% interpolatedTrajectory, ...
% interpolatedTrajectoryDates, ...
% interpolatedTrajectoryClockError, ...
% interpolatedTrajectoryResiduals, ...
% interpolatedTrajectoryVelocities, ...
% interpolatedTrajectoryTimeDivergenceToGps, ...
% interpolatedTrajectorySegmentSize, ...
% interpolatedTrajectoryVariationResults ...
% ] = calculateTrajectoryWithTrackParameter(trackParameter, startEndPosition);
else
interpolatedTrajectorySegmentSize = 0;
end
% merge all segments
if interpolatedTrajectorySegmentSize > 0
trajectory = [trajectory; interpolatedTrajectory; backwardTrajectory];
trajectoryDates = [ trajectoryDates; interpolatedTrajectoryDates; backwardTrajectoryDates];
trajectoryClockError = [ trajectoryClockError; interpolatedTrajectoryClockError; backwardTrajectoryClockError];
trajectorySegmentSize = [trajectorySegmentSize; interpolatedTrajectorySegmentSize; backwardTrajectorySegmentSize];
trajectoryVariationResults = [trajectoryVariationResults, interpolatedTrajectoryVariationResults, backwardTrajectoryVariationResults];
else
trajectory = [trajectory; backwardTrajectory];
trajectoryDates = [ trajectoryDates; backwardTrajectoryDates];
trajectoryClockError = [ trajectoryClockError; backwardTrajectoryClockError];
trajectorySegmentSize = [trajectorySegmentSize; backwardTrajectorySegmentSize];
trajectoryVariationResults = [trajectoryVariationResults, backwardTrajectoryVariationResults];
end
% merge structs
if interpolatedTrajectorySegmentSize == 0
trajectoryResiduals = cell2struct( ...
cellfun( ...
@vertcat, ...
struct2cell(trajectoryResiduals), ...
struct2cell(backwardTrajectoryResiduals), ...
'uni', 0), ...
fieldnames(trajectoryResiduals), ...
1);
trajectoryVelocities = cell2struct( ...
cellfun( ...
@vertcat, ...
struct2cell(trajectoryVelocities), ...
struct2cell(backwardTrajectoryVelocities), ...
'uni', 0), ...
fieldnames(trajectoryVelocities), ...
1);
trajectoryTimeDivergenceToGps = cell2struct( ...
cellfun( ...
@vertcat, ...
struct2cell(trajectoryTimeDivergenceToGps), ...
struct2cell(backwardTrajectoryTimeDivergenceToGps), ...
'uni', 0), ...
fieldnames(trajectoryTimeDivergenceToGps), ...
1);
else
trajectoryResiduals = cell2struct( ...
cellfun( ...
@vertcat, ...
struct2cell(trajectoryResiduals), ...
struct2cell(interpolatedTrajectoryResiduals), ...
struct2cell(backwardTrajectoryResiduals), ...
'uni', 0), ...
fieldnames(trajectoryResiduals), ...
1);
trajectoryVelocities = cell2struct( ...
cellfun( ...
@vertcat, ...
struct2cell(trajectoryVelocities), ...
struct2cell(interpolatedTrajectoryVelocities), ...
struct2cell(backwardTrajectoryVelocities), ...
'uni', 0), ...
fieldnames(trajectoryVelocities), ...
1);
trajectoryTimeDivergenceToGps = cell2struct( ...
cellfun( ...
@vertcat, ...
struct2cell(trajectoryTimeDivergenceToGps), ...
struct2cell(interpolatedTrajectoryTimeDivergenceToGps), ...
struct2cell(backwardTrajectoryTimeDivergenceToGps), ...
'uni', 0), ...
fieldnames(trajectoryTimeDivergenceToGps), ...
1);
end
else
[ ...
trajectory, ...
trajectoryDates, ...
trajectoryClockError, ...
trajectoryResiduals, ...
trajectoryVelocities, ...
trajectoryTimeDivergenceToGps, ...
trajectorySegmentSize, ...
trajectoryVariationResults ...
] = calculateTrajectoryWithTrackParameter(artoaWorkspace.trackParameter, false);
end
%% Setup trajectory object %% Setup trajectory object
trajectoryObject = struct(); trajectoryObject = struct();
......
...@@ -436,7 +436,8 @@ columns = { ... ...@@ -436,7 +436,8 @@ columns = { ...
'Begin', ... 'Begin', ...
'End', ... 'End', ...
'<html>Sound<br>Sources', ... '<html>Sound<br>Sources', ...
'<html>Reference<br>Position', ... '<html>Reference<br>Position Start', ...
'<html>Segment<br>Position End', ...
'<html>Sound<br>Speed', '<html>Sound<br>Speed', '<html>Sound<br>Speed', ... '<html>Sound<br>Speed', '<html>Sound<br>Speed', '<html>Sound<br>Speed', ...
'<html>Tracking<br>Method', ... '<html>Tracking<br>Method', ...
'<html>Backward<br>Tracking' ... '<html>Backward<br>Tracking' ...
......
...@@ -38,12 +38,6 @@ if ~exist('pStartEndPosition', 'var') ...@@ -38,12 +38,6 @@ if ~exist('pStartEndPosition', 'var')
end end
%% Flip soundsource combination table if required %% Flip soundsource combination table if required
if all(pTrackingParameter.soundsourceCombinations.backwardTracking)
pTrackingParameter.soundsourceCombinations = flipud(pTrackingParameter.soundsourceCombinations);
%tmp = pTrackingParameter.soundsourceCombinations.combinationBegin;
%pTrackingParameter.soundsourceCombinations.combinationBegin = pTrackingParameter.soundsourceCombinations.combinationEnd;
%pTrackingParameter.soundsourceCombinations.combinationEnd = tmp;
end
%% Get required data %% Get required data
soundsourceCombinations = pTrackingParameter.soundsourceCombinations; soundsourceCombinations = pTrackingParameter.soundsourceCombinations;
...@@ -249,7 +243,8 @@ for oCombination = 1:size(soundsourceCombinations, 1) ...@@ -249,7 +243,8 @@ for oCombination = 1:size(soundsourceCombinations, 1)
&& islogical(pStartEndPosition) && islogical(pStartEndPosition)
return; return;
elseif isempty(currentCombination.referencePosition{1}) ... elseif isempty(currentCombination.referencePosition{1}) ...
& ~artoa.trajectory.isInterpolationMethod(currentCombination.trackingMethod{1}) & ~artoa.trajectory.isInterpolationMethod(currentCombination.trackingMethod{1}) ...
& ~currentCombination.backwardTracking(1)
currentCombination.referencePosition{1} = num2str(trajectory(end, :)); currentCombination.referencePosition{1} = num2str(trajectory(end, :));
end end
......
...@@ -135,6 +135,18 @@ if pBackwardTracking ...@@ -135,6 +135,18 @@ if pBackwardTracking
for i = 1:length(soundsourceNames) for i = 1:length(soundsourceNames)
pluginTables.(soundsourceNames{i}) = flipud(pluginTables.(soundsourceNames{i})); pluginTables.(soundsourceNames{i}) = flipud(pluginTables.(soundsourceNames{i}));
end end
pCombinationDetails.referencePosition{1} = pCombinationDetails.referencePositionEnd{1};
end
if artoa.trajectory.isInterpolationMethod(pCombinationDetails.trackingMethod{1})
pStartEndPosition = [ ...
str2double(strsplit(pCombinationDetails.referencePosition{1}, ' ')); ...
str2double(strsplit(pCombinationDetails.referencePositionEnd{1}, ' ')) ...
];
pluginTables = struct( ...
'combinationBegin', pCombinationDetails.combinationBegin, ...
'combinationEnd', pCombinationDetails.combinationEnd ...
);
end end
%% Call the corresponding tracking method from the plugin folder %% Call the corresponding tracking method from the plugin folder
...@@ -155,12 +167,24 @@ if pBackwardTracking ...@@ -155,12 +167,24 @@ if pBackwardTracking
end end
%% Store toa dates %% Store toa dates
segmentDates = intersectedToaDates; if artoa.trajectory.isInterpolationMethod(pCombinationDetails.trackingMethod{1})
segmentDates = [pCombinationDetails.combinationBegin:1:pCombinationDetails.combinationEnd]';
else
segmentDates = intersectedToaDates;
end
%% Calculate residuals %% Calculate residuals
% initalize variables % initalize variables
segmentResiduals = struct(); segmentResiduals = struct();
if artoa.trajectory.isInterpolationMethod(pCombinationDetails.trackingMethod{1})
for i = 1:length(soundsourceNames)
segmentResiduals.(soundsourceNames{i}) = NaN(length(segmentDates), 1);
end
return;
end
for i = 1:length(soundsourceNames) for i = 1:length(soundsourceNames)
segmentResiduals.(soundsourceNames{i}) = []; segmentResiduals.(soundsourceNames{i}) = [];
end end
......
%% Add variable reference position end to the tracking parameter panel
if artoa.data.hasMember(artoaWorkspace, 'trackParameter', 'soundsourceCombinations') ...
& ~any(strcmp(artoaWorkspace.trackParameter.soundsourceCombinations.Properties.VariableNames, 'referencePositionEnd'))
artoaWorkspace.trackParameter.soundsourceCombinations = ...
addvars( ...
artoaWorkspace.trackParameter.soundsourceCombinations, ...
addReferencePositionEnd4274(length(artoaWorkspace.trackParameter.soundsourceCombinations.combinationBegin)), ...
'After', 4 ...
);
artoaWorkspace.trackParameter.soundsourceCombinations.Properties.VariableNames{5} = 'referencePositionEnd';
end
%% Helper functions
function emptyCell = addReferencePositionEnd4274(pLength)
emptyCell = repmat({''}, pLength, 1);
end
\ No newline at end of file
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