Main Content

getScenario

Get scenario object from scenario descriptor object

Since R2022b

Description

example

variantScenario = getScenario(descriptor,Simulator="DrivingScenario") returns a drivingScenario object, variantScenario, from the specified ScenarioDescriptor object, descriptor.

example

variantScenario = getScenario(descriptor,Simulator="RoadRunner",SimulatorInstance=rrApp) returns a RoadRunner ScenarioSimulation object, variantScenario, from the specified ScenarioDescriptor object, descriptor. This syntax also stores the RoadRunner scenario and scene into these two paths, respectively, where ProjectFolder is the path to the folder you specify for the RoadRunner project. For more details on the project folder layout, see RoadRunner Project and Scene System (RoadRunner).

ProjectFolder/Scenario/variantScenario.rrscenario
ProjectFolder/Scene/variantScene.rrscene

Before you use this syntax, you must install RoadRunner and activate your RoadRunner license. For more information, see Install and Activate RoadRunner (RoadRunner).

Note

This function requires the Automated Driving Toolbox™ Test Suite for Euro NCAP® Protocols support package. You can install the Automated Driving Toolbox Test Suite for Euro NCAP Protocols support package from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

Examples

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, ...
    Lanes=laneSpecification,Name="Road");

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, ...
    Name="Car");
waypoints = [13 4 0;
             30 4 0;
             41 4 0];
speed = 30;
trajectory(egoVehicle,waypoints,speed)

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");

To create a RoadRunner scenario from a ScenarioDescriptor object, you must meet these requirements:

  • 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.

openScenario(rrApp,fileName)

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.

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

Stop the RoadRunner simulation.

close(scenario.SimulatorInstance)

Create a new scene and a new scenario in RoadRunner by using the newScene and the newScenario functions, respectively.

newScene(rrApp)
newScenario(rrApp)

Create a RoadRunner scenario from your scenario descriptor object.

scenario = getScenario(rrScenarioDescriptor,Simulator="RoadRunner",SimulatorInstance=rrApp);

Input Arguments

collapse all

Scenario descriptor, specified as a ScenarioDescriptor object or an N-element array of ScenarioDescriptor objects. 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.

RoadRunner application, specified as a roadrunner object.

Output Arguments

collapse all

Variant scenario, returned as a drivingScenario object, N-element array of drivingScenario objects, or a ScenarioSimulation object. The value of this output depends on the which simulator you specify.

  • "DrivingScenario" — The value returned by this argument depends on the value of the descriptor input argument.

    • When you input a ScenarioDescriptor object using the descriptor argument, this function returns a drivingScenario object.

    • When you input an N-element array of ScenarioDescriptor objects using the descriptor argument, this function returns an N-element array of drivingScenario objects.

  • "RoadRunner" — The function returns a RoadRunner ScenarioSimulation object. You can also create a ScenarioSimulation object by using the createSimulation function.

Tips

Version History

Introduced in R2022b

expand all