tuning a multi-凯发k8网页登录
this example shows how to tune and run a tracker to track multiple objects in the scene. the example explains and demonstrates the importance of key properties of the trackers in the sensor fusion and tracking toolbox.
default tracker configuration
in order to test the capability of a tracker to track multiple objects, you set up a basic scenario. in the scenario, you define three objects with each moving along a straight line at a constant velocity. initially, you set the object velocities to be 48 m/s, 60 m/s, and 72 m/s, respectively.
stoptime = 10; v = 60; scenario = trackingscenario; scenario.stoptime = stoptime; scenario.updaterate = 0; p1 = platform(scenario); p1.trajectory = waypointtrajectory([20 10 0; 20 .8*v*stoptime-10 0], [0 stoptime]); p2 = platform(scenario); p2.trajectory = waypointtrajectory([0 0 0; 0 v*stoptime 0], [0 stoptime]); p3 = platform(scenario); p3.trajectory = waypointtrajectory([-20 -10 0; -20 1.2*v*stoptime 10 0], [0 stoptime]);
in addition, you define a radar that stares at the scene and updates 5 times per second. you mount it on a platform located on the side of the moving objects.
pradar = platform(scenario); pradar.trajectory = kinematictrajectory('position', [-v*stoptime 0.5*v*stoptime 0]); radar = fusionradarsensor(1, 'no scanning', 'updaterate', 5, ... 'mountingangles', [0 0 0], 'azimuthresolution', 1, ... 'fieldofview', [100 1], 'hasins', true, 'detectioncoordinates', 'scenario'); pradar.sensors = radar;
you create a theater plot to display the scene.
fig = figure; ax = axes(fig); tp = theaterplot('parent', ax, 'xlimits', [-11*v 100], 'ylimits', [-50 15*v], 'zlimits', [-100 100]); rp = platformplotter(tp, 'displayname', 'radar', 'marker', 'd'); pp = platformplotter(tp, 'displayname', 'platforms'); dp = detectionplotter(tp, 'displayname', 'detections'); trp = trackplotter(tp, 'displayname', 'tracks', 'connecthistory', 'on', 'colorizehistory', 'on'); covp = coverageplotter(tp, 'displayname', 'radar coverage', 'alpha', [0.1 0]);
finally, you create a default trackergnn
object, run the scenario, and observe the results. you use trackgospametric
to evaluate the tracker performance.
tracker = trackergnn; tgm = trackgospametric("distance","posabserr"); gospa = zeros(1,51); % number of timesteps is 51 i = 0; % define the random number generator seed for repeatable results s = rng(2019); while advance(scenario) % get detections dets = detect(scenario); % update the tracker if islocked(tracker) || ~isempty(dets) [tracks, ~, ~, info] = tracker(dets, scenario.simulationtime); end % evaluate gospa i = i 1; truth = platformposes(scenario); gospa(i) = tgm(tracks, truth); % update the display updatedisplay(rp, pp, dp, trp, covp, scenario, dets, tracks); end
rng(s)
figure
plot(gospa)
title('generalized ospa vs. timestep')
you observe that the tracker was not able to track the three objects. at some point, additional tracks are confirmed and shown in addition to the three expected tracks for the three moving objects. as a result, the value of the gospa metric increases. note that lower values of the gospa metric indicate better tracker performance.
assignment threshold
you look at the info
struct that the tracker outputs and observe that the costmatrix
and the assignments
do not show an assignment of pairs of tracks and objects you expect to happen. this means that the assignmentthreshold
is too small and should be increased. increase the assignment threshold to 50.
release(tracker); tracker.assignmentthreshold = 50; rerunscenario(scenario, tracker, tgm, tp);
the assignment threshold property also has a maximum distance from a detection that you can set. this is the last element in the assignmentthreshold
value. you can use this value to speed the tracker up when handling large number of detections and tracks. refer to the how to efficiently track large numbers of objects example for more details. here, you set the value to 2000
instead of inf
, which will reduce the number of combinations of tracks and detections that are used to calculate the assignment cost.
release(tracker); tracker.assignmentthreshold = [50 2000]; rerunscenario(scenario, tracker, tgm, tp);
filter initialization function
the results above show that the tracker is capable of maintaining three tracks for the three moving objects without creating false tracks. however, would the tracker's performance hold if the objects move at a faster speed? to check that, you modify the scenario and increase the object speeds to be 160, 200, and 240 m/s, respectively.
v = 200;
p1.trajectory = waypointtrajectory([20 -10 0; 20 0.8*v*stoptime-10 0], [0 stoptime]);
p2.trajectory = waypointtrajectory([0 0 0; 0 v*stoptime 0], [0 stoptime]);
p3.trajectory = waypointtrajectory([-20 10 0; -20 1.2*v*stoptime 10 0], [0 stoptime]);
pradar.trajectory = kinematictrajectory('position', [-v*stoptime 0.5*v*stoptime 0]);
tp.xlimits = [-100-v*stoptime 300];
tp.ylimits = [-100 100 v*1.2*stoptime];
release(radar);
radar.rangelimits(2) = 3000;
rerunscenario(scenario, tracker, tgm, tp);
as you probably expected, the tracker could not establish stable tracks of the three objects. a possible solution is to increase the assignmentthreshold
even further to allow tracks to be updated. however, this option may increase the chance of random false tracks being assigned to multiple detections and getting confirmed. so, you choose to modify how a filter is being initialized.
you set the filterinitializationfcn
property to the function initfastcvekf
. the function is the same as the default initcvekf
except it increases the uncertainty in the velocity components of the state. it allows the initial state to account for larger unknown velocity values, but once the track establishes, the uncertainty decreases again.
release(tracker) tracker.filterinitializationfcn = @initfastcvekf; rerunscenario(scenario, tracker, tgm, tp);
you observe that the tracker is once again able to maintain the tracks, and there are 3 tracks for the three moving objects, even though they are moving faster now. the gospa value is also reduced after a few steps.
confirmation and deletion thresholds
you want to make sure that your tracker is robust to a higher false alarm rate. to do that, you configure the radar to have a false alarm rate that is 250 times higher than previously.
you zoom out to view a larger portion of the scene and to see if false tracks are created.
release(radar); radar.falsealarmrate = 2.5e-4; tp.xlimits = [-2100 300]; tp.ylimits = [-100 3100]; tp.zlimits = [-1000 1000]; rerunscenario(scenario, tracker, tgm, tp);
there are a few false tracks being created (not all of them shown) and they increase the gospa value.
you want to delete false tracks more quickly, for which you use the deletionthreshold
property. the default value for deletion threshold is [5 5], which requires 5 consecutive misses before a confirmed track is deleted. you can make the deletion process quicker by reducing this value to [3 3], or 3-out-of-3 misses. alternatively, since the radar detectionprobability
is high, you can even delete a track after 2-out-of-3 misses, by setting:
release(tracker) tracker.deletionthreshold = [2 3]; rerunscenario(scenario, tracker, tgm, tp);
as expected, reducing the number of steps it takes to delete tracks decreases the gospa value because these false tracks are short-lived. however, these false tracks are still confirmed and deteriorate the overall tracking quality.
so, you want to make the confirmation of new tracks more stringent in attempt to reduce the number of false tracks. consider the tracker confirmationthreshold
property.
disp(tracker.confirmationthreshold);
2 3
the value shows that the tracker confirms every track if it is assigned two detections in the first three updates. you decide to make it harder to confirm a track and reset the value to be 3-out-of-4 assignments.
release(tracker) tracker.confirmationthreshold = [3 4]; rerunscenario(scenario, tracker, tgm, tp);
by making track confirmation more stringent you were able to eliminate the false tracks. as a result, the gospa values are down to around 20 again, except for the first few steps.
maximum number of tracks
making the confirmation more stringent allowed you to eliminate false tracks. however, the tracker still initializes a track for each false detection, which you can observe by looking at the number of tracks the tracker currently maintains.
the number of tracks fluctuates through the lifetime of the tracker. however, you don't want it to exceed the maximum number of tracks that the tracker can maintain, defined by maxnumtracks
, which is by default 100. if the tracker exceeds this number, it issues a warning that a new track could not be added, but the execution can continue.
increase the maximum number of tracks to allow the tracker to track even with a higher false alarm rate without issuing the warning. you also want to make track confirmation even more stringent to reduce the number of false tracks and reduce the gospa metric.
release(tracker) tracker.maxnumtracks = 200; tracker.confirmationthreshold = [5 6]; release(radar) radar.falsealarmrate = 1e-3; rerunscenario(scenario, tracker, tgm, tp);
note that making track confirmation more stringent requires more steps to confirm tracks. as a result, for the first few steps, there are no confirmed tracks and the gospa value remains high. you can compare that with the gospa graphs in the beginning of this example.
try another tracker
you want to try using another tracker, in this case, the joint probabilistic data association tracker, trackerjpda
. many of the properties defined for the previous tracker are still valid in the jpda tracker. you use the helpergnn2jpda
to construct the jpda tracker.
jpda = helpergnn2jpda(tracker); jpda.clutterdensity = 1e-3; rerunscenario(scenario, tracker, tgm, tp);
summary
in this example, you learned to set up multi-object trackers in order to maintain tracks of the real objects in the scene, avoid false tracks, maintain the right number of tracks, and switch between different trackers.
when tuning a multi-object tracker, consider changing the following properties:
filterinitializationfcn — defines the filter used to initialize a new track with an unassigned detection.
the function defines the motion and measurement models.
check that the state uncertainties are correctly represented by the statecovariance of the filter. for example, a large initial velocity covariance allows tracking fast moving objects.
assignmentthreshold — maximum normalized distance used in the assignment of detections to tracks.
decrease this value to speed up assignment, especially in large scenes with many tracks and to avoid false tracks, redundant tracks, and track swaps. if using a
trackerjpda
, reducing this value reduces the number of detections that are considered as assigned to a single track. if using atrackertomht
, reducing the assignment thresholds reduces the number of track branches that are created.increase this value to avoid tracks diverging and breaking even in the presence of new detections.
maxnumtracks — maximum number of tracks maintained by the tracker.
decrease this value to minimize memory usage and speed up tracker initialization.
increase this value to avoid new tracks not being initialized because the limit was reached.
confirmationthreshold — controls the confirmation of new tracks.
decrease this value to confirm more tracks and to confirm tracks more quickly.
increase this value to lower the number of false tracks.
deletionthreshold — controls the coasting and deletion of tracks.
decrease this value to delete tracks more quickly (for example when the probability of detection is high).
increase this value to compensate for a lower probability of detection (for example coast tracks during occlusions).
you can refer to the following examples for additional details: how to generate c code for a tracker, , tracking closely spaced targets under ambiguity, and .
utility functions
updatedisplay
this function updates the display at every step of the simulation.
function updatedisplay(rp, pp, dp, trp, covp, scenario, dets, tracks) % plot the platform positions poses = platformposes(scenario); pos = reshape([poses(1:3).position], 3, [])'; % only the platforms plotplatform(pp, pos); radarpos = poses(4).position; % only the radar plotplatform(rp, radarpos) % plot the detection positions if ~isempty(dets) ds = [dets{:}]; dpos = reshape([ds.measurement], 3, [])'; else dpos = zeros(0,3); end plotdetection(dp, dpos); % plot the tracks tpos = gettrackpositions(tracks, [1 0 0 0 0 0; 0 0 1 0 0 0; 0 0 0 0 1 0]); tids = string([tracks.trackid]); plottrack(trp, tpos, tids); % plot the coverage covcon = coverageconfig(scenario); plotcoverage(covp, covcon); end
rerunscenario
this function runs the scenario with a given tracker and a track gospa metric object. it uses the theater plot object to display the results.
function info = rerunscenario(scenario, tracker, tgm, tp) % reset the objects after the previous run restart(scenario); reset(tracker); reset(tgm); rp = findplotter(tp, 'displayname', 'radar'); pp = findplotter(tp, 'displayname', 'platforms'); trp = findplotter(tp, 'displayname', 'tracks'); dp = findplotter(tp, 'displayname', 'detections'); covp = findplotter(tp, 'displayname', 'radar coverage'); clearplotterdata(tp); gospa = zeros(1,51); % number of timesteps is 51 i = 0; s = rng(2019); while advance(scenario) % get detections dets = detect(scenario); % update the tracker if islocked(tracker) || ~isempty(dets) [tracks, ~, ~, info] = tracker(dets, scenario.simulationtime); end % evaluate gospa i = i 1; truth = platformposes(scenario); gospa(i) = tgm(tracks, truth); % update the display updatedisplay(rp, pp, dp, trp, covp, scenario, dets, tracks); end rng(s) figure plot(gospa(gospa>0)) title('generalized ospa vs. timestep') end
initfastcvekf
this function modifies the default initcvekf
filter initialization function to allow for more uncertainty in the object speed.
function ekf = initfastcvekf(detection) ekf = initcvekf(detection); initialcovariance = diag(ekf.statecovariance); initialcovariance([2,4,6]) = 300^2; % increase the speed covariance ekf.statecovariance = diag(initialcovariance); end
helpergnn2jpda
this function provides the jpda tracker equivalent to the gnn tracker given as an input.
function jpda = helpergnn2jpda(gnn) jpda = trackerjpda(... 'maxnumtracks', gnn.maxnumtracks, ... 'assignmentthreshold', gnn.assignmentthreshold, ... 'filterinitializationfcn', gnn.filterinitializationfcn, ... 'maxnumsensors', gnn.maxnumsensors, ... 'confirmationthreshold', gnn.confirmationthreshold, ... 'deletionthreshold', gnn.deletionthreshold, ... 'hascostmatrixinput', gnn.hascostmatrixinput, ... 'hasdetectabletrackidsinput', gnn.hasdetectabletrackidsinput); if strcmpi(gnn.tracklogic, 'history') jpda.tracklogic = 'history'; else jpda.tracklogic = 'integrated'; jpda.detectionprobability = gnn.detectionprobability; jpda.clutterdensity = gnn.falsealarmrate / gnn.volume; end end