Main Content

advance

Advance radar scenario simulation by one time step

Since R2021a

Description

example

isRunning = advance(scenario) advances the simulation of the radar scenario scenario by one time step, and returns the running status of the scenario. Set up the advance behavior using the UpdateRate and InitialAdvance properties of the radarScenario object.

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

  • When the UpdateRate property is 0, the simulation advances to the next scheduled sampling time of any mounted sensors or emitters. For example, if a scenario has two sensors with update rates of 2 Hz and 5 Hz, then the first seven simulation updates are at 0, 0.2, 0.4, 0.5, 0.6, 0.8 and 1.0 seconds, respectively.

    In this case, the initial time is always time 0. Also, you must trigger the running of the sensors or emitters by using at least one of these options between calls to the advance function:

    • Directly running the sensors or emitters

    • Using the emit or detect function of the radar scenario to run sensors or emitters in the scenario

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

Examples

collapse all

Create a new radar scenario.

rs = radarScenario;

Create a platform that follows a circular path of radius 10 m for one second. This is accomplished by placing waypoints in a circular shape, ensuring that the first and last waypoint are the same.

plat = platform(rs);
wpts = [0 10 0; 10 0 0; 0 -10 0; -10 0 0; 0 10 0];
time = [0; 0.25; .5; .75; 1.0];
plat.Trajectory = waypointTrajectory(wpts,time);

Perform the simulation, advancing one time step at a time. Display the simulation time and the position and velocity of the platform at each time step.

while advance(rs)
    p = pose(plat);
    disp(strcat("Time = ",num2str(rs.SimulationTime)))
    disp(strcat("  Position = [",num2str(p.Position),"]"))
    disp(strcat("  Velocity = [",num2str(p.Velocity),"]"))
end
Time = 0
  Position = [0  10   0]
  Velocity = [62.8318 -1.88403e-05            0]
Time = 0.1
  Position = [5.8779      8.0902           0]
  Velocity = [50.832     -36.9316            0]
Time = 0.2
  Position = [9.5106      3.0902           0]
  Velocity = [19.4161     -59.7566            0]
Time = 0.3
  Position = [9.5106     -3.0902           0]
  Velocity = [-19.4161     -59.7567            0]
Time = 0.4
  Position = [5.8779     -8.0902           0]
  Velocity = [-50.832     -36.9316            0]
Time = 0.5
  Position = [0 -10   0]
  Velocity = [-62.8319  1.88181e-05            0]
Time = 0.6
  Position = [-5.8779     -8.0902           0]
  Velocity = [-50.832      36.9316            0]
Time = 0.7
  Position = [-9.5106     -3.0902           0]
  Velocity = [-19.4161      59.7566            0]
Time = 0.8
  Position = [-9.5106      3.0902           0]
  Velocity = [19.4161      59.7566            0]
Time = 0.9
  Position = [-5.8779      8.0902           0]
  Velocity = [50.832      36.9316            0]
Time = 1
  Position = [-7.10543e-15           10            0]
  Velocity = [62.8319 -1.88404e-05            0]

Input Arguments

collapse all

Radar scenario, specified as a radarScenario object.

Output Arguments

collapse all

Run-state of the simulation, returned as a logical 0 or 1. If isRunning is 1, then the simulation is running. If isRunning is 0, then 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 and you have specified the platform Motion property with waypoints using the waypointTrajectory System object™.

Data Types: logical

Version History

Introduced in R2021a