Main Content

getScenarioDescriptor

Extract properties from input scenario to generate scenario variants

Since R2022b

Description

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

example

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

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.

example

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)
scenarioDescriptor = 
  ScenarioDescriptor with properties:

    status: "DescriptorCreated"

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

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 R2023b\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);
Connection status: 1
Connected to RoadRunner Scenario server on localhost:57145, with client id {87162949-e48b-4263-9385-fcd81da6f555}

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.

close(scenario.SimulatorInstance)

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.

    Note

    To create a roadrunner object for the first time, you must install RoadRunner and activate your RoadRunner license. For more information, see Install and Activate RoadRunner (RoadRunner).

  • 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

Note

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.

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

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

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.

Tips

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

Version History

Introduced in R2022b

expand all