Main Content


Extract properties from input scenario to generate scenario variants

Since R2022b



descriptor = getScenarioDescriptor(scenario) extracts the properties of an input scenario scenario and stores these properties in a ScenarioDescriptor object, descriptor, for scenario variant generation.


descriptor = getScenarioDescriptor(scenario,Simulator=simulator) also specifies the simulator simulator used by the input scenario scenario.


This function requires the Scenario Variant Generator for Automated Driving Toolbox™ support package. You can install Scenario Variant Generator for Automated Driving Toolbox from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.


collapse all

Create a driving scenario.

scenario = drivingScenario;

Add a road segment to the scenario.

roadCenters = [41 6; 7 6];
laneSpecification = lanespec([2 2]);
road(scenario,roadCenters, ...

Create a trajectory by adding an ego vehicle, waypoints, and speed information to the scenario.

egoVehicle = vehicle(scenario, ...
    ClassID=1, ...
    Position=[13 4 0], ...
    Mesh=driving.scenario.carMesh, ...
waypoints = [13 4 0;
             30 4 0;
             41 4 0];
speed = 30;

Create a ScenarioDescriptor object, and display it.

scenarioDescriptor = getScenarioDescriptor(scenario)
scenarioDescriptor = 
  ScenarioDescriptor with properties:

    status: "DescriptorCreated"

This example shows how to create a scenario descriptor from a RoadRunner Scenario simulator.

This example assumes that:

  • You have a RoadRunner license and the product is installed.

  • You have a RoadRunner Scenario license and the product is installed.

Specify the path to your local RoadRunner installation folder. This code shows the path for the default installation location on Windows®.

appPath = "C:\Program Files\RoadRunner R2023a\bin\win64";

Specify the path to your RoadRunner project. This code shows the path for a sample project folder location in Windows.

projectPath = "C:\RR\MyProject";

Specify the filename of the RoadRunner scenario.

fileName = "TrajectoryCutIn.rrscenario";

Set up the environment to open the scenario in RoadRunner. Update the settings group.

To update the MATLAB® path for the RoadRunner installation folder, get the root object within the settings hierarchical tree, and update the TemporaryValue for the RoadRunner installation folder property. For more information, see SettingsGroup.

s = settings;
s.roadrunner.application.InstallationFolder.TemporaryValue = appPath;

Open RoadRunner using the specified path to your project. The rrApp RoadRunner object enables you to interact with RoadRunner from the MATLAB workspace.

rrApp = roadrunner(projectPath);

Open the scenario in RoadRunner.


Create a RoadRunner Scenario simulation.

rrSim = createSimulation(rrApp);

Create a structure to store RoadRunner simulation information.

scenario.SimulatorInstance = rrApp;
scenario.SimulationInstance = rrSim;

Create a RoadRunner descriptor.

roadrunnerDS = getScenarioDescriptor(scenario,Simulator="RoadRunner");

Stop the RoadRunner simulation.


Input Arguments

collapse all

Seed scenario, specified as a drivingScenario object, an N-element array of drivingScenario objects, or a structure. The structure must contain these fields:

  • SimulatorInstanceRoadRunner simulator instance, specified as a roadrunner object.

  • SimulationInstanceRoadRunner simulation instance, specified as a ScenarioSimulation object. You can create a ScenarioSimulation object by using the createSimulation function.

Simulator name of the seed scenario, specified as "DrivingScenario" or "RoadRunner".

Data Types: char | string


If you do not specify the simulator argument, getScenarioDescriptor function automatically creates a scenario descriptor based on the scenario you specified at input scenario argument.

Output Arguments

collapse all

Scenario descriptor, returned as a ScenarioDescriptor object or an N-element array of ScenarioDescriptor objects. The status property of the descriptor object descriptor indicates "DescriptorCreated" whether the object has been successfully created.

The ScenarioDescriptor object stores scene, actor, and vehicle information extracted from a seed scenario. You can use these information to generate scenario variants to perform safety assessments for various automated driving applications.


  • To get a scenario from a ScenarioDescriptor object, use the getScenario function.

Version History

Introduced in R2022b