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

Plugin method for single source tracking has been added.

It cannot be used yet, it only calculates the average speed in m/s of all
distances available.
parent 85ee7980
No related branches found
No related tags found
No related merge requests found
186
\ No newline at end of file
187
\ No newline at end of file
function [positions, clockError] = SingleSource(pData, pSoundsourcePositions, pCombinationDetails)
%SINGLESOURCE Implements the single source tracking algorithm
%
% Parameters:
% pData (struct):
% Data structured by soundsource. The toa is already corrected
% (e.g. doppler correction etc.)
% pSoundsourcePositions (struct):
% The soundsource positions [deg].
% pCombinationDetails (table):
% Contains all information of the current soundsource
% combination.
%
%
% Returns:
% positions (double):
% The calculated list of segment positions as a X x 2 column vector.
% clockError (double):
% The estimated clock error.
%% Get reference position and all soundsource names that are involved
referencePosition = cellfun(@str2double, strsplit(pCombinationDetails.referencePosition{1}));
soundsourceNames = strsplit(pCombinationDetails.soundsources{1});
%% Check if only one sound source is selected
if length(soundsourceNames) ~= 1 || isempty(soundsourceNames)
error('Only one or at least one soundsource requires to be specified for SingleSource tracking!');
end
%% Get required data for single source tracking
pData.(soundsourceNames{1}).horizontalVelocity = ...
[ ...
NaN; ...
calculateHorizontalVelocity( ...
[pData.(soundsourceNames{1}).date{:}]', ...
[pData.(soundsourceNames{1}).distance{:}]' ...
) ...
];
averageHorizontalVelocity = mean( ...
pData.(soundsourceNames{1}).horizontalVelocity( ...
~isnan(pData.(soundsourceNames{1}).horizontalVelocity) ...
) ...
);
%% Return NaN because this is a sample
positions = NaN(size(pData.(soundsourceNames{1}).date, 1), 2);
clockError = [];
error('Tracking method implementation not finished yet!');
%% Helper functions
function [hvel] = calculateHorizontalVelocity(dates, distances)
% calculate the average speed in m/s
% distances are stored in km
% dates as rafos dates
diffDistances = diff(distances) / 1000; % now in [m]
diffDates = diff(dates) * 24 * 3600; % now in [s]
hvel = abs(diffDistances ./ diffDates);
end
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