主要内容

play

Play scenario simulation from scenario descriptor

Since R2026a

Description

Add-On Required: This feature requires the Automated Driving Toolbox Test Suite for Euro NCAP Protocols add-on.

play(scenarioDescriptorPlotObj) plays the scenario simulation from the scenario descriptor plot object scenarioDescriptorPlotObj.

example

play(scenarioDescriptorPlotObj,Name=Value) specifies additional options for playing the scenario simulation using one or more name-value arguments. For example, PlaybackSpeed=2 simulates the scenario with a speed double the default playback speed of the input scenario by skipping two consecutive scenario frames.

example

Examples

collapse all

Load a driving scenario into the workspace.

load("scenarioWithSingleActor.mat")

Create a scenario descriptor from the loaded driving scenario.

scenarioDescriptor = getScenarioDescriptor(sc);

Plot the first frame of the scenario simulation from the scenario descriptor object.

plot(scenarioDescriptor)

Create a scenario descriptor plot object from the scenario descriptor object.

scenarioDescriptorPlotObj = plot(scenarioDescriptor)
scenarioDescriptorPlotObj = 
  ScenarioDescriptorPlot with properties:

       SimulationTime: 0
    MaxSimulationTime: 0.9300

       NumDescriptors: 1
        FigureHandles: [1×1 Figure]

            Waypoints: "StartEnd"
             CropType: "None"
               XLimit: []
               YLimit: []
               ZLimit: []
                Title: "Figure"
        SubPlotTitles: "Scenario"
             GridSize: []

Configure the scenario descriptor plot object to change the title.

configure(scenarioDescriptorPlotObj,Title="Straight Road")

Play the entire scenario simulation, instead of displaying only the first frame of the scenario.

play(scenarioDescriptorPlotObj)

Close the scenario descriptor plot.

close(scenarioDescriptorPlotObj)

Load a driving scenario containing multiple actor collisions into the workspace.

load("scenarioWithMultipleCollisions.mat")

Create a scenario descriptor from the loaded driving scenario.

scenarioDescriptor = getScenarioDescriptor(sc);

Plot the first frame of the scenario simulation, and create a scenario descriptor plot object from the scenario descriptor object.

scenarioDescriptorPlotObj = plot(scenarioDescriptor)

scenarioDescriptorPlotObj = 
  ScenarioDescriptorPlot with properties:

       SimulationTime: 0
    MaxSimulationTime: 8.0500

       NumDescriptors: 1
        FigureHandles: [1×1 Figure]

            Waypoints: "StartEnd"
             CropType: "None"
               XLimit: []
               YLimit: []
               ZLimit: []
                Title: "Figure"
        SubPlotTitles: "Scenario"
             GridSize: []

Configure the scenario descriptor plot object to change the title.

configure(scenarioDescriptorPlotObj,Title="Collision Scenario")

If you know your scenario contains a collision, you can directly plot the first frame in which a collision occurs. Seek and plot the first collision instance from the loaded scenario.

seek(scenarioDescriptorPlotObj,"Collision")

Rather than specifically plotting the collision instance, you can simulate the scenario, and stop when a collision occurs.

Note: The input scenario contains two collision instances, and the play function stops the simulation at the first collision instance.

play(scenarioDescriptorPlotObj,StopAtEvent="Collision")

Load a MAT file containing two scenario descriptors.

load("scenarioDescriptors")

Plot the first frames of the scenario simulations for both loaded scenario descriptors in a single figure.

scenarioDescriptorPlotObj = plot(scenarioDescriptors)

scenarioDescriptorPlotObj = 
  ScenarioDescriptorPlot with properties:

       SimulationTime: [2×1 double]
    MaxSimulationTime: [2×1 double]

       NumDescriptors: 2
        FigureHandles: [1×1 Figure]

            Waypoints: "StartEnd"
             CropType: "None"
               XLimit: []
               YLimit: []
               ZLimit: []
                Title: "Figure"
        SubPlotTitles: ["Scenario #1"    "Scenario #2"]
             GridSize: []

Configure the scenario descriptor plot object to change the title and subplot titles.

configure(scenarioDescriptorPlotObj,Title="Scenarios",SubPlotTitles=["Curved Road" "Straignt Road"])

Play the entirety of both scenario simulations, instead of displaying only the first frame of each.

play(scenarioDescriptorPlotObj)

Close the scenario descriptor plot.

close(scenarioDescriptorPlotObj)

Input Arguments

collapse all

Scenario descriptor plot data, specified as a ScenarioDescriptorPlot object.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: play(scenarioDescriptorPlot,PlaybackSpeed=2) simulates the scenario with a speed double the default playback speed of the input scenario by skipping two consecutive scenario frames.

Scenario simulation playback speed, specified as a positive integer in the range [1 20].

Data Types: uint8 | uint16 | uint32 | uint64

Stop scenario simulation at event, specified as "None" or "Collision".

If you specify StopAtEvent as "Collision" and the scenario contains multiple collision instances, the function stops simulating the scenario at the first collision instance.

The StopAtEvent name-value argument sets the SimulationTime property of the input ScenarioDescriptorPlot object scenarioDescriptorPlot to the time of the first collision instance in the scenario simulation.

Limitations

  • The plot, play, and seek functions display the lane markings at a junction if that junction has been created without using the roadGroup function.

Version History

Introduced in R2026a