Main Content

table2scenario

Generate scene and scenario from tabular data

Since R2024a

Description

descriptor = table2scenario(sceneSpec) generates a scene as a ScenarioDescriptor object, descriptor, by using the information in the input scene specification table sceneSpec. For best results, create specification tables using CSV files or spreadsheet files (including from Microsoft® Excel®), and then convert them to the MATLAB table format by using the readtable function.

example

descriptor = table2scenario(sceneSpec,actorSpec) includes actors in the generated scene by using the information in the input actor specification table actorSpec.

descriptor = table2scenario(sceneSpec,actorSpec,eventSpec) includes a scenario with trajectories for the actors in the generated scene by using the information in the event specification table eventSpec.

example

descriptor = table2scenario(___,Name=Value) specifies options using one or more name-value arguments in addition to any combination of input arguments from previous syntaxes. For example, ShowPlot=true creates a figure and displays the generated scene.

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 from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

example

Examples

collapse all

Load a table containing scene specifications into the workspace.

sceneSpec = load("sceneData.mat");

Generate a ScenarioDescriptor object by using the loaded data.

scenarioDescriptor = table2scenario(sceneSpec.sceneData);

Create a drivingScenario object from the generated ScenarioDescriptor object.

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

Visualize the roads in the scene created using the scene specification table.

plot(scenarioDS)

Load a table containing lane specifications and a table containing scene specifications into the workspace

laneSpec = load("laneData.mat");
sceneSpec = load("sceneDataWithLane.mat");

Generate a ScenarioDescriptor object by using the loaded tabular data, and plot the scene.

scenarioDescriptor = table2scenario(sceneSpec.sceneData,LaneSpec=laneSpec.laneData,ShowPlot=true);

Load a table containing scene specifications, a table containing actor specifications, and a table containing actor event specifications into the workspace.

sceneSpec = load("sceneData.mat");
actorSpec = load("actorData.mat");
eventSpec = load("eventData.mat");

Generate a ScenarioDescriptor object by using the loaded tabular data.

scenarioDescriptor = table2scenario(sceneSpec.sceneData,actorSpec.actorData,eventSpec.eventData);

Create a drivingScenario object from the ScenarioDescriptor object.

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

Open the generated driving scenario in the Driving Scenario Designer app.

drivingScenarioDesigner(scenarioDS)

This figure shows the generated driving scenario in the Driving Scenario Designer app.

Click the Run button to run and visualize the scenario. Observe that the scenario contains three actors performing their events as specified in the event specification table, eventSpec.eventData.

This figure shows thre generated driving scenario containing three actors in the Driving Scenario Designer app.

Input Arguments

collapse all

Scene specifications, specified as a table. Each row in the table contains the specifications for a road element, such as a road or junction. Each column specifies one type of road element information, such as element ID, element type, length of the road, or change in heading angle of the road. For more information on the scene specification table, see Scene Specification Table.

Actor specifications, specified as a table. Each row in the table contains the specifications for an actor. Each column specifies one type of actor information, such as actor ID, actor type, actor name, or actor position. For more information on the actor specification table, see Actor Specification Table.

Actor event specifications, specified as a table. Each row in the table contains the specifications for an actor event, such as initialization, turning, lane change, or speed change. Each column specifies one type of actor event information, such as event ID, actor ID, event type, or actor speed. For more information on the actor event specification table, see Event Specification Table.

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: table2scenario(sceneSpec,ShowPlot=true) returns a descriptor which contains a scene and displays it in a figure.

Lane specifications, specified as a table. Each row in the table contains the lane specifications for a road, and each column specifies one type of lane specification information, such as number of lanes, lane markings, and lane type. For more information on the lane specification table, see Lane Specification Table.

Driving direction of the lanes, specified as "Right" or "Left".

Scene plot display, specified as a logical 1 (true) or 0 (false). Specify true to display the generated scene with travel directions of lanes embedded. Otherwise, specify this value as false.

Output Arguments

collapse all

Scenario descriptor, returned as a ScenarioDescriptor object. The Status property of the descriptor object indicates "DescriptorCreated" when the object has been successfully created.

The ScenarioDescriptor object stores scene, actor, and vehicle information extracted from the input tabular data. You can use this information to generate scenario variants to perform safety assessments for various automated driving applications.

More About

collapse all

Tips

  • To create input specification tables from a spreadsheet file (including from Microsoft Excel), use the readtable function.

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

Version History

Introduced in R2024a