get track positions from trackerGNN

In this example:
how do you extract the track coordinates and uncertainties calculated from the tracker?
I tried this:
[positions, covariances] = getTrackPositions(allTracks,'constvel')
but positions was a 3x1 array.

 Accepted Answer

Prashant Arora
Prashant Arora on 6 Feb 2025
Edited: Prashant Arora on 6 Feb 2025
Hi,
For the Cartesian EKF, you should be able to use getTrackPositions(tracks, "constvel") and the output positions represents the position as 3xN array, where N is the number of tracks.
For the MSC-EKF, there's a helper function getTrackPositionsMSC defined in the example. You should be able to use that to get the position and covariance of the tracks.
Thanks,
Prashant

5 Comments

Thank you for the reply. After I ran the entire example and saved getTrackPositionsMSC into a separate .m file, I tried
[pos,cov] = getTrackPositionsMSC(allTracks(1),[0,0,0]');
But pos was still just a 3-element array.
Could you clarify what you meant by track coordinates and uncertainties?
The position output, pos, represents the position of the track as [x y z], and is expected to be a 3-element array. The covariance is a 3x3xN matrix representing the covariance of the error.
I would like to get the 3D positions of the track over time as estimated by the tracker over the course of the collection. The detections are angle-only.
The "tracks" output from the tracker represents the estimate of the object at the current time. It does not represent the entire history of the object estimate. To get the estimate over a course of time, you can use the getTrackPositions or getTrackPositionsMSC function inside the loop.
Each element of the "tracks" has a TrackID which represents the unique identity of the object. The code below shows an example of logging positions of tracks using a struct, however, you can use any format to store this information. This approach should work for multiple tracks, but can be simplied for single track use-case.
% Use a struct to store track-based position log.
positionLog = repmat(struct('TrackID',0,...
'Position',zeros(0,3),...
'PositionCovariance',zeros(3,3,0)),0,1);
while advance(scenario)
% Code to simulate scenario and generate detections
% The output is the confirmed tracks at current time
tracks = tracker(detections, time);
% This represent the current positions and covariances of all the confirmed tracks
[pos, cov] = getTrackPositions(tracks, 'constvel');
for k = 1:numel(tracks)
idx = find([positionLog.TrackID] == tracks(k).TrackID);
if ~isempty(idx) % Track exists in the log
positionLog(idx).Position = [positionLog(idx).Position;pos(k,:)];
positionLog(idx).PositionCovariance = cat(3,positionLog(idx).PositionCovariance,cov(:,:,k));
else % Add new track to the log
newTrack.TrackID = tracks(k).TrackID;
newTrack.Position = pos(k,:);
newTrack.PositionCovariance = cov(:,:,k);
positionLog = [positionLog;newTrack];
end
end
end
I see, thank you so much for explaining!

Sign in to comment.

More Answers (0)

Products

Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!