main content

object tracking using time difference of arrival (tdoa) -凯发k8网页登录

this example shows how to track objects using time difference of arrival (tdoa). this example introduces the challenges of localization with tdoa measurements as well as algorithms and techniques that can be used for tracking single and multiple objects with tdoa techniques.

introduction

tdoa positioning is a passive technique to localize and track emitting objects by exploiting the difference of signal arrival times at multiple, spatially-separated receivers. given a signal emission time (te) from the object and the propagation speed (c) in the medium, the time-of-arrival (toa) of the signal at 2 receivers located at ranges r1and r2 respectively from the object can be denoted as:

t1=te r1ct2=te r2c

as the true signal emission time is typically not known, a difference between t1and t2can be used to obtain some information about the location of an object. specifically, given the location of each receiver, the time-difference measurement corresponds to a difference in ranges from the two receivers to the unknown object.

(xt-x1)2 (yt-y1)2 (zt-z1)2-(xt-x2)2 (yt-y2)2 (zt-z2)2=c(t1-t2)

where [xtytzt] is the unknown object location, t1-t2 is the tdoa measurement, and [x1y1z1], [x2y2z2] are the locations of two receivers. this non-linear relationship between tdoa and object location represents a hyperbola in 2-d or a hyperboloid in 3-d coordinates with two receivers at the foci. the image below shows the hyperbolae of an object for different tdoa measurements (c = speed of light). these curves are typically called constant tdoa curves. notice that using the sign of a tdoa measurement, you can constrain the object location to a single branch of the hyperbola.

helpertdoatrackingexampledisplay.plotconstanttdoacurves;

figure contains an axes object. the axes object with xlabel x (km), ylabel y (km) contains 15 objects of type line, text. one or more of the lines displays its values using only markers

tdoa calculation

there are two primary methods used to calculate the tdoa measurement from the signal of an object. in the first method, each receiver measures the absolute time instant of signal arrival (time-of-arrival or toa) as defined by tiabove. a difference in time-of-arrivals between two receivers is then calculated to obtain the tdoa measurement. this method is applicable when certain signal attributes are known a-priori and the leading edge of the signal can be detected by the receiver.

tdoa12=toa2-toa1

in the second method, each receiver records and transmits the received signal to a shared processing hub. a cross-correlation between signals received from two receivers is calculated at the processing hub. the tdoa is estimated to be the delay which maximizes the cross-correlation between the two signals.

tdoa12=argmaxt[-tmaxtmax]([s1s2](t))

where [s1s2](t) represents the cross-correlation between the signals at receivers as a function of time delay, t. tmax is the maximum possible absolute delay and can be calculated as dc, where d is the distance between the receivers.

both methods of tdoa calculation require synchronized clocks at the receivers. in practical applications, you typically achieve this using the global positioning system (gps) clock.

tdoa localization

as the tdoa between two receivers localizes an object to a hyperbola or hyperboloid, it is not possible to observe the full state of the object by using only two stationary receivers. for 2-d localization, at least 3 spatially-separated receivers are required to estimate the object state. similarly, for 3-d tracking, at least 4 spatially-separated receivers are required.

with n(n2) receivers, a total of n(n-12) tdoa measurements from an object can be obtained by calculating the time difference of arrival using each combination of receiver. however, out of these measurements, only n-1measurements are independent and the rest of the tdoa measurements can be formulated as a linear combination of these independent measurements. given these n-1 measurements from the object, an estimation algorithm is typically used to locate the position of the object. in this example, you use the spherical intersection algorithm [1] to find the position and uncertainty in position estimate. the spherical intersection algorithm assumes that all n-1 tdoas are calculated with respect to the same receiver, sometimes referred to as the reference receiver.

the accuracy or uncertainty in the estimated position obtained from localization depends on the geometry of the network. at regions, where small errors in tdoa measurements results in large errors in estimated position, the accuracy of the estimated position is lower. this effect is called geometric dilution of precision (gdop). the image below shows the gdop heat map of the network geometry for a 2-d scenario with 3 receivers. note that the accuracy is high within the envelope generated by the network and is lowest directly behind the receivers along the receiver-to-receiver line of sights.

helpertdoatrackingexampledisplay.plotgdopaccuracymap;

figure contains an axes object. the axes object with title geometric dilution of precision, xlabel x (km), ylabel y (km) contains 2 objects of type image, line. one or more of the lines displays its values using only markers this object represents receivers.

tracking a single emitter

in this section, you simulate tdoa measurements from a single object and use them to localize and track the object in the absence of any false alarms and missed detections.

you define a 2-d scenario using the helper function, helpercreatesingletargettdoascenario. this function returns a object representing a single object moving at a constant velocity. this object is observed by three stationary, spatially-separated receivers. the helper function also returns a matrix of two columns representing the pairs formed by the receivers. each row represents the platformid of the platforms that form the tdoa measurement.

% reproducible results
rng(2021);
% setup scenario with 3 receivers
numreceivers = 3;
[scenario, rxpairs] = helpercreatesingletargettdoascenario(numreceivers);

you then use the helper function, helpersimulatetdoa, to simulate tdoa measurements from the objects. the helper function allows you to specify the measurement accuracy in the tdoa. you use a measurement accuracy of 100 nanoseconds to represent timing inaccuracy in the clocks as well as tdoa estimation. the emission speed and units of the reported time are speed of light in vacuum and nanoseconds respectively, specified using the helpergetglobalparameters function. the helpersimulatetdoa function outputs tdoa detections as a cell array of objects.

tdoadets = helpersimulatetdoa(scenario, rxpairs, measnoise); % specify measurement noise variance (nanosecond^2)

each tdoa detection is represented using the objectdetection according to the following format:

next, you run the scenario and generate tdoa detections from the object. you use the helper function, helpertdoa2pos, to estimate the position and position covariance of the object at every step using the spherical intersection algorithm [1]. you further filter the position estimate of the object using a global nearest neighbor (gnn) tracker configured using the system object™ with a constant-velocity linear kalman filter. to account for the high speed of the object, this constant velocity kalman filter is configured using the helper function, helperinithighspeedkf.

% define accuracy in measurements
measnoise = (100)^2; % nanoseconds^2
% display object
display = helpertdoatrackingexampledisplay(xlimits=[-1e4 1e4],...
                                           ylimits=[-1e4 1e4],...
                                           logaccuracy=true,...
                                           title="single object tracking");
% create a gnn tracker
tracker = trackergnn(filterinitializationfcn=@helperinithighspeedkf,...
                     assignmentthreshold=100);
while advance(scenario)
    % elapsed time
    time = scenario.simulationtime;
    % simulate tdoa detections without false alarms and missed detections
    tdoadets = helpersimulatetdoa(scenario, rxpairs, measnoise);
    % get estimated position and position covariance as objectdetection
    % objects
    posdet = helpertdoa2pos(tdoadets,true);
    % update the tracker with position detections
    tracks = tracker(posdet, time);
    % display results
    display(scenario, rxpairs, tdoadets, {posdet}, tracks);
end

notice that the tracker is able to maintain a track on the object. the the estimated position of the object lies close to the intersection of hyperbolic curves created by each receiver pair. also notice in the zoomed plot below that the filtered estimate of the object has less uncertainty as compared to the fused estimate at every step. as the object moves towards positive x axis, the error in estimated position increases due to geometric dilution of precision. notice that the tracker is able to provide an improved estimate of the object by filtering the position estimate of the object using the kalman filter with constant velocity motion model.

zoomontrack(display,tracks(1).trackid);

figure contains an axes object. the axes object with title single object tracking, xlabel x (km), ylabel y (km) contains 13 objects of type line, image, patch, text. one or more of the lines displays its values using only markers these objects represent emitters, receivers, static fused position, tracks, (history).

figure contains an axes object. the axes object with title single object tracking, xlabel x (km), ylabel y (km) contains 13 objects of type line, image, patch, text. one or more of the lines displays its values using only markers these objects represent emitters, receivers, static fused position, tracks, (history).

plotdetectionvstrackaccuracy(display);

figure contains an axes object. the axes object with title target position accuracy, xlabel time (s), ylabel position uncertainty (m) contains 2 objects of type line. these objects represent fused position, track.

tracking multiple emitters with known ids

in the previous section, you learned how to use tdoa measurements from a single object to generate positional measurement of the object. in practical situations, the scenario may consist of multiple objects.

the main challenge in multi-object tdoa tracking is the estimation of tdoa for each target. in the presence of multiple objects, each receiver receives signals from multiple objects. in the first method for tdoa calculation, each receiver records multiple time-of-arrival measurements. the unknown data association between time-of-arrival measurements reported by each receiver results in many possible tdoa combinations. in the second method of tdoa calculation, the signal cross-correlation function between receiver signals results in multiple peaks corresponding to true objects as well as false alarms. in certain applications, this unknown data association between receivers can be easily solved at the signal level. for example, if the signal encoding is known a-priori, such as in wireless communications signals like lte, 5g signals or aviation communication signals like adsb signals, the receiver is typically able to calculate both the time-of-arrival and the unique identity of the object. similarly, if the objects are separated in their carrier frequencies, a separate tdoa calculation can be added for each object in their own frequency bands.

in this section, you assume that signal-level data association is performed at the receiver. this helps the processing hub to form tdoa measurements per identified object without ambiguity. to simulate tdoa measurements with known emitter identification, you provide a fourth input argument to the helper function, helpersimulatetdoa. the function outputs the unique identity of the emitter as the objectclassid property of the objectdetection object. you use this object identity, shared between tdoas from multiple receiver-pairs, to fuse detections from each object separately and obtain their respective positions as well as uncertainties. then, you use these fused measurements to track these objects using the gnn tracker.

% create the multiple object scenario
numreceivers = 3;
numobjects = 4;
[scenario, rxpairs] = helpercreatemultitargettdoascenario(numreceivers, numobjects);
% reset display 
release(display);
display.logaccuracy = false;
display.title = 'tracking multiple emitters with known ids';
% release tracker
release(tracker);
while advance(scenario)
    % elapsed time
    time = scenario.simulationtime;
   
    % simulate classified tdoa detections
    classifiedtdoadets = helpersimulatetdoa(scenario, rxpairs, measnoise, true);
    
    % find unique object identities
    tgtids = cellfun(@(x)x.objectclassid,classifiedtdoadets);
    uniqueids = unique(tgtids);
    
    % estimate the position and covariance of each emitter as objectdection
    posdets = cell(numel(uniqueids),1);
    for i = 1:numel(uniqueids)
        thisemittertdoadets = classifiedtdoadets(tgtids == uniqueids(i));
        posdets{i} = helpertdoa2pos(thisemittertdoadets, true);
    end
    % update tracker
    tracks = tracker(posdets, time);
    % update display
    display(scenario, rxpairs, classifiedtdoadets, posdets, tracks);
end

figure contains an axes object. the axes object with title tracking multiple emitters with known ids, xlabel x (km), ylabel y (km) contains 19 objects of type line, image, patch, text. one or more of the lines displays its values using only markers these objects represent emitters, receivers, static fused position, tracks, (history).

note that the tracker is able to maintain a track on all 4 objects when tdoa-to-tdoa association is assumed to be known. when the data association is provided by the receivers, the multi-object tdoa estimation is simplified to generating multiple tdoa detections with known single-object associations. the multi-object tracking problem is similarly simplified because there are no false tdoa detections.

tracking multiple emitters with unknown ids

in this section, you assume that data association between receiver data is not known a-priori i.e., receivers cannot identify objects. in the absence of this data association, each intersection between blue and maroon hyperbolic curves shown in the plot from the section could be a possible object location. therefore, when data association is not available from the receivers, associating time-of-arrival (toa) or tdoa detections from multiple receivers is prone to detections from ghost objects. to separate the ghost detections from true object detections, you must add more receivers to reduce the ambiguity. in this section, you will use a static fusion algorithm [2] to determine the unknown data association and estimate position measurements from each object. you will use this static fusion algorithm for systems that transmit multiple time-of-arrival measurements to the processing hub as well as systems that transmit recorded signals to the hub and calculates tdoa before processing them for object tracking.

tracking with time-of-arrival (toa) measurements

in this section, you configure a system in which each receiver transmits multiple time of arrival (toa) measurements to the central processing hub. to reduce ambiguity in data association and to reduce the number of potential ghost objects, you use 4 stationary receivers to localize and track the objects.

to simulate time-of-arrival measurements from the objects, you use the helper function, helpersimulatetoa, to simulate time-of-arrival measurements from multiple objects. these time-of-arrival measurements record the exact time instant in a global reference clock at which the signal was received by the receivers. to simulate exact time instants, the helper function uses the scenario time as the global clock time and assumes that the objects emit signals at the time instant of scenario. note that the algorithm used to track with these measurements is not tied to this assumption as the exact emission time from the object is not known to the receivers.

you specify the nfalse input as 1 to simulate one false time-of-arrival measurement from each receiver. you also specify the pd input, which defines the probability of detecting a true time-of-arrival measurement by each receiver, as 0.95.

toadets = helpersimulatetoa(scenario, receiverids, measnoise, nfalse, pd); 
% receiverids - platformid of all receivers
% measnoise - accuracy in toa measurements (ns^2)
% nfalse - number of false alarms per receiver
% pd - detection probability for receivers

here is the format of time-of-arrival (toa) detections.

to fuse multiple time-of-arrival measurements from each receiver, you use the static fusion algorithm by configuring a object. the staticdetectionfuser object determines the best data association between time of arrival measurements and provides fused detections from possible objects. the static fusion algorithm requires two sub routines or functions. the first function (measurementfusionfcn) allows the algorithm to estimate a fused measurement from object, given a set of time-of-arrival measurements assumed to originate from the same object. the second function (measurementfcn) allows the algorithm to obtain the expected time-of-arrival measurement from the fused measurement. note that to define a measurement function to obtain time-of-arrival measurement, the fused measurement must contain an estimate of the signal emission time from the object. therefore, you define the fused measurement as [xtytztte], where te is the time instant at which the object emitted the signal.

you use the helper function, helpertoa2pos, to estimate fused measurement - position and emission time - of the object. you also use the helper function, helpermeasuretoa, to define the measurement model that calculates time-of-arrival measurement from the fused measurement. the fusion algorithm outputs fused detections as a cell array of objectdetection objects. each element of the cell array defines an objectdetection object containing measurement from a potential object as its position and emission time. you can speed-up this static fusion algorithm by specifying the useparallel property to true. specifying useparallel as true requires the parallel computing toolbox™.

% create scenario
[scenario, ~, receiverids] = helpercreatemultitargettdoascenario(4, 4);
% specify stastics of toa simulation
measnoise = 1e4; % 100 ns per receiver
nfalse = 1; % 1 false alarm per receiver per step
pd = 0.95; % detection probability of true signal
% release display
release(display);
display.title = 'tracking using toa measurements with unknown ids';
% release tracker 
release(tracker);
tracker.confirmationthreshold = [4 6];
% use parallel computing toolbox if available
useparallel = false;
% define fuser. 
toafuser = staticdetectionfuser(maxnumsensors=4,...
    measurementformat='custom',...
    measurementfcn=@helpermeasuretoa,...
    measurementfusionfcn=@helpertoa2pos,...
    falsealarmrate=1e-8,...
    detectionprobability=pd,...
    useparallel=useparallel);
while advance(scenario)
    % current time
    time = scenario.simulationtime;
    % simulate toa detections with false alarms and missed detections
    toadets = helpersimulatetoa(scenario, receiverids, measnoise, pd, nfalse);
    % fuse toa detections to estimate position amd emission time of
    % unidentified and unknown number of emitters. 
    [posdets, info] = toafuser(toadets);
    
    % remove emission time before feeding detections to the tracker as it
    % is not tracked in this example.
    for i = 1:numel(posdets)
        posdets{i}.measurement = posdets{i}.measurement(1:3);
        posdets{i}.measurementnoise = posdets{i}.measurementnoise(1:3,1:3);
    end
    % update tracker. the target emission is assumed at timestamp, time.
    % the timestamp of the detection's is therefore time plus signal
    % propagation time. the tracker timestamp must be greater than
    % detection time. use time   0.05 here. in real-world, this is
    % absolute timestamp at which tracker was updated. 
    tracks = tracker(posdets, time   0.05);
    % update display
    % form tdoa measurements from assigned toas for visualization
    tdoadets = helperformulatetdoas(toadets,info.assignments);
    display(scenario, receiverids, tdoadets, posdets, tracks);
end

figure contains an axes object. the axes object with title tracking using toa measurements with unknown ids, xlabel x (km), ylabel y (km) contains 19 objects of type line, image, patch, text. one or more of the lines displays its values using only markers these objects represent emitters, receivers, static fused position, tracks, (history).

notice that the fuser algorithm is able to estimate the position of the object accurately most of the time. however, due to the presence of false alarms and missed measurements, the fusion algorithm may pick a wrong data association at some steps. this can lead to detections from ghost intersections. the tracker assists the static fusion algorithm by discarding these wrong associations as false alarms.

tracking with time-difference-of-arrival (tdoa) measurements

in this section, you configure the tracking algorithm for a system where tdoas are formed from the receiver-pairs from multiple objects without any emitter identification. the calculation of tdoa from receiver pairs in a multi-object scenario may generate a few false alarms due to false peaks in the cross-correlation function. to simulate the tdoa measurements from such system, you increase the number of false alarms per receiver pair to 2.

the static fusion algorithm is configured similar to the previous section by using the staticdetectionfuser object. in contrast to the time-of-arrival fusion, here you use the measurement fusion function, helperfusetdoa, to fuse multiple tdoas into a fused measurement. you also use the helper function, helpermeasuretdoa, to define the transformation from fused measurement to tdoa measurement. as tdoa measurements do not contain or need information about the true signal emission time, you define the fused measurement as [xtytzt]. you set the maxnumsensors to 3 as four receivers form three tdoa pairs.

% create scenario
[scenario, rxpairs] = helpercreatemultitargettdoascenario(4, 4);
% measurement statistics
measnoise = 1e4; % 100 ns per receiver
nfalse = 2; % 2 false alarms per receiver pair
pd = 0.95; % detection probability per receiver pair
% release display
release(display);
display.title = 'tracking using tdoa measurements with unknown ids';
% release tracker 
release(tracker);
% define fuser. 
tdoafuser = staticdetectionfuser(maxnumsensors=3,...
    measurementformat='custom',...
    measurementfcn=@helpermeasuretdoa,...
    measurementfusionfcn=@helpertdoa2pos,...
    detectionprobability=pd,...
    falsealarmrate=1e-8,...
    useparallel=useparallel);
while advance(scenario)
    % current elapsed time
    time = scenario.simulationtime;
    % simulate tdoa detections with false alarms and missed detections
    tdoadets = helpersimulatetdoa(scenario, rxpairs, measnoise, false, pd, nfalse);
    % fuse tdoa detections to esimate position detections of unidentified
    % and unknown number of emitters
    posdets = tdoafuser(tdoadets);
    
    % update tracker with position detections
    if ~isempty(posdets)
        tracks = tracker(posdets, time);
    end
    % update display
    display(scenario, receiverids, tdoadets, posdets, tracks);
end

figure contains an axes object. the axes object with title tracking using tdoa measurements with unknown ids, xlabel x (km), ylabel y (km) contains 21 objects of type line, image, patch, text. one or more of the lines displays its values using only markers these objects represent emitters, receivers, static fused position, tracks, (history).

with the defined measurement statistics in this example, the tracker maintains tracks on all the objects based on this network geometry. the geometry of the problem, the measurement accuracy, as well as the number of false alarms all have major impacts on the data association accuracy of the static fusion algorithm for both the toa and tdoa systems with unknown data association. for the scenario used in this example, the static fusion algorithm was able to report true detections at sufficient time instants to maintain a track on true objects.

summary

in this example, you learned how to track single object as well as multiple objects using tdoa measurements. you learned about the challenges associated with multi-object tracking without emitter identification from the receivers and used a static fusion algorithm to compute data association at the measurement level.

references

[1] smith, julius, and jonathan abel. "closed-form least-squares source location estimation from range-difference measurements." ieee transactions on acoustics, speech, and signal processing 35.12 (1987): 1661-1669.

[2] sathyan, t., a. sinha, and t. kirubarajan. "passive geolocation and tracking of an unknown number of emitters." ieee transactions on aerospace and electronic systems 42.2 (2006): 740-750.

supporting functions

this section defines a few supporting functions used in this example. the complete list of helper functions can be found in the current working directory.

helpertdoa2pos

function varargout = helpertdoa2pos(tdoadets, reportdetection)
% this function uses the spherical intersection algorithm to find the
% object position from the tdoa detections assumed to be from the same
% object.
%
% this function assumes that all tdoas are measured with respect to the
% same reference sensor. 
%
% [pos, poscov] = helpertdoa2pos(tdoadets) returns the estimated position
% and position uncertainty covariance.
%
% posdetection = helpertdoa2pos(tdoadets, true) returns the estimate
% position and uncertainty covariance as an objectdetection object. 
if nargin < 2
    reportdetection = false;
end
% collect scaling information
params = helpergetglobalparameters;
emissionspeed = params.emissionspeed;
timescale = params.timescale;
% location of the reference receiver
referenceloc = tdoadets{1}.measurementparameters(2).originposition(:);
% formulate the problem. see [1] for more details
d = zeros(numel(tdoadets),1);
delta = zeros(numel(tdoadets),1);
s = zeros(numel(tdoadets),3);
for i = 1:numel(tdoadets)
    receiverloc = tdoadets{i}.measurementparameters(1).originposition(:);
    d(i) = tdoadets{i}.measurement*emissionspeed/timescale;
    delta(i) = norm(receiverloc - referenceloc)^2 - d(i)^2;
    s(i,:) = receiverloc - referenceloc;
end
% pseudo-inverse of s
swstar = pinv(s);
% assemble the quadratic range equation
sts = (swstar'*swstar);
a = 4 - 4*d'*sts*d;
b = 4*d'*sts*delta;
c = -delta'*sts*delta;
rs = zeros(2,1);
% imaginary solution, return a location outside coverage
if b^2 < 4*a*c 
    varargout{1} = 1e10*ones(3,1);
    varargout{2} = 1e10*eye(3);
    return;
end
% two range values
rs(1) = (-b   sqrt(b^2 - 4*a*c))/(2*a);
rs(2) = (-b - sqrt(b^2 - 4*a*c))/(2*a);
% if one is negative, use the positive solution
if prod(rs) < 0
    rs = rs(rs > 0);
    pos = 1/2*swstar*(delta - 2*rs(1)*d)   referenceloc;
else % use range which minimize the error
    xs1 = 1/2*swstar*(delta - 2*rs(1)*d);
    xs2 = 1/2*swstar*(delta - 2*rs(2)*d);
    e1 = norm(delta - 2*rs(1)*d - 2*s*xs1);
    e2 = norm(delta - 2*rs(2)*d - 2*s*xs2);
    if e1  > e2
        pos = xs2   referenceloc;
    else
        pos = xs1   referenceloc;
    end
end
% if required, compute the uncertainty in the position
if nargout > 1 || reportdetection
    poscov = helpercalcpositioncovariance(pos,tdoadets,timescale,emissionspeed);
end
if reportdetection
    varargout{1} = objectdetection(tdoadets{1}.time,pos,'measurementnoise',poscov);
else
    varargout{1} = pos;
    if nargout > 1
        varargout{2} = poscov;
    end
end
end
function meascov = helpercalcpositioncovariance(pos,thisdetections,timescale,emissionspeed)
n = numel(thisdetections);
% complete jacobian from position to n tdoas
h = zeros(n,3);
% covariance of all tdoas
s = zeros(n,n);
for i = 1:n
   e1 = pos - thisdetections{i}.measurementparameters(1).originposition(:);
   e2 = pos - thisdetections{i}.measurementparameters(2).originposition(:);
   htdoar1 = (e1'/norm(e1))*timescale/emissionspeed;
   htdoar2 = (e2'/norm(e2))*timescale/emissionspeed;
   h(i,:) = htdoar1 - htdoar2;
   s(i,i) = thisdetections{i}.measurementnoise;
end
pinv = h'/s*h;
% z is not measured, use 1 as the covariance
if pinv(3,3) < eps
    pinv(3,3) = 1;
end
% insufficient information in tdoa
if rank(pinv) >= 3
    meascov = eye(3)/pinv;
else
    meascov = inf(3);
end
% replace inf with large number
meascov(~isfinite(meascov)) = 100;
% return a true symmetric, positive definite matrix for covariance.
meascov = (meascov   meascov')/2;
end

helperinithighspeedkf

function filter = helperinithighspeedkf(detection)
% this function initializes a constant velocity kalman filter and sets a
% higher initial state covariance on velocity components to account for
% high speed of the object vehicles. 
filter = initcvkf(detection);
filter.statecovariance(2:2:end,2:2:end) = 500*eye(3);
end

helpertoa2pos

function [postime, postimecov] = helpertoa2pos(toadetections)
% this function computes the position and emission time of a target given
% its time-of-arrival detections from multiple receivers. 
%
% convert toas to tdoas for using spherical intersection
[tdoadetections, isvalid] = helpertoa2tdoadetections(toadetections);
% at least 3 toas (2 tdoas) required. some toa pairings can lead to an
% invalid tdoa (> maximum tdoa). in those situations, discard the tuple by
% using an arbitrary position with a large covariance.
if numel(tdoadetections) < 2 || any(~isvalid)
    postime = 1e10*ones(4,1);
    postimecov = 1e10*eye(4);
else
    % get position estimate using tdoa fusion. 
    % get time estimate using calculated position.
    if nargout > 1 % only calculate covariance when requested to save time
        [pos, poscov] = helpertdoa2pos(tdoadetections);
        [time, timecov] = helpercalcemissiontime(toadetections, pos, poscov);
        postime = [pos;time];
        postimecov = blkdiag(poscov,timecov);
    else
        pos = helpertdoa2pos(tdoadetections);
        time = helpercalcemissiontime(toadetections, pos);
        postime = [pos;time];
    end
end
end

helpercalcemissiontime

function [time, timecov] = helpercalcemissiontime(toadetections, pos, poscov)
% this function calculates the emission time of an object given its
% position and obtained toa detections. it also computes the uncertainty in
% the estimate time. 
globalparams = helpergetglobalparameters;
emissionspeed = globalparams.emissionspeed;
timescale = globalparams.timescale;
n = numel(toadetections);
emissiontime = zeros(n,1);
emissiontimecov = zeros(n,1);
for i = 1:numel(toadetections)
    % calculate range from this receiver
    p0 = toadetections{i}.measurementparameters.originposition(:);
    r = norm(pos - p0);
    emissiontime(i) = toadetections{i}.measurement - r/emissionspeed*timescale;
    if nargout > 1
        rjac = (pos - p0)'/r;
        rcov = rjac*poscov*rjac';
        emissiontimecov(i) = rcov./emissionspeed^2*timescale^2;
    end
end
% gaussian merge each time and covariance estimate
time = mean(emissiontime);
if nargout > 1
    e = emissiontime - time;
    timecov = mean(emissiontimecov)   mean(e.^2);
end
end

helpermeasuretoa

function toa = helpermeasuretoa(postime, params)
% this function calculates the expected toa at a receiver given an object
% position and emission time and the receiver's measurement parameters
% (originposition)
globalparams = helpergetglobalparameters;
emissionspeed = globalparams.emissionspeed;
timescale = globalparams.timescale;
r = norm(postime(1:3) - params.originposition);
toa = postime(4)   r/emissionspeed*timescale;
end

helpermeasuretdoa

function toa = helpermeasuretdoa(pos, params)
% this function calculates the expected tdoa measurement given object
% position and measurement parameters of a tdoa detection
globalparams = helpergetglobalparameters;
emissionspeed = globalparams.emissionspeed;
timescale = globalparams.timescale;
r1 = norm(pos(1:3) - params(1).originposition);
r2 = norm(pos(1:3) - params(2).originposition);
toa = (r1 - r2)/emissionspeed*timescale;
end

凯发官网入口首页 copyright 2021 the mathworks, inc.

网站地图