This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Scenario Reader

Read driving scenario into model

  • Library:
  • Automated Driving Toolbox / Driving Scenario and Sensor Modeling

Description

The Scenario Reader block reads the roads and actors from a scenario file created using the Driving Scenario Designer app. The block outputs the poses of actors in either the coordinate system of the ego vehicle or the world coordinates of the scenario. You can also output the lane boundaries.

To generate object and lane boundary detections from output actor poses and lane boundaries, specify the poses and boundaries as inputs to sensor blocks, such as Vision Detection Generator or Radar Detection Generator. Use the generated, synthetic detections to test the performance of sensor fusion algorithms, tracking algorithms, and other automated driving assistance system (ADAS) algorithms. To visualize the performance of these algorithms, use the Bird's-Eye Scope.

You can read the ego vehicle from the scenario file or specify an ego vehicle defined in your model as an input to the Scenario Reader block. Use this option to test closed-loop vehicle controller algorithms, such as autonomous emergency braking (AEB), lane keeping assist (LKA), or adaptive cruise control (ACC).

Limitations

  • The Scenario Reader block does not read sensor data from scenario files saved from the Driving Scenario Designer app. If a scenario file contains radar or vision sensors, the block ignores that sensor data. For the block to read sensor data, you must create sensors in your Simulink® model. For example, you can create these sensors by using Radar Detection Generator and Vision Detection Generator blocks.

  • Large road networks, including OpenDRIVE® road networks, can take up to several minutes to read into models.

Ports

Input

expand all

Ego vehicle pose, specified as a Simulink bus containing a MATLAB structure.

The structure must contain these fields.

FieldDescription
ActorID

Scenario-defined actor identifier, specified as a positive integer.

Position

Position of actor, specified as an [x y z] real-valued vector. Units are in meters.

Velocity

Velocity (v) of actor in the x-, y-, and z-directions, specified as a [vx vy vz] real-valued vector. Units are in meters per second.

Roll

Roll angle of actor, specified as a real scalar. Units are in degrees.

Pitch

Pitch angle of actor, specified as a real scalar. Units are in degrees.

Yaw

Yaw angle of actor, specified as a real scalar. Units are in degrees.

AngularVelocity

Angular velocity (ω) of actor in the x-, y-, and z-directions, specified as an [ωx ωy ωz] real-valued vector. Units are in degrees per second.

Dependencies

To enable this port, set the Source of ego vehicle parameter to Input port.

Output

expand all

Scenario actor poses, returned as a Simulink bus containing a MATLAB structure.

The structure has these fields.

FieldDescriptionType
NumActorsNumber of actors (ego vehicle excluded)Nonnegative integer
TimeCurrent simulation timeReal scalar
ActorsActor poses in ego vehicle coordinatesNumActors-length array of actor pose structures

Each actor pose structure in Actors has these fields.

FieldDescription
ActorID

Scenario-defined actor identifier, specified as a positive integer. ActorID is a required field.

Position

Position of actor, specified as an [x y z] real-valued vector. Position is a required field. Units are in meters.

Velocity

Velocity (v) of actor in the x-, y-, and z-directions, specified as a [vx vy vz] real-valued vector. You can specify either Speed or Velocity, but not both. If bothVelocity and Speed are not specified, a default Velocity of [0 0 0] is used. Units are in meters per second.

Speed

Speed of actor, specified as a real scalar. When Speed is specified, the actor velocity is aligned with the x-axis of the actor in the ego vehicle coordinate system. You can specify either Speed or Velocity, but not both. If both Velocity and Speed are not specified, a default Velocity of [0 0 0] is used. Units are in meters per second.

Roll

Roll angle of actor, specified as a real scalar. If Roll is not specified, the default value is 0. Units are in degrees.

Pitch

Pitch angle of actor, specified as a real scalar. If Pitch is not specified, the default value is 0.Units are in degrees.

Yaw

Yaw angle of actor, specified as a real scalar. If Yaw is not specified, the default value is 0.Units are in degrees.

The pose of the ego vehicle is excluded from the Actors array.

Dependencies

To enable this port, set Source of ego vehicle to Input port.

Scenario lane boundaries, returned as a Simulink bus containing a MATLAB structure.

The structure has these fields.

FieldDescriptionType
NumLaneBoundariesNumber of lane boundariesNonnegative integer
TimeCurrent simulation timeReal scalar
LaneBoundariesLane boundaries in ego vehicle coordinatesNumLaneBoundaries-length array of lane boundary structures

Each lane boundary structure in LaneBoundaries has these fields.

FieldDescription

Coordinates

Lane boundary coordinates, specified as a real-valued N-by-3 matrix, where N is the number of lane boundaries. Lane boundary coordinates define the position of points on the boundary at distances specified by the 'XDistance' name-value pair argument of the laneBoundaries function. In addition, a set of boundary coordinates are inserted into the matrix at zero distance. Units are in meters.

Curvature

Lane boundary curvature at each row of the Coordinates matrix, specified as a real-valued N-by-1 vector. N is the number of lane boundaries. Units are in radians per meter.

CurvatureDerivative

Derivative of lane boundary curvature at each row of the Coordinates matrix, specified as a real-valued N-by-1 vector. N is the number of lane boundaries. Units are in radians per square meter.

HeadingAngle

Initial lane boundary heading angle, specified as a real scalar. The heading angle of the lane boundary is relative to the ego vehicle heading. Units are in degrees.

LateralOffset

Distance of the lane boundary from the ego vehicle position, specified as a real scalar. An offset to a lane boundary to the left of the ego vehicle is positive. An offset to the right of the ego vehicle is negative. Units are in meters.

BoundaryType

Type of lane boundary marking, specified as one of these values:

  • 'Unmarked' — No physical lane marker exists

  • 'Solid' — Single unbroken line

  • 'Dashed' — Single line of dashed lane markers

  • 'DoubleSolid' — Two unbroken lines

  • 'DoubleDashed' — Two dashed lines

  • 'SolidDashed' — Solid line on the left and a dashed line on the right

  • 'DashedSolid' — Dashed line on the left and a solid line on the right

Strength

Strength of the lane boundary marking, specified as a real scalar from 0 to 1. A value of 0 corresponds to a marking that is not visible. A value of 1 corresponds to a marking that is completely visible. Values between 0 and 1 correspond to partially visible markings.

Width

Lane boundary width, specified as a positive real scalar. In a double-line lane marker, the same width is used for both lines and for the space between lines. Units are in meters.

Length

Length of dash in dashed lines, specified as a positive real scalar. In a double-line lane marker, the same length is used for both lines.

Space

Length of space between dashes in dashed lines, specified as a positive real scalar. In a dashed double-line lane marker, the same space is used for both lines.

The number of returned lane boundary structures depends on the Lane boundaries to output parameter value.

Dependencies

To enable this port, set Lane boundaries to output to Ego lane boundaries or All lane boundaries.

Parameters

expand all

Driving scenario file name, specified as a scenario file that is on the MATLAB search path or as the full path to a scenario file. A scenario file is a MAT-file saved from the Driving Scenario Designer app. Scenarios stored in a drivingScenario object are not supported.

You can specify a scenario file containing all roads, actors, and sensors, or a scenario file containing only roads and actors. Scenario files containing only sensors are not supported. If the specified scenario file contains sensor data, the block ignores that data.

The default scenario file shows an ego vehicle traveling north on a straight, two-lane road, with another vehicle traveling south in the opposite lane.

To add a scenario file to the MATLAB search path, use the addpath function. For example, this code adds the set of folders containing prebuilt Euro NCAP® scenarios to the MATLAB search path.

path = fullfile(matlabroot,'toolbox','driving','drivingdata', ...
    'PrebuiltScenarios','EuroNCAP');
addpath(genpath(path))

In the Driving scenario file name parameter, you can then specify the name of any scenario located in these folders, without having to specify the full file path. For example: AEB_PedestrianChild_Nearside_50width.mat

When you are done using the scenario in your models, you can remove any added folders from the MATLAB search path by using the rmpath function

rmpath(genpath(path))

Coordinate system of the output actors and lane boundaries, specified as one of these values:

  • Vehicle Coordinates — Coordinates are defined with respect to the ego vehicle. Select this value when your scenario has only one ego vehicle.

  • World Coordinates — Coordinates are defined with respect to the driving scenario. Select this value in multi-agent scenarios that contain more than one ego vehicle. If you select this value, model visualization using the Bird's-Eye Scope is not supported.

For more details on the vehicle and world coordinate systems, see Coordinate Systems in Automated Driving Toolbox.

Source of ego vehicle, specified as one of these options:

  • Scenario file — Use the ego vehicle defined in the scenario file specified by the Driving scenario file name parameter. The pose of the ego vehicle is excluded from the Actors output port. Select this option to test open-loop ADAS algorithms, where the ego vehicle behavior is predefined and does not change as the scenario advances. For an example, see Test Open-Loop ADAS Algorithm Using Driving Scenario.

  • Input port — Specify the ego vehicle by using the Ego Vehicle input port. The pose of the ego vehicle is not included in the Actors output port. Select this option to test closed-loop ADAS algorithms, where the ego vehicle reacts to changes as the scenario advances. For an example, see Test Closed-Loop ADAS Algorithm Using Driving Scenario.

Dependencies

To enable this parameter, set Coordinate system of outputs to Vehicle coordinates.

Sample time of simulation, in seconds, specified as a positive real scalar. Inherited and continuous sample times are not supported. This sample time value is separate from the sample time used when simulating the scenario in the Driving Scenario Designer app.

Lane boundaries to output, specified as one of these options:

  • None — Do not output any lane boundaries.

  • Ego vehicle lane boundaries — Output the left and right lane boundaries of the ego vehicle.

  • All lane boundaries — Output all lane boundaries of the road on which the ego vehicle is traveling.

If you select Ego vehicle lane boundaries or All lane boundaries, then the block returns the lane boundaries in the Lane Boundaries output port.

Dependencies

To enable this parameter, set Coordinate system of outputs to Vehicle coordinates.

Distances ahead of the ego vehicle at which to compute the lane boundaries, specified as an N-element real-valued vector. N is the number of distance values. Units are in meters.

Example: 1:0.1:10 computes the lane boundaries every 0.1 meters over the range from 1 to 10 meters ahead of the ego vehicle.

Lane boundary location on the lane markings, specified as one of the options in this table.

Lane Boundary LocationDescriptionExample
Center of lane markingsLane boundaries are centered on the lane markings.

A three-lane road has four lane boundaries: one per lane marking.

Inner edge of lane markingsLane boundaries are placed at the inner edges of the lane markings.

A three-lane road has six lane boundaries: two per lane.

Source of the name for the actor poses bus returned in the Actors output port, specified as one of these options:

  • Auto — The block automatically creates an actor poses bus name.

  • Property — Specify the actor poses bus name by using the Actors bus name parameter.

Name of the actor poses bus returned in the Actors output port, specified as a valid bus name.

Dependencies

To enable this parameter, set Source of actors bus name to Property.

Source of the name for the lane boundaries bus returned in the Lane Boundaries output port, specified as one of these options:

  • Auto — The block automatically creates a lane boundaries bus name.

  • Property — Specify the lane boundaries bus name by using the Lane boundaries bus name parameter.

Dependencies

To enable this parameter, set Lane boundaries to output to Ego vehicle lane boundaries or All lane boundaries.

Name of the lane boundaries bus returned in the Lane Boundaries output port, specified as a valid bus name.

Dependencies

To enable this parameter:

  1. Set Lane boundaries to output to Ego vehicle lane boundaries or All lane boundaries.

  2. Set Source of lane boundaries bus name to Property.

  • Interpreted execution — Simulate the model using the MATLAB interpreter. This option shortens startup time. In Interpreted execution mode, you can debug the source code of the block.

  • Code generation — Simulate the model using generated C code. The first time you run a simulation, Simulink generates C code for the block. The C code is reused for subsequent simulations as long as the model does not change. This option requires additional startup time.

Tips

  • For best results, use only one active Scenario Reader block per model. To use multiple Scenario Reader blocks in one model, switch between the blocks by specifying them in a variant subsystem.

  • To update the scenario between simulations, open the scenario file in the Driving Scenario Designer app, update the parameters, and resave the file. To switch between scenarios with different parameter settings, you can use Simulink Test™ software. For an example, see Testing a Lane-Following Controller with Simulink Test (Simulink Test).

Extended Capabilities

Introduced in R2019a