Main Content


Get scenario object from scenario descriptor object

Since R2022b



variantScenario = getScenario(descriptor,Simulator=simulator) returns a scenario object that supports the specified simulator simulator from the given ScenarioDescriptor object descriptor.


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,Simulator="DrivingScenario")
scenarioDescriptor = 
  ScenarioDescriptor with properties:

    status: "DescriptorCreated"

Create a drivingScenario object from ScenarioDescriptor object.

scenarioDS = getScenario(scenarioDescriptor,Simulator="DrivingScenario");

Input Arguments

collapse all

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

Name of simulator, specified as "DrivingScenario".

Data Types: char | string

Output Arguments

collapse all

Variant scenario, returned as a drivingScenario object.

Version History

Introduced in R2022b