Main Content

advance

Advance tracking scenario simulation by one time step

Description

example

isrunning = advance(sc) advances simulation of the tracking scenario, sc, and returns the running status of the scenario. Set up the advance behavior using the UpdateRate and InitialAdvance properties of the trackingScenario object.

  • When the UpdateRate property is specified as a positive scalar F, the scenario advances in the time step of 1/F. Moreover, if the InitialAdvance property is specified as 'Zero', the scenario starts at time 0. If the InitialAdvance property is specified as 'UpdateInterval', then the scenario starts at time 1/F.

  • When the UpdateRate property is specified as 0, the scenario advances based on the necessity of updating sensors or emitters mounting on the platforms in the scenario. In this case, the initial time is always time 0. Also, you need to trigger the running of the sensors or emitters by using at least one of these options between advance calls:

    • Directly running the sensors or emitters

    • Using the emit, detect, or lidarDetect function of the tracking scenario to run sensors or emitters in the scenario

    • Using the emit, detect, or lidarDetect function of the platform with a corresponding sensors or emitters

Examples

expand all

Create a tracking scenario and set its InitialAdvance property to UpdateInterval.

scene = trackingScenario('UpdateRate',10);
scene.InitialAdvance = 'UpdateInterval';

Create a platform and define its trajectory. Mount a sensor on the platform.

plat = platform(scene);
traj = waypointTrajectory('Waypoints', [0 1 0; 1 0 0; 0 -1 0; -1 0 0; 0 1 0], ...
    'TimeOfArrival', [0; 0.25; .5; .75; 1.0]);
sensor = fusionRadarSensor(1,'UpdateRate',20)
sensor = 
  fusionRadarSensor with properties:

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

         MountingLocation: [0 0 0]
           MountingAngles: [0 0 0]

              FieldOfView: [1 5]
                LookAngle: [0 0]
              RangeLimits: [0 100000]

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

       TargetReportFormat: 'Clustered detections'

  Use get to show all properties

plat.Trajectory = traj;
plat.Sensors = sensor;

Show the simulation status before running the scenario.

fprintf('Time = %f, Status is %s\n',...
    scene.SimulationTime, scene.SimulationStatus);
Time = 0.000000, Status is NotStarted

Advance the tracking scenario recursively.

while advance(scene)
    p = pose(plat);
    poses = platformPoses(scene);
    detections = sensor(poses,scene.SimulationTime);
    fprintf('Time = %f, Status is %s\n', ...
        scene.SimulationTime, scene.SimulationStatus);
end
Time = 0.100000, Status is InProgress
Time = 0.200000, Status is InProgress
Time = 0.300000, Status is InProgress
Time = 0.400000, Status is InProgress
Time = 0.500000, Status is InProgress
Time = 0.600000, Status is InProgress
Time = 0.700000, Status is InProgress
Time = 0.800000, Status is InProgress
Time = 0.900000, Status is InProgress
Time = 1.000000, Status is InProgress

Show the simulation status after the simulation finishes.

fprintf('Time = %f, Status is %s\n', ...
    scene.SimulationTime, scene.SimulationStatus);
Time = 1.100000, Status is Completed

Input Arguments

expand all

Tracking scenario, specified as a trackingScenario object.

Output Arguments

expand all

The run-state of the simulation, returned as 0 or 1. If isrunning is 1, the simulation is running. If isrunning is 0, the simulation has stopped. A simulation stops when either of these conditions is met:

  • The stop time is reached.

  • Any platform reaches the end of its trajectory.

Units are in seconds.

Version History

Introduced in R2018b