table2scenario
Syntax
Description
generates a scene as a descriptor
= table2scenario(sceneSpec
)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.
includes actors in the generated scene by using the information in the input actor
specification table descriptor
= table2scenario(sceneSpec
,actorSpec
)actorSpec
.
includes a scenario with trajectories for the actors in the generated scene by using the
information in the event specification table descriptor
= table2scenario(sceneSpec
,actorSpec
,eventSpec
)eventSpec
.
specifies options using one or more name-value arguments in addition to any combination of
input arguments from previous syntaxes. For example, descriptor
= table2scenario(___,Name=Value
)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.
Examples
Create Scene Using Scene Specification Table
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)
Create Scene Using Scene and Lane Specification Tables
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);
Generate Scenario Using Tabular Data
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)
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
.
Input Arguments
sceneSpec
— Scene specifications
table
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.
actorSpec
— Actor specifications
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.
eventSpec
— Actor event specifications
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
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.
LaneSpec
— Lane specifications
table
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.
DrivingDirection
— Driving direction of lanes
"Right"
(default) | "Left"
Driving direction of the lanes, specified as "Right"
or
"Left"
.
ShowPlot
— Scene plot display
false
or 0
(default) | true
or 1
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
descriptor
— Scenario descriptor
ScenarioDescriptor
object
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
Scene Specification Table
Specify the column names in the first row of your spreadsheet or CSV file. The scene specification tables can contain these columns.
Column | Description |
---|---|
RoadElementID | ID of the road element, specified as a positive integer. |
RoadElementType | Type of road element, specified as one of these road element types:
Note When you specify
|
Length_Radius | Length of the road or radius of curvature for the junction, specified
as a positive scalar. This table describes the values of
|
DeltaHeading | Change in the heading angle of a road, specified as positive scalar.
Units are in degrees. This table describes the values of
|
ParentIntersectionID (optional) | ID of parent intersection junction linked to the current road,
specified as a positive integer. The This value must
be
Note Include the |
LaneSpecID (optional) | ID of the lane specification, specified as a positive integer. The ID
must match a Note Include the |
This example shows a scene specification table and the scene created using it.
Scene Specification Table | Generated Scene |
---|---|
|
|
Lane Specification Table
Lane specification tables must contain these columns.
Column | Description |
---|---|
LaneSpecID | ID of the lane specification, specified as a positive integer. |
LeftLaneCount | Number of left lanes, specified as a positive integer. The
default value is |
RightLaneCount | Number of right lanes, specified as a positive integer. The
default value is |
LaneMarking | Lane marking, specified as The
default value is |
This example shows a scene specification table, a lane specification table, and the scene created using them.
Scene and Lane Specification Tables | Generated Scene |
---|---|
An example of scene specification table: |
|
An example of lane specification table: |
Actor Specification Table
Actor specification tables must contain these columns.
Column | Description |
---|---|
ActorID | ID of the actor, specified as a positive integer. |
RoadID | ID of the road on which to place the actor, specified as a positive integer. |
LaneID | ID of the lane on which to place the actor, specified as a positive integer. |
ActorType | Type of the actor, specified as The
default actor type is |
ActorName | Name of the actor, specified as a string. The default name
is a concatenation of the string |
Dimension | Dimensions of the actor, specified as a six-element row vector of the
form [
For more information on these dimensions, see Actor and Vehicle Positions and Dimensions. If you specify this value in a form other than a six-element row
vector, by default, this function uses this value: [ |
Heading | Travel direction of the actor, specified as The default actor direction is
|
RelativePosition | Start position of the actor on a lane relative to the lane direction,
in percentage, specified as a comma-separated string of the form
[
This figure shows the longitudinal and lateral positions of an actor on a lane, in percentages, relative to the directional lane length and lane width. Note that percentage values are relative to the lane, rather than the road, the actor occupies. The default value of
|
For more information on using the actor specification table, see the Generate Scenario Using Tabular Data example.
Event Specification Table
Actor event specification tables must contain these columns.
Column | Description | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
EventID | ID of the actor event, specified as a positive integer. | ||||||||||||||||||||||||||
ActorID | ID of the actor, specified as a positive integer. | ||||||||||||||||||||||||||
EventType | Type of event, specified as one of these values which are specified in the Event Name column. Initialization Events
Turn Events
Lane Events
Speed Change Event
| ||||||||||||||||||||||||||
Speed | Speed of the actor at the end of the event, specified as a scalar. Units are in meters per second.
| ||||||||||||||||||||||||||
Distance | Distance at which the actor completes the event, specified as a scalar or a three-element row vector. Units are in meters. These table
describes how to specify Initialization Events
Turn Events
Lane Events
Speed Change Event
| ||||||||||||||||||||||||||
EventTrigger | Distance for the actor to travel on its current lane to trigger the event, specified as a positive scalar. Units are in meters. The
default value is |
For more information on using the actor event specification table, see Generate Scenario Using Tabular Data example.
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 thegetScenario
function.
Version History
Introduced in R2024a
See Also
ncapSpec
| ncapScenario
| getScenario
| drivingScenario
| vehicle
| generateVariants
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)