Newer
Older
leprob001
committed
function [positions, clockError] = SingleSource(pData, pSoundsourcePositions, pCombinationDetails, pStartEndPosition)
%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.
leprob001
committed
% pStartEndPosition (double, logical):
% Set to false if it has not been passed by artoa. Contains the
% desired start and end position as a matrix of row vectors.
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
%
%
% 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]