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.

 채택된 답변

Prashant Arora
Prashant Arora 2025년 2월 6일
편집: Prashant Arora 2025년 2월 6일

0 개 추천

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

black cat
black cat 2025년 2월 6일
편집: black cat 2025년 2월 6일
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.
Prashant Arora
Prashant Arora 2025년 2월 7일
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.
black cat
black cat 2025년 2월 7일
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
black cat
black cat 2025년 2월 7일
I see, thank you so much for explaining!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품

릴리스

R2024b

질문:

2025년 2월 6일

댓글:

2025년 2월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by