Main Content

Introduction to Tracking Scenario and Simulating Sensor Detections

This example introduces how to generate synthetic radar detections in a tracking scenario that simulates target motion and sensor detections. Specifically, this example shows:

  • How to simulate the motion of targets using trackingScenario.

  • How to generate synthetic sensor detections using a sensor object. You use three different approaches to generate detections — generate detections from a specific sensor, generate detections for all sensors mounted on a given platform, and generate all detections in the tracking scenario.

  • How to use the various plotters offered by theaterPlot to visualize the scenario, sensor coverage, and detections.

The main benefit of using scenario generation and sensor simulation over sensor recording is the ability to create rare and potentially hazardous scenarios and test sensor fusion algorithms with these scenarios. These radar detections can be used to develop various tracking algorithms, such as trackerGNN and trackerJPDA.

Simulate a Moving Object and its Attributes

Create a Tracking Scenario with a Moving Target

The first step in generating simulated radar detections is creating a tracking scenario, in which the motion of one or more moving targets is simulated. To set up a tracking scenario, you first create a trackingScenario object, which serves as a simulation environment for all the moving targets added later.

rng(2020); % For repeatable results.
scene = trackingScenario('UpdateRate',2.5)
scene = 
  trackingScenario with properties:

     IsEarthCentered: 0
          UpdateRate: 2.5000
      SimulationTime: 0
            StopTime: Inf
    SimulationStatus: NotStarted
           Platforms: {}
      SurfaceManager: [1x1 fusion.scenario.SurfaceManager]

By default, a tracking scenario runs from the SimulationTime to the StopTime. The step size is given by UpdateRate in Hz. Based on an update rate of 2.5 Hz, the step size of scene is 0.4 sec. Currently, there is no targets (defined using platform) defined in the scenario. When the StopTime is defined as Inf, the scenario runs until the motion of all the platforms in the scenario ends. Define a platform in the scenario named target:

target = platform(scene);

You can check the target is now defined in the scenario, scene.

scene.Platforms{1}
ans = 
  Platform with properties:

       PlatformID: 1
          ClassID: 0
         Position: [0 0 0]
      Orientation: [0 0 0]
       Dimensions: [1x1 struct]
             Mesh: [1x1 extendedObjectMesh]
       Trajectory: [1x1 kinematicTrajectory]
    PoseEstimator: [1x1 insSensor]
         Emitters: {}
          Sensors: {}
       Signatures: {[1x1 rcsSignature]  [1x1 irSignature]  [1x1 tsSignature]}

By default, a dimensionless point object is created, but you can specify the object extent in length, width and height. Also, a trivial kinematicTrajectory is associated with the target. To create a trajectory for the target, you can use the waypointTrajectory object. You can set up a waypoint trajectory by specifying a series of waypoints of the target and the corresponding visiting time. You can also specify other trajectory properties such as velocity and course. See waypointTrajectory for more details.

The following code defines a racetrack path for a target with straight legs of 20 km and a turn radius of 2 km. The altitude of the trajectory is 3 km, which is defined as –3 km in the default North-East-Down coordinate frame used in this scenario.

h = 3; % Unit in km
waypoints = 1e3*[  1    1    0   -1    -1   0     1    1
                   0   10   12   10   -10  -12  -10    0
                   h    h    h    h     h   h     h    h]';
course = [ 90   90  180   270  270    0   90   90]';% unit in degree
timeOfArrival = 60*[  0   1.5  1.8  2.1  5.1  5.4  5.7  7.2]';
targetTrajectory = waypointTrajectory('Waypoints', waypoints, 'TimeOfArrival', timeOfArrival);
target.Trajectory = targetTrajectory;

Visualize and Run the Tracking Scenario

To visualize the scenario as it runs, create a theaterPlot and add a trajectoryPlotter and a platformPlotter to visualize the trajectory and the target, respectively.

tp = theaterPlot('XLimits',[-12 12]*1e3,'Ylimits',[-12 12]*1e3,'ZLimits',[-1e4 1e4]);
trajPlotter = trajectoryPlotter(tp,'DisplayName','Trajectory');
plotTrajectory(trajPlotter,{waypoints})
targetPlotter = platformPlotter(tp,'DisplayName','Target');

Run the tracking scenario and visualize the target motion in a bird's eye view.

while advance(scene) && ishghandle(tp.Parent)
    targetPose = pose(target,'true');
    plotPlatform(targetPlotter, targetPose.Position);
end

Figure contains an axes object. The axes object with xlabel X (m), ylabel Y (m) contains 2 objects of type line. One or more of the lines displays its values using only markers These objects represent Trajectory, Target.

Generate Detections Using Radar Sensors

In a tracking scenario, you can generate detections of targets in three different approaches:

Model a Radar Sensor and Simulate its Detections

To add a sensor to the scenario, you first create a Platform on which the sensor is mounted. The Platform object also provides a targetPoses function which you can use to obtain the poses of targets relative to the platform.

Create a Tower and a Radar

Next, you create a tower platform with dimensions of 5 m, 5 m, and 30 m in length, width, and height, respectively. Position the tower to the left the target path. Set the z coordinate of the tower position to -15 m such that the tower bottom is on the horizontal plane of the scenario frame.

tower = platform(scene);
tower.Dimensions = struct ('Length',5,'Width',5,'Height',30,'OriginOffset', [0 0 0]);
tower.Trajectory.Position = [-1e4 0 15];

Define a platform plotter to show the tower.

towerPlotter = platformPlotter(tp,'DisplayName','Tower','Marker','o','MarkerFaceColor',[0 0 0]);
plotPlatform(towerPlotter,tower.Trajectory.Position,tower.Dimensions,tower.Trajectory.Orientation);

Use a fusionRadarSensor in monostatic mode to implement a monostatic scanning radar sensor. By default, a sensor object reports detections in the coordinate frame of the platform on which the sensor is mounted. You can change the output coordinate frame using the DetectionsCoordinates property of fusionRadarSensor. The available output frames are 'Body'(default), 'Scenario', 'Sensor rectangular', and 'Sensor spherical'.

radar1 = fusionRadarSensor(1,'UpdateRate',2.5,...
    'MountingLocation',[0 0 -15],'FieldOfView',[4;45],...
    'MechanicalAzimuthLimits',[-60 60],'MechanicalElevationLimits',[0 0],...
    'HasElevation',true,'FalseAlarmRate',1e-7)
radar1 = 
  fusionRadarSensor with properties:

              SensorIndex: 1
               UpdateRate: 2.5000
            DetectionMode: 'Monostatic'
                 ScanMode: 'Mechanical'
    InterferenceInputPort: 0
       EmissionsInputPort: 0

         MountingLocation: [0 0 -15]
           MountingAngles: [0 0 0]

              FieldOfView: [4 45]
                LookAngle: [0 0]
              RangeLimits: [0 100000]

     DetectionProbability: 0.9000
           FalseAlarmRate: 1.0000e-07
           ReferenceRange: 100000

       TargetReportFormat: 'Clustered detections'

  Use get to show all properties

Mount the sensor on the tower platform.

tower.Sensors = radar1;

Generate and Simulate Detections

You can visualize the radar coverage area and its scanning beam using the coveragePlotter, coverageConfig, and plotCoverage functions. Create a detectionPlotter to visualize detections generated by the radar.

radar1Plotter = coveragePlotter(tp,'DisplayName','Radar1 Beam','Color','b');
detPlotter = detectionPlotter(tp,'DisplayName','Detections',...
    'Marker','o','MarkerFaceColor',[1 0 0]);

Restart the scenario, generate the detections, and plot the detections. You can observe several false detections.

restart(scene);
while advance(scene) && ishghandle(tp.Parent)
    
    view(70,40); % Comment this to show the bird's eye view;
    time = scene.SimulationTime;

    % Obtain the target pose and plot it.
    poseTarget = pose(target,'true');
    plotPlatform(targetPlotter,poseTarget.Position);
    
    % Obtain the target pose expressed in the tower's coordinate frame.
    poseInTower = targetPoses(tower);
    
    % Obtain the radar detections using the radar object.
    [detections, numDets] = radar1(poseInTower,time);
    
    % Extract detection positions and transform them to the scenario frame.
    detPos = zeros(numDets,3);
    for i=1:numDets
        detPos(i,:) = tower.Trajectory.Position + detections{i}.Measurement';
    end

    % Plot detections.
    if ~isempty(detPos)
        plotDetection(detPlotter,detPos);
    end
    
    % Plot the radar beam and coverage area.
    plotCoverage(radar1Plotter,coverageConfig(scene));
    
end

Figure contains an axes object. The axes object with xlabel X (m), ylabel Y (m) contains 5 objects of type line, patch. One or more of the lines displays its values using only markers These objects represent Trajectory, Target, Tower, Radar1 Beam, Detections.

Generate Detections for All the Sensors Mounted on a Platform

Alternately, you can generate detections for all sensors on a given platform using the detect function. To illustrate this approach, you add a second radar sensor to the tower platform. You also create a coverage plotter for the second radar sensor.

radar2 = fusionRadarSensor(2,'Rotator','UpdateRate',2.5, ...
    'MountingLocation',[0 0 -15], 'FieldOfView',[4; 45], ...
    'HasElevation',true,'FalseAlarmRate',1e-7);
tower.Sensors{2} = radar2;
radar2Plotter = coveragePlotter(tp,'DisplayName','Radar 2 Beam', 'Color','g');

Restart the scenario, generate the detections based on the tower, and plot the detections. As shown in the simulation, both the two radars generate detections of the target.

restart(scene);
while advance(scene) && ishghandle(tp.Parent)
    
    time = scene.SimulationTime;

    % Obtain the target pose and plot it.
    poseTarget = pose(target,'true');
    plotPlatform(targetPlotter,poseTarget.Position);

    % Plot the coverage of sensors.
    configs = coverageConfig(scene);
    plotCoverage(radar1Plotter,configs(1));
    plotCoverage(radar2Plotter,configs(2));

    % Generate the detections.
    [towerDetections, numDets] = detect(tower,time);

    % Extract detection positions and transform them to the scenario frame.
    detPos = NaN(numDets,3);
    for i=1:numDets
        detPos(i,:) = tower.Trajectory.Position + towerDetections{i}.Measurement';    
    end

    % Plot detections.
    if numDets
        plotDetection(detPlotter,detPos);
    end
    
end

Figure contains an axes object. The axes object with xlabel X (m), ylabel Y (m) contains 6 objects of type line, patch. One or more of the lines displays its values using only markers These objects represent Trajectory, Target, Tower, Radar1 Beam, Detections, Radar 2 Beam.

Generate Detections from All the Sensors in a Scenario

You can also generate detections from all sensors in the tracking scenario using the detect function of trackingScenario.

To illustrate this approach, you add a plane in the scenario and define its waypoint trajectory. The plane flies from southwest to northeast at a height of 2.9 km. Create a platform plotter for the plane.

plane = platform(scene);
planeTrajectory = waypointTrajectory('Waypoints',1e3*[-10 -10 -2.9; 12 12 -2.9],'TimeOfArrival',[0 80]);
plane.Trajectory = planeTrajectory;
planePlotter = platformPlotter(tp,'DisplayName','Plane','Marker','d','MarkerEdgeColor','k');

Mount a staring radar on the plane with a field of view of 50 degrees. Create a plotter for the radar.

radar3 = fusionRadarSensor(3,'No scanning','UpdateRate',2.5,'FieldOfView',[60,20], ...
    'HasElevation',true,'FalseAlarmRate',1e-7);
plane.Sensors = radar3;
radar3Plotter = coveragePlotter(tp,'DisplayName','Radar 3 Beam', 'Color','y');

Set the reporting frames of all the three radars to the scenario frame. You need to enable inertial navigation system (INS) before setting the detection coordinate to the scenario frame.

release(radar1);
radar1.HasINS = true;
radar1.DetectionCoordinates = 'Scenario';
release(radar2);
radar2.HasINS = true;
radar2.DetectionCoordinates = 'Scenario';
radar3.HasINS = true;
radar3.DetectionCoordinates = 'Scenario';

Restart and run the scenario, generate all the detections in the scenario, and plot the detections.

% Hide the published figure and show a pre-recorded animation instead.
% You can show the figure by setting f.Visible = 'on'.
f = tp.Parent.Parent;
f.Visible = 'off';

restart(scene);
while advance(scene) && ishghandle(tp.Parent)
     
    % Obtain the target pose and plot it.
    poseTarget = pose(target,'true');
    plotPlatform(targetPlotter,poseTarget.Position);
    
    % Obtain the plane pose and plot it.
    posePlane = pose(plane,'true');
    plotPlatform(planePlotter,posePlane.Position);
    
    % Plot the coverage of sensors.
    configs = coverageConfig(scene);
    plotCoverage(radar1Plotter,configs(1));
    plotCoverage(radar2Plotter,configs(2));
    plotCoverage(radar3Plotter,configs(3));
    
    % Generate the detections.
    scenarioDetections = detect(scene);
    numDets = numel(scenarioDetections);
    
    % Extract detection positions in the scenario frame.
    detPos = NaN(numDets,3);
    for i=1:numDets
        detPos(i,:) = scenarioDetections{i}.Measurement';    
    end
    
    % Plot detections.
    if numDets
        plotDetection(detPlotter,detPos);
    end
    
end

From the results, for a period of time, the radar on the plane can continuously detect the target. The radar on the plane also generate several false detections. The two radars on the tower can detect the plane.

Summary

This example shows you how to create a tracking scenario, simulate target motion, and simulate radar detections in three different approaches based on a sensor, a platform, and the whole scenario. It also shows you how to visualize the target trajectory, instantaneous positions, radar scan beams, and detections.