Introduction to Tracking Scenario and Simulating Radar Detections

This example shows how to simulate the motion of targets in space using trackingScenario and how to generate synthetic radar detections using monostaticRadarSensor. It also shows how to use the various plotters offered by the theaterPlot to visualize the scenario and detections.


The main benefit of using scenario generation and sensor simulation over sensor recording is the ability to create rare and potentially dangerous events and test sensor fusion algorithms with them. This example covers the entire synthetic data workflow: how to create synthetic scenarios and how to simulate radar detections. These radar detections can be used to develop and test sensor fusion and tracking algorithms, including the trackerGNN.

Create a Tracking Scenario with One 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 do it, you first create a trackingScenario, which serves as a simulation environment for all the moving targets that are added later.

scene = trackingScenario('UpdateRate', 10)
scene = 

  trackingScenario with properties:

        UpdateRate: 10
          StopTime: Inf
    SimulationTime: 0
         IsRunning: 1
         Platforms: {}

The default tracking scenario is configured to run from the SimulationTime to StopTime updating at UpdateRate hertz. Initially, there are no moving targets, called Platforms, defined in the scenario. To add them, use the platform method.

plat = platform(scene)
plat = 

  Platform with properties:

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

Now, you can see that the scenario has one platform defined in the list of Platforms, and that platform has default information that defines it, but the platform motion still needs to be defined by using the trajectory method, which is the next step.

An platform's trajectory is defined by a set of waypoints, in 3-dimensional space, and a set of time of arrival information. The time of arrival defines when each waypoint is reached. Between the waypoints, the motion will follow a clothoid motion, which minimizes the rate of change in platform orientation relative to the distance it passes. Optionally, you use the Course specify the course at teach waypoint to guarantee that the target moves along a certain direction relative to the ground.

The following code defines a racetrack path for a target, with straight legs the length of 20 Kilometers and a turn radius of 2 Kilometer. The target flies at about 150 meters per second. The altitude above ground is 3 Kilometers, and is defined as negative in the convention of North-East-Down used in this scenario.

h = -3; % Altitude above ground, in Kilometers
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]';
timeOfArrival = 60*[  0   1.5  1.8  2.1  5.1  5.4  5.7  7.2]';
traj = waypointTrajectory('Waypoints', waypoints, 'TimeOfArrival', timeOfArrival);
plat.Trajectory = traj;

Visualize and Run the Tracking Scenario

To visualize the scenario as it runs, create and use a theaterPlot and add a trajectoryPlotter and an platformPlotter to visualize the trajectory of the platform, respectively.

tp = theaterPlot('XLimits', [-12 12]*1e3, 'Ylimits', [-12 12]*1e3, 'ZLimits', [1.1*h 0]*1e3);
pPlotter = trajectoryPlotter(tp, 'DisplayName', 'Trajectory');
plotTrajectory(pPlotter, {waypoints})
aPlotter = platformPlotter(tp, 'DisplayName', 'Target');

You can now visualize the motion of the target by advancing the simulation and using the plotPlatform method to plot the target position.

while advance(scene)
    p = pose(plat,'true');
    plotPlatform(aPlotter, p.Position);

Create a Scanning Radar

So far, the scenario you created only has a target, but no sensor that can detect it. There are two required steps when adding a sensor to the scenario:

  1. You add a platform that represents the platform, on to which the sensor is mounted. This allows you to use the targetPoses method to extract the poses of all other targets in the scenario relative to the sensor. You position the tower platform to the left of the target path.

  2. You add a sensor mounted on the platform. You can define the MountingLocation and MountingAngles properties to define how the sensor is mounted on the platform relative to the platform frame of axes.

tower = platform(scene);
tower.Trajectory.Position = [-10000 0 0];
radar = monostaticRadarSensor(1, 'UpdateRate',10, ... % In Hz
    'MountingLocation', [0 0 -30], 'FieldOfView', [1.5;45],...
    'MechanicalScanLimits', [-60 60; 0 0], 'HasElevation', true)
radarLocation = tower.Trajectory.Position + radar.MountingLocation;
rPlotter = platformPlotter(tp, 'DisplayName', 'Radar', 'Marker', 'o', 'MarkerFaceColor', [0 0 0]);
plotPlatform(rPlotter, tower.Trajectory.Position);
radar = 

  monostaticRadarSensor with properties:

                  SensorIndex: 1
                   UpdateRate: 10
                     ScanMode: 'Mechanical'

             MountingLocation: [0 0 -30]
               MountingAngles: [0 0 0]

          MaxUnambiguousRange: 100000
    MaxUnambiguousRadialSpeed: 200
                  FieldOfView: [2x1 double]
        MaxMechanicalScanRate: [2x1 double]
         MechanicalScanLimits: [2x2 double]
              MechanicalAngle: [2x1 double]
                    LookAngle: [2x1 double]

         DetectionProbability: 0.9000
               FalseAlarmRate: 1.0000e-06

  Use get to show all properties

Create Detections Using the Scanning Radar

To create detections, you restart and advance the scenario and step the radar simulation.

You can visualize the radar scanning beam using a trajectoryPlotter centered at the radar position. The detectionPlotter is used to visualize the radar detections.

beamPlotter = trajectoryPlotter(tp, 'DisplayName', 'Radar Beam', 'LineStyle', '-');
detsPlotter = detectionPlotter(tp, 'DisplayName', 'Radar Detections', 'Marker', 'o', 'MarkerFaceColor', [1 0 0]);
while advance(scene)
    % Move the platform
    p = pose(plat,'true');
    plotPlatform(aPlotter, p.Position);

    % Get the platform pose in the coordinates of the tower
    tgtPose = targetPoses(tower);

    % Simulate and plot the radar detections
    [detections, numDets] = radar(tgtPose, scene.SimulationTime);
    detPos = zeros(numDets,3);
    for i=1:numDets
        detPos(i,:) = radarLocation + detections{i}.Measurement';
    if ~isempty(detPos)
        plotDetection(detsPlotter, detPos);

    % Get and plot the radar beam in the horizontal plane
    angle = radar.MechanicalAngle(1);
    beamPosition = radarLocation + radar.MaxUnambiguousRange*[0 0 0; cosd(angle) sind(angle) 0];
    plotTrajectory(beamPlotter, {beamPosition})

Add a Moving Radar Platform

You want to add a moving platform equipped with a phased array staring radar to the scenario. We use the term platform to denote a combination of a moving platform and a sensor. The platform is a platform, defined with a trajectory, that carries a radar.


% Create the platform and add it to the scenario
pPlat = platform(scene);
% Make the platform move from bottom-left to top-down
traj = waypointTrajectory('Waypoints', 1e3*[-10 -10 -3; 10 10 -3], 'TimeOfArrival', [0; 100]);
pPlat.Trajectory = traj;
% Add a staring radar with 60 degrees field-of-view relative to the platform x-axis
pRadar = monostaticRadarSensor(2,'No scanning','UpdateRate',10,'FieldOfView',[60;20], ...
    'HasINS',true,'DetectionCoordinates','Scenario'); % Report detections in the scenario frame
% Pack the platform with a radar and INS-GPS sensor
pPlat.PoseEstimator = insSensor;
pPlat.Sensors = pRadar;
% Add a plotter to plot the platform position
pPlotter = platformPlotter(tp, 'DisplayName', 'Platform', 'Marker', 'd', 'MarkerFaceColor', [0 0 1]);
wasSnapped = false;

% Run the simulation with both platforms
while advance(scene)
    time = scene.SimulationTime;

    % Move the first platform
    p = pose(plat,'true');
    plotPlatform(aPlotter, p.Position);

    % Simulate tower detections
    tgtPose = targetPoses(tower); % Get the platform pose relative to the tower
    [detections1, numDets1] = radar(tgtPose, time); % Simulate the radar detections

    % Simulate platform detections
    [detections2, numDets2] = detect(pPlat, time); % Generate detections for platform
    p = pose(pPlat,'true');
    plotPlatform(pPlotter, p.Position); % Plot the platform position

    % Collect and plot the detections
    detPos = zeros(numDets1+numDets2,3);
    for i=1:numDets1
        detPos(i,:) = radarLocation + detections1{i}.Measurement';
    for i=numDets1+1:numDets2
        detPos(i,:) = detections2{i-numDets1}.Measurement';
    if numDets1 || numDets2
        plotDetection(detsPlotter, detPos);
        if ~wasSnapped
            wasSnapped = true;

    % Plot the radar beam in the horizontal plane
    angle = radar.MechanicalAngle(1);
    beamPosition = radarLocation + radar.MaxUnambiguousRange*[0 0 0; cosd(angle) sind(angle) 0];
    plotTrajectory(beamPlotter, {beamPosition})


This example shows you how to create a tracking scenario to simulate target motion and radar detections. It shows you how to visualize the target trajectory and instantaneous position, and how to visualize the radar scan beam and detections. It also shows you how to simulate a radar mounted on a moving platform.