updateTracks

Update multi-object tracker with new detections

Description

confirmedTracks = updateTracks(tracker,detections,time) creates, updates, and deletes tracks in the multiObjectTracker System object™, tracker. Updates are based on the specified list of detections, and all tracks are updated to the specified time. Each element in the returned confirmedTracks structure array corresponds to a single track.

[confirmedTracks,tentativeTracks] = updateTracks(tracker,detections,time) also returns a structure array containing details about the tentative tracks.

example

[confirmedTracks,tentativeTracks,allTracks] = updateTracks(tracker,detections,time) also returns a structure array containing details about all confirmed and tentative tracks, allTracks. The tracks are returned in the order by which the tracker internally maintains them. You can use this output to help you calculate the cost matrix, an optional input argument.

[___] = updateTracks(tracker,detections,time,costMatrix) specifies a cost matrix, returning any of the outputs from preceding syntaxes.

To specify a cost matrix, set the HasCostMatrixInput property of tracker to true.

Examples

collapse all

Generate detections using a forward-facing automotive radar mounted on an ego vehicle. Assume that there are three targets:

  • Vehicle 1 is in the center lane, directly in front of the ego vehicle, and driving at the same speed.

  • Vehicle 2 is in the left lane and driving faster than the ego vehicle by 12 kilometers per hour.

  • Vehicle 3 is in the right lane and driving slower than the ego vehicle by 5 kilometers per hour.

All positions, velocities, and measurements are relative to the ego vehicle. Run the simulation for ten steps.

dt = 0.1;
pos1 = [150 0 0];
pos2 = [160 10 0];
pos3 = [130 -10 0];
vel1 = [0 0 0];
vel2 = [12*1000/3600 0 0];
vel3 = [-5*1000/3600 0 0];
car1 = struct('ActorID',1,'Position',pos1,'Velocity',vel1);
car2 = struct('ActorID',2,'Position',pos2,'Velocity',vel2);
car3 = struct('ActorID',3,'Position',pos3,'Velocity',vel3);

Create an automotive radar sensor that is offset from the ego vehicle. By default, the sensor location is at (3.4,0) meters from the vehicle center and 0.2 meters above the ground plane. Turn off the range rate computation so that the radar sensor measures position only.

radar = radarDetectionGenerator('DetectionCoordinates','Sensor Cartesian', ...
    'MaxRange',200,'RangeResolution',10,'AzimuthResolution',10, ...
    'FieldOfView',[40 15],'UpdateInterval',dt,'HasRangeRate',false);
tracker = multiObjectTracker('FilterInitializationFcn',@initcvkf, ...
    'ConfirmationParameters',[3 4],'NumCoastingUpdates',6);

Generate detections with the radar from the non-ego vehicles. The output detections form a cell array and can be passed directly in to the multiObjectTracker.

simTime = 0;
nsteps = 10;
for k = 1:nsteps
    dets = radar([car1 car2 car3],simTime);
    [confirmedTracks,tentativeTracks,allTracks] = updateTracks(tracker,dets,simTime);

Move the cars one time step and update the multi-object tracker.

    simTime = simTime + dt;
    car1.Position = car1.Position + dt*car1.Velocity;
    car2.Position = car2.Position + dt*car2.Velocity;
    car3.Position = car3.Position + dt*car3.Velocity;
end

Use birdsEyePlot to create an overhead view of the detections. Plot the sensor coverage area. Extract the X and Y positions of the targets by converting the Measurement fields of the cell array into a MATLAB array. Display the detections on the bird's-eye plot.

BEplot = birdsEyePlot('XLim',[0 220],'YLim',[-75 75]);
caPlotter = coverageAreaPlotter(BEplot,'DisplayName','Radar coverage area');
plotCoverageArea(caPlotter,radar.SensorLocation,radar.MaxRange, ...
    radar.Yaw,radar.FieldOfView(1))
detPlotter = detectionPlotter(BEplot,'DisplayName','Radar detections');
detPos = cellfun(@(d)d.Measurement(1:2),dets,'UniformOutput',false);
detPos = cell2mat(detPos')';
if ~isempty(detPos)
    plotDetection(detPlotter,detPos)
end

Input Arguments

collapse all

Multi-object tracker, specified as a multiObjectTracker System object.

Detection list, specified as a cell array of objectDetection objects. The Time property value of each objectDetection object must be less than or equal to the current time of update, time, and greater than the previous time value used to update the multi-object tracker.

Time of update, specified as a real scalar. The multi-object tracker updates all tracks to this time. Units are in seconds.

time must be greater than or equal to the largest Time property value of the objectDetection objects in the input detections list. time must increase in value with each update to the multi-object tracker.

Data Types: double

Cost matrix, specified as a real-valued NT-by-ND matrix, where NT is the number of existing tracks, and ND is the number of current detections. The rows of the cost matrix correspond to the existing tracks. The columns correspond to the detections. Tracks are ordered as they appear in the list of tracks in the allTracks output argument of the previous update to the multi-object tracker.

In the first update to the multi-object tracker, or when the multi-object tracker has no previous tracks, assign the cost matrix a size of [0, ND]. The cost must be calculated so that lower costs indicate a higher likelihood that the multi-object tracker assigns a detection to a track. To prevent certain detections from being assigned to certain tracks, use Inf.

Dependencies

To enable specification of the cost matrix when updating tracks, set the HasCostMatrixInput property of the multi-object tracker to true

Data Types: double

Output Arguments

collapse all

Confirmed tracks, returned as a structure array with these fields.

FieldDefinition
TrackIDUnique track identifier.
TimeTime at which the track is updated. Units are in seconds.
AgeNumber of updates since track initialization.
StateUpdated state vector. The state vector is specific to each type of Kalman filter.
StateCovarianceUpdated state covariance matrix. The covariance matrix is specific to each type of Kalman filter.
IsConfirmedConfirmation status. This field is true if the track is confirmed to be a real target.
IsCoastedCoasting status. This field is true if the track is updated without a new detection.
ObjectClassIDInteger value representing the object classification. The value 0 represents an unknown classification. Nonzero classifications apply only to confirmed tracks.
ObjectAttributesCell array of object attributes reported by the sensor making the detection.

A track is confirmed if:

  • At least M detections are assigned to the track during the first N updates after track initialization. To specify the values [M N], use the ConfirmationParameters property of the multi-object tracker.

  • The objectDetection object initiating the track has an ObjectClassID greater than zero.

Tentative tracks, returned as a structure array with these fields.

FieldDefinition
TrackIDUnique track identifier.
TimeTime at which the track is updated. Units are in seconds.
AgeNumber of updates since track initialization.
StateUpdated state vector. The state vector is specific to each type of Kalman filter.
StateCovarianceUpdated state covariance matrix. The covariance matrix is specific to each type of Kalman filter.
IsConfirmedConfirmation status. This field is true if the track is confirmed to be a real target.
IsCoastedCoasting status. This field is true if the track is updated without a new detection.
ObjectClassIDInteger value representing the object classification. The value 0 represents an unknown classification. Nonzero classifications apply only to confirmed tracks.
ObjectAttributesCell array of object attributes reported by the sensor making the detection.

A track is tentative before it is confirmed.

All confirmed and tentative tracks, returned as a structure array with these fields.

FieldDefinition
TrackIDUnique track identifier.
TimeTime at which the track is updated. Units are in seconds.
AgeNumber of updates since track initialization.
StateUpdated state vector. The state vector is specific to each type of Kalman filter.
StateCovarianceUpdated state covariance matrix. The covariance matrix is specific to each type of Kalman filter.
IsConfirmedConfirmation status. This field is true if the track is confirmed to be a real target.
IsCoastedCoasting status. This field is true if the track is updated without a new detection.
ObjectClassIDInteger value representing the object classification. The value 0 represents an unknown classification. Nonzero classifications apply only to confirmed tracks.
ObjectAttributesCell array of object attributes reported by the sensor making the detection.

Algorithms

When you pass detections into updateTracks, the function:

  • Attempts to assign the input detections to existing tracks, using the assignDetectionsToTracks function.

  • Creates new tracks from unassigned detections.

  • Updates already assigned tracks and possibly confirms them, based on the ConfirmationParameters property of the multi-object tracker.

  • Deletes tracks that have no assigned detections within the last NumCoastingUpdates updates.

Introduced in R2017a