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
          IsRunning: 1
          Platforms: {}

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.

ans = 
  Platform with properties:

       PlatformID: 1
          ClassID: 0
         Position: [0 0 0]
      Orientation: [0 0 0]
       Dimensions: [1×1 struct]
             Mesh: [1×1 extendedObjectMesh]
       Trajectory: [1×1 kinematicTrajectory]
    PoseEstimator: [1×1 insSensor]
         Emitters: {}
          Sensors: {}
       Signatures: {[1×1 rcsSignature]  [1×1 irSignature]  [1×1 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');
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);

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]);

Create 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 mononstaticRadarSensor. The available output frames are 'Body'(default), 'Scenario', 'Sensor rectangular', and 'Sensor spherical'.

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

                  SensorIndex: 1
                   UpdateRate: 2.5000
                     ScanMode: 'Mechanical'

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

          MaxUnambiguousRange: 100000
    MaxUnambiguousRadialSpeed: 200
                  FieldOfView: [2×1 double]
        MaxMechanicalScanRate: [2×1 double]
         MechanicalScanLimits: [2×2 double]
              MechanicalAngle: [2×1 double]
                    LookAngle: [2×1 double]

         DetectionProbability: 0.9000
               FalseAlarmRate: 1.0000e-07

  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.

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');
    % 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';

    % Plot detections.
    if ~isempty(detPos)
    % Plot the radar beam and coverage area.

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 = monostaticRadarSensor(2,'Rotator','UpdateRate',2.5, ...
    'MountingLocation',[0 0 -15], 'FieldOfView',[4; 45], ...
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.

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

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

    % Plot the coverage of sensors.
    configs = coverageConfig(scene);

    % 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';    

    % Plot detections.
    if numDets

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 = monostaticRadarSensor(3,'No scanning','UpdateRate',2.5,'FieldOfView',[60,20], ...
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.

radar1.HasINS = true;
radar1.DetectionCoordinates = 'Scenario';
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. Show a pre-recorded animation instead.
f = tp.Parent.Parent;
if numel(dbstack) > 5
    f.Visible = 'on';
    f.Visible = 'off';

while advance(scene) && ishghandle(tp.Parent)
    % Obtain the target pose and plot it.
    poseTarget = pose(target,'true');
    % Obtain the plane pose and plot it.
    posePlane = pose(plane,'true');
    % Plot the coverage of sensors.
    configs = coverageConfig(scene);
    % 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';    
    % Plot detections.
    if numDets

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.


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.