Driving Scenario Designer

Design driving scenarios, configure sensors, and generate synthetic object detections

Description

The Driving Scenario Designer app enables you to design synthetic driving scenarios for testing your autonomous driving systems.

Using the app, you can:

  • Create road and actor models using a drag-and-drop interface.

  • Configure vision and radar sensors mounted on the ego vehicle, and use these sensors to simulate detections of actors and lane boundaries in the scenario.

  • Load driving scenarios representing European New Car Assessment Programme (Euro NCAP®) test protocols [1][2][3] and other prebuilt scenarios.

  • Import OpenDRIVE® roads and lanes into a driving scenario. The app supports OpenDRIVE format specification version 1.4H [4].

  • Import roads data from the HERE HD Live Map[1] web service into a driving scenario.

  • Export synthetic sensor detections to MATLAB®.

  • Generate MATLAB code of the scenario and sensors, and then programmatically modify the scenario and import it back into the app for further simulation.

  • Generate a Simulink® model from the scenario and sensors, and use the generated models to test your sensor fusion or vehicle control algorithms.

To learn more about the app, see Driving Scenario Designer.

Open the Driving Scenario Designer App

  • MATLAB Toolstrip: On the Apps tab, under Automotive, click the app icon.

  • MATLAB command prompt: Enter drivingScenarioDesigner.

Examples

expand all

Build a driving scenario of a vehicle driving down a curved road, and export the road and vehicle models to the MATLAB workspace. For a more detailed example of building a driving scenario, see Build a Driving Scenario and Generate Synthetic Detections.

Open the Driving Scenario Designer app.

drivingScenarioDesigner

Create a curved road. On the app toolstrip, click Add Road. Click the bottom of the canvas, extend the road path to the middle of the canvas, and click the canvas again. Extend the road path to the top of the canvas, and then double-click to create the road. To make the curve more complex, click and drag the road centers (open circles), or double-click the road to add more road centers.

Add lanes to the road. In the left pane, on the Roads tab, expand the Lanes section. Set the Number of lanes to 2.

By default, the road is one-way and has solid lane markings on either side to indicate the shoulder.

Add a vehicle at one end of the road. On the app toolstrip, select Add Actor > Car. Then click the road to set the initial position of the car.

Set the driving path of the car. Right-click the car, select Add Waypoints, and add waypoints for the car to pass through. After you add the last waypoint, press Enter. The car autorotates in the direction of the first waypoint.

Adjust the speed of the car as it passes between waypoints. In the left pane, on the Actors tab, in the Trajectory section, clear the Constant Speed check box. Then, in the Waypoints table, set the velocity, v (m/s), of the car in m/s as it enters each waypoint segment. To model more realistic conditions, increase the speed of the car for the straight segments and decrease its speed for the curved segments. For example:

Run the scenario, and adjust settings as needed. Then click Save > Roads & Actors to save the road and car models to a MAT-file.

Generate vision sensor detections from a prebuilt driving scenario of a Euro NCAP test protocol.

Load a Euro NCAP autonomous emergency braking (AEB) scenario of a collision with a pedestrian child. At collision time, the point of impact occurs 50% of the way across the width of the car.

path = fullfile(matlabroot,'toolbox','shared','drivingscenario', ...
    'PrebuiltScenarios','EuroNCAP');
addpath(genpath(path)) % Add folder to path
drivingScenarioDesigner('AEB_PedestrianChild_Nearside_50width.mat')
rmpath(path) % Remove folder from path

Add a front-facing radar sensor to the ego vehicle. First click Add Radar. Then, on the Sensor Canvas, click the predefined sensor location at the front window of the car. By default, the radar is long-range.

Run the scenario. Inspect different aspects of the scenario by toggling between canvases and views. You can toggle between the Sensor Canvas and Scenario Canvas and between the Bird's-Eye Plot and Ego-Centric View.

Export the sensor data to the MATLAB workspace. Click Export > Export Sensor Data, enter a workspace variable name, and click OK.

Programmatically create a driving scenario, radar sensor, and camera sensor, and then import the scenario and sensors into the app. For more details on working with programmatic driving scenarios and sensors, see Create Driving Scenario Variations Programmatically.

Create a simple driving scenario by using a drivingScenario object. In this scenario, the ego vehicle travels straight on a 50-meter road segment at a constant speed of 30 meters per second. For the ego vehicle, specify a ClassID of 1. This value corresponds to the app Class ID of 1, which refers to actors of class Car. For more details on how the app defines classes, see the Class parameter description in the Actors parameter tab.

scenario = drivingScenario;
roadCenters = [0 0 0; 50 0 0];
road(scenario, roadCenters);

egoVehicle = vehicle(scenario,'ClassID',1,'Position',[5 0 0]);
waypoints = [5 0 0; 45 0 0];
speed = 30;
trajectory(egoVehicle,waypoints,speed);

Create a radar sensor by using a radarDetectionGenerator object, and create a camera sensor by using a visionDetectionGenerator object. Place both sensors at the vehicle origin, with the radar facing forward and the camera facing backward.

radar = radarDetectionGenerator('SensorLocation',[0 0]);
camera = visionDetectionGenerator('SensorLocation',[0 0],'Yaw',-180);

Import the scenario, front-facing radar sensor, and rear-facing camera sensor into the app.

drivingScenarioDesigner(scenario,{radar,camera})

You can then run the scenario and modify the scenario and sensors. To generate new drivingScenario, radarDetectionGenerator, and visionDetectionGenerator objects, on the app toolstrip, select Export > Export MATLAB Function, and then run the generated function.

Load a driving scenario containing a sensor and generate a Simulink model from the scenario and sensor. For a more detailed example on generating Simulink models from the app, see Generate Sensor Detection Blocks Using Driving Scenario Designer.

Load a prebuilt driving scenario into the app. The scenario contains two vehicles crossing through an intersection. The ego vehicle travels north and contains a camera sensor. This sensor is configured to detect both objects and lanes.

path = fullfile(matlabroot,'toolbox','shared','drivingscenario','PrebuiltScenarios');
addpath(genpath(path)) % Add folder to path
drivingScenarioDesigner('EgoVehicleGoesStraight_VehicleFromLeftGoesStraight.mat')
rmpath(path) % Remove folder from path

Generate a Simulink model of the scenario and sensor. On the app toolstrip, select Export > Export Simulink Model. If you are prompted, save the scenario file.

The Scenario Reader block reads the road and actors from the scenario file. To update the scenario data in the model, update the scenario in the app and save the file.

The Vision Detection Generator block recreates the camera sensor defined in the app. To update the sensor in the model, update the sensor in the app, select Export > Export Sensor Simulink Model, and copy the newly generated sensor block into the model. If you updated any roads or actors while updating the sensors, then select Export > Export Simulink Model. In this case, the Scenario Reader block accurately reads the actor profile data and passes it to the sensor.

Create a scenario with vehicle trajectories that you can later recreate in Simulink for simulation in a 3D environment.

Open one of the prebuilt scenarios that recreates a default scene available through the 3D environment. On the app toolstrip, select Open > Prebuilt Scenario > Simulation3D and select a scenario. For example, select the DoubleLaneChange.mat scenario.

Specify a vehicle and its trajectory.

Update the dimensions of the vehicle to match the dimensions of the predefined vehicle types in the 3D simulation environment.

  1. On the Actors tab, select the 3D Display Type option you want.

  2. On the app toolstrip, select 3D Display > Use 3D Simulation Actor Dimensions. In the Scenario Canvas, the actor dimensions update to match the predefined dimensions of the actors in the 3D simulation environment.

Preview how the scenario will look when you later recreate it in Simulink. On the app toolstrip, select 3D Display > View Simulation in 3D Display. After the 3D display window opens, click Run.

Modify the vehicle and trajectory as needed. Avoid changing the road network or the actors that were predefined in the scenario. Otherwise, the app scenario will not match the scenario that you later recreate in Simulink. If you change the scenario, the 3D display window closes.

When you are done modifying the scenario, you can recreate it in a Simulink model for use in the 3D simulation environment. For an example that shows how to set up such a model, see Visualize 3D Simulation Sensor Coverages and Detections.

Related Examples

Parameters

To enable the Roads parameters, add at least one road to the scenario. Then, select a road from either the Scenario Canvas or the Road parameter. The parameter values in the Roads tab are based on the road you select.

ParameterDescription
Road

Road to modify, specified as a list of the roads in the scenario.

Name

Name of road.

Width (m)

Width of the road, in meters, specified as a decimal scalar in the range (0, 50].

If the curvature of the road is too sharp to accommodate the specified road width, the app does not generate the road.

Default: 6

Bank Angle (deg)

Side-to-side incline of the road, in degrees, specified as one of these values:

  • Decimal scalar — Applies a uniform bank angle along the entire length of the road

  • N-element vector of decimal values — Applies a different bank angle to each road center, where N is the number of road centers in the selected road

When you add an actor to a road, you do not have to change the actor position to match the bank angles specified by this parameter. The actor automatically follows the bank angles of the road.

Default: 0

Lanes

ParameterDescription
Number of lanes

Number of lanes in the road, specified as one of these values:

  • Integer, M, in the range [1, 30] — Creates an M-lane road whose default lane markings indicate that the road is one-way.

  • Two-element vector, [M N], where M and N are positive integers whose sum must be in the range [2, 30] — Creates a road with (M + N) lanes. The default lane markings of this road indicate that it is two-way. The first M lanes travel in one direction. The next N lanes travel in the opposite direction.

If you increase the number of lanes, the added lanes are of the width specified in the Lane Width (m) parameter. If Lane Width (m) is a vector of differing lane widths, then the added lanes are of the width specified in the last vector element.

Lane Width (m)

Width of each lane in the road, in meters, specified as one of these values:

  • Decimal scalar in the range (0, 50] — The same width applies to all lanes.

  • N-element vector of decimal values in the range (0, 50] — A different width applies to each lane, where N is the total number of lanes specified in the Number of lanes parameter.

The width of each lane must be greater than the width of the lane markings it contains. These lane markings are specified by the Marking > Width (m) parameter.

Lane TypesLanes in the road, specified as a list of the lane types in the selected road. To modify one or more lane parameters that include lane type, color, and strength, select the desired lane from the drop-down list.
Lane Types > Type

Type of lane, specified as one of these values:

  • 'Driving' — Lanes for driving.

  • 'Border' — Lanes at the road borders.

  • 'Restricted' — Lanes reserved for high occupancy vehicles.

  • 'Shoulder' — Lanes reserved for emergency stopping.

  • 'Parking'— Lanes alongside driving lanes, intended for parking vehicles.

Default: 'Driving'

Lane Types > Color

Color of lane, specified as an RGB triplet with default values as:

TypeColor (Default values)
'Driving'[0.8 0.8 0.8]
'Border'[0.72 0.72 0.72]
'Restricted'[0.59 0.56 0.62]
'Shoulder'[0.59 00.59 0.59]
'Parking'[0.28 0.28 0.28]

Alternatively, you can also specify some common colors as an RGB triplet, hexadecimal color code, color name, or short color name. For more information, see Color Specifications for Lanes and Markings.

Lane Types > Strength

Saturation strength of lane color, specified as a decimal scalar in the range [0, 1].

  • A value of 0 specifies that the lane color is fully unsaturated, resulting in a gray colored lane.

  • A value of 1 specifies that the lane color is fully saturated, resulting in a true colored lane.

Default: 1

Lane Markings

Lane markings, specified as a list of the lane markings in the selected road. To modify one or more lane marking parameters which include marking type, color, and strength, select the desired lane marking from the drop-down list.

A road with N lanes has (N + 1) lane markings.

Lane Markings > Specify multiple marker types along a lane

Select this parameter to define composite lane markings. A composite lane marking comprises multiple marker types along a lane. The portion of the lane marking that contains each marker type is referred as a marker segment. For more information on composite lane markings, see Composite Lane Marking.

Lane Markings > Number of Segments

Number of marker segments in a composite lane marking, specified as an integer greater than or equal to 2. A composite lane marking must have at least two marker segments.

Default: 2

Dependencies

To enable this parameter, select the Specify multiple marker types along a lane parameter.

Lane Markings > Segment Range

Normalized range for each marker segment in a composite lane marking, specified as a row vector of values in the range [0, 1].. The length of the vector must be equal to the Number of Segments parameter value.

Default: [0.5 0.5]

Dependencies

To enable this parameter, select the Specify multiple marker types along a lane parameter.

Lane Markings > Marker Segment

Marker segments, specified as a list of marker types in the selected lane marking. To modify one or more marker segment parameters that include marking type, color, and strength, select the desired marker segment from the drop-down list.

Dependencies

To enable this parameter, select the Specify multiple marker types along a lane parameter.

Lane Markings > Type

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

  • Unmarked — No lane marking

  • Solid — Solid line

  • Dashed — Dashed line

  • DoubleSolid — Two solid lines

  • DoubleDashed — Two dashed lines

  • SolidDashed — Solid line on left, dashed line on right

  • DashedSolid — Dashed line on left, solid line on right

By default, for a one-way road, the leftmost lane marking is a solid yellow line, the rightmost lane marking is a solid white line, and the markings for the inner lanes are dashed white lines. For two-way roads, the default outermost lane markings are both solid white lines and the dividing lane marking is two solid yellow lines.

If you enable the Specify multiple marker types along a lane parameter, then this value is applied to the selected marker segment in a composite lane marking.

Lane Markings > Color

Color of lane marking, specified as an RGB triplet, hexadecimal color code, color name, or short color name. For a lane marker specifying a double line, the same color is used for both lines.

You can also specify some common colors as an RGB triplet, hexadecimal color code, color name, or short color name. For more information, see Color Specifications for Lanes and Markings.

If you enable the Specify multiple marker types along a lane parameter, then this value is applied to the selected marker segment in a composite lane marking.

Lane Markings > Strength

Saturation strength of lane marking color, specified as a decimal scalar in the range [0, 1].

  • A value of 0 specifies that the lane marking color is fully unsaturated, resulting in a gray colored lane marking.

  • A value of 1 specifies that the lane marking color is fully saturated, resulting in a true colored lane marking.

For a lane marker specifying a double line, the same strength is used for both lines.

Default: 1

If you enable the Specify multiple marker types along a lane parameter, then this value is applied to the selected marker segment in a composite lane marking.

Lane Markings > Width (m)

Width of lane marking, in meters, specified as a positive decimal scalar.

The width of the lane marking must be less than the width of its enclosing lane. The enclosing lane is the lane directly to the left of the lane marking.

For a lane marker specifying a double line, the same width is used for both lines.

Default: 0.15

If you enable the Specify multiple marker types along a lane parameter, then this value is applied to the selected marker segment in a composite lane marking.

Lane Markings > Length (m)

Length of dashes in dashed lane markings, in meters, specified as a decimal scalar in the range (0, 50].

For a lane marker specifying a double line, the same length is used for both lines.

Default: 3

If you enable the Specify multiple marker types along a lane parameter, then this value is applied to the selected marker segment in a composite lane marking.

Lane Markings > Space (m)

Length of spaces between dashes in dashed lane markings, in meters, specified as a decimal scalar in the range (0, 150].

For a lane marker specifying a double line, the same space is used for both lines.

Default: 9

If you enable the Specify multiple marker types along a lane parameter, then this value is applied to the selected marker segment in a composite lane marking.

Road Centers

Each row of the Road Centers table contains the x-, y-, and z-positions of a road center within the selected road. All roads must have at least two unique road center positions. When you update a cell within the table, the Scenario Canvas updates to reflect the new road center position. The orientation of the road depends on the values of the road centers. The road centers specifies the direction in which the road renders in the Scenario Canvas. For more information, see Draw Direction of Road and Numbering of Lanes.

ParameterDescription
x (m)x-axis position of the road center, in meters, specified as a decimal scalar.
y (m)y-axis position of the road center, in meters, specified as a decimal scalar.
z (m)

z-axis position of the road center, in meters, specified as a decimal scalar.

  • The z-axis specifies the elevation of the road. If the elevation between road centers is too abrupt, adjust these elevation values.

  • When you add an actor to a road, you do not have to change the actor position to match changes in elevation. The actor automatically follows the elevation of the road.

  • When two elevated roads form a junction, the elevation around that junction can vary widely. The exact amount of elevation depends on how close the road centers of each road are to each other. If you try to place an actor at the junction, the app might be unable to compute the precise elevation of the actor. In this case, the app cannot place the actor at that junction.

    To address this issue, in the Scenario Canvas, modify the intersecting roads by moving the road centers of each road away from each other. Alternatively, manually adjust the elevation of the actor to match the elevation of the road surface.

Default: 0

To enable the Actors parameters, add at least one actor to the scenario. Then, select an actor from either the Scenario Canvas or from the list on the Actors tab. The parameter values in the Actors tab are based on the actor you select.

ParameterDescription
Color

To change the color of an actor, next to the actor selection list, click the color patch for that actor.

Then, use the color picker to select one of the standard colors commonly used in MATLAB graphics. Alternatively, select a custom color from the Custom Colors tab by first clicking in the upper-right corner of the Color dialog box. You can then select custom colors from a gradient or specify a color using an RGB triplet, hexadecimal color code, or HSV triplet.

By default, the app sets each newly created actor to a new color. This color order is based on the default color order of Axes objects. For more details, see the ColorOrder property for Axes objects.

To set a single default color for all newly created actors of a specific class, on the app toolstrip, select Add Actor > Edit Actor Classes. Then, select Set Default Color and click the corresponding color patch to set the color. To select a default color for a class, the Scenario Canvas must contain no actors of that class.

Color changes made in the app are carried forward into Bird's-Eye Scope visualizations.

Set as Ego Vehicle

Set the selected actor as the ego vehicle in the scenario.

When you add sensors to your scenario, the app adds them to the ego vehicle. In addition, the Ego-Centric View and Bird's-Eye Plot windows display simulations from the perspective of the ego vehicle.

Only actors who have vehicle classes, such as Car or Truck, can be set as the ego vehicle. The ego vehicle must also have a 3D Display Type parameter value other than Cuboid.

For more details on actor classes, see the Class parameter description.

Name

Name of actor.

Class

Class of actor, specified as the list of classes to which you can change the selected actor.

You can change the class of vehicle actors only to other vehicle classes. The default vehicle classes are Car and Truck. Similarly, you can change the class of nonvehicle actors only to other nonvehicle classes. The default nonvehicle classes are Pedestrian, Bicycle, and Barrier.

The list of vehicle and nonvehicle classes appear in the app toolstrip, in the Add Actor > Vehicles and Add Actor > Other sections, respectively.

Actors created in the app have default sets of dimensions, radar cross-section patterns, and other properties based on their Class ID value. The table shows the default Class ID values and actor classes.

Class IDActor Class
1Car
2Truck
3Bicycle
4Pedestrian
5Barrier

To modify actor classes or create new actor classes, on the app toolstrip, select Add Actor > Edit Actor Classes or Add Actor > New Actor Class, respectively.

3D Display Type

Display type of actor as it appears in the 3D display window, specified as the list of display types to which you can change the selected actor.

To display the scenario in the 3D display window during simulation, on the app toolstrip, click 3D Display > View Simulation in 3D Display. The app renders this display by using the Unreal Engine® from Epic Games®.

For any actor, the available 3D Display Type options depend on the actor class specified in the Class parameter.

Actor Class3D Display Type Options
Car
  • Sedan (default for Car class)

  • Muscle Car

  • SUV

  • Small Pickup Truck

  • Hatchback

  • Box Truck (default for Truck class)

  • Cuboid (default for custom vehicle classes)

Truck

Custom vehicle class

To create a custom vehicle class:

  1. On the app toolstrip, select Add Actor > New Actor Class.

  2. In the Class Editor window, select the Vehicle parameter.

  3. Set other class properties as needed and click OK.

Bicycle
  • Bicyclist (default for Bicycle class)

  • Male Pedestrian (default for Pedestrian class)

  • Female Pedestrian

  • Barrier (default for Barrier class)

  • Cuboid (default for custom nonvehicle classes)

Pedestrian
Barrier

Custom nonvehicle class

To create a custom nonvehicle class:

  1. On the app toolstrip, select Add Actor > New Actor Class.

  2. In the Class Editor window, clear the Vehicle parameter.

  3. Set other class properties as needed and click OK.

If you change the dimensions of an actor using the Actor Properties parameters, the app applies these changes in the Scenario Canvas display but not in the 3D display. This case does not apply to actors whose 3D Display Type is set to Barrier or Cuboid. The dimensions of these actors change in both displays.

In the 3D display, actors of all other display types have predefined dimensions. To use the same dimensions in both displays, you can apply the predefined 3D display dimensions to the actors in the Scenario Canvas display. On the app toolstrip, under 3D Display, select Use 3D Simulation Actor Dimensions.

Actor Properties

Actor properties include the position and orientation of an actor.

ParameterDescription
Length (m)

Length of actor, in meters, specified as a decimal scalar in the range (0, 60].

For vehicles, the length must be greater than (Front Overhang + Rear Overhang).

Width (m)

Width of actor, in meters, specified as a decimal scalar in the range (0, 20].

Height (m)

Height of actor, in meters, specified as a decimal scalar in the range (0, 20].

Front Overhang

Distance between the front axle and front bumper, in meters, specified as a decimal scalar.

The front overhang must be less than (Length (m)Rear Overhang).

This parameter applies to vehicles only.

Default: 0.9

Rear Overhang

Distance between the rear axle and rear bumper, in meters, specified as a decimal scalar.

The rear overhang must be less than (Length (m)Front Overhang).

This parameter applies to vehicles only.

Default: 1

Roll

Orientation angle of the actor about its x-axis, in degrees, specified as a decimal scalar.

Roll is clockwise-positive when looking in the forward direction of the x-axis, which points forward from the actor.

When you export the MATLAB function of the driving scenario and run that function, the roll angles of actors in the output scenario are wrapped to the range [–180, 180].

Default: 0

Pitch

Orientation angle of the actor about its y-axis, in degrees, specified as a decimal scalar.

Pitch is clockwise-positive when looking in the forward direction of the y-axis, which points to the left of the actor.

When you export the MATLAB function of the driving scenario and run that function, the pitch angles of actors in the output scenario are wrapped to the range [–180, 180].

Default: 0

Yaw

Orientation angle of the actor about its z-axis, in degrees, specified as a decimal scalar.

Yaw is clockwise-positive when looking in the forward direction of the z-axis, which points up from the ground. However, the Scenario Canvas has a bird's-eye-view perspective that looks in the reverse direction of the z-axis. Therefore, when viewing actors on this canvas, Yaw is counterclockwise-positive.

When you export the MATLAB function of the driving scenario and run that function, the yaw angles of actors in the output scenario are wrapped to the range [–180, 180].

Default: 0

Radar Cross Section

Use these parameters to manually specify the radar cross-section (RCS) of an actor. Alternatively, to import an RCS from a file or from the MATLAB workspace, expand this parameter section and click Import.

ParameterDescription
Azimuth Angles (deg)

Horizontal reflection pattern of actor, in degrees, specified as a vector of monotonically increasing decimal values in the range [–180, 180].

Default: [-180 180]

Elevation Angles (deg)

Vertical reflection pattern of actor, in degrees, specified as a vector of monotonically increasing decimal values in the range [–90, 90].

Default: [-90 90]

Pattern (dBsm)

RCS pattern, in decibels per square meter, specified as a Q-by-P table of decimal values. RCS is a function of the azimuth and elevation angles, where:

  • Q is the number of elevation angles specified by the Elevation Angles (deg) parameter.

  • P is the number of azimuth angles specified by the Azimuth Angles (deg) parameter.

Trajectory

Manually set or modify the positions and velocities of actors at their specified waypoints.

ParameterDescription
Wait Time at Waypoints (s)

Select this parameter to enable pausing an actor at selected waypoints along the trajectory.

If you select this parameter, use the Waypoints table to specify the wait time for an actor at one or more selected waypoints. When you set the wait time to a positive value, the corresponding velocity value v (m/s) resets to 0. You cannot set wait times at consecutive waypoints along the trajectory of an actor to positive value.

Default: 0

Constant Speed (m/s)

Select this parameter to set a constant speed for the actor through all of its waypoints. Specify this constant speed as a positive decimal scalar in meters per second.

If you clear this parameter, use the Waypoints table to specify the velocity of the actor at each waypoint.

Default: 30

Waypoints

Actor waypoints, specified as a table.

Each row corresponds to a waypoint and contains the position and velocity information of the actor at that waypoint. The table columns are:

  • x (m) — World coordinate x-position of each waypoint in meters.

  • y (m) — World coordinate y-position of each waypoint in meters.

  • z (m) — World coordinate z-position of each waypoint in meters.

  • v (m/s) — Vehicle velocity, in meters per second, at each waypoint. To enable this column, clear the Constant Speed (m/s) parameter.

  • w (s) — Wait time for an actor, in seconds, at each waypoint. To enable this column, select the Wait Time at Waypoints parameter.

To access these parameters, add at least one camera sensor to the scenario by following these steps:

  1. On the app toolstrip, click Add Camera.

  2. From the Sensors tab, select the sensor from the list. The parameter values in this tab are based on the sensor you select.

ParameterDescription
EnabledEnable or disable the selected sensor. Select this parameter to capture sensor data during simulation and visualize that data in the Bird's-Eye Plot pane.
NameName of sensor.
Update Interval (ms)

Frequency at which the sensor updates, in milliseconds, specified as an integer multiple of the app sample time defined under Settings, in the Sample Time (ms) parameter.

The default Update Interval (ms) value of 100 is an integer multiple of the default Sample Time (ms) parameter value of 10. Having the update interval be a multiple of the sample time ensures that the app samples and displays the detections found at these intervals during simulation.

If you update the app sample time such that a sensor is no longer a multiple of the app sample time, the app prompts you with the option to automatically update the Update Interval (ms) parameter to the closest integer multiple.

Default: 100

TypeType of sensor, specified as either Radar for radar sensors or Vision for camera sensors.

Sensor Placement

ParameterDescription
X (m)

X-axis position of the sensor in the vehicle coordinate system, in meters, specified as a decimal scalar.

The X-axis points forward from the vehicle. The origin is located at the center of the vehicle's rear axle.

Y (m)

Y-axis position of the sensor in the vehicle coordinate system, in meters, specified as a decimal scalar.

The Y-axis points to the left of the vehicle. The origin is located at the center of the vehicle's rear axle.

Height (m)

Height of the sensor above the ground, in meters, specified as a positive decimal scalar.

Default: 1.1

Roll

Orientation angle of the sensor about its X-axis, in degrees, specified as a decimal scalar.

Roll is clockwise-positive when looking in the forward direction of the X-axis, which points forward from the sensor.

Default: 0

Pitch

Orientation angle of the sensor about its Y-axis, in degrees, specified as a decimal scalar.

Pitch is clockwise-positive when looking in the forward direction of the Y-axis, which points to the left of the sensor.

Default: 1

Yaw

Orientation angle of the sensor about its Z-axis, in degrees, specified as a decimal scalar.

Yaw is clockwise-positive when looking in the forward direction of the Z-axis, which points up from the ground. However, the Sensor Canvas has a bird's-eye-view perspective that looks in the reverse direction of the Z-axis. Therefore, when viewing sensor coverage areas on this canvas, Yaw is counterclockwise-positive.

Camera Settings

ParameterDescription
Focal Length X

Horizontal point at which the camera is in focus, in pixels, specified as a positive decimal scalar.

The default focal length changes depending on where you place the sensor on the ego vehicle.

Focal Length Y

Vertical point at which the camera is in focus, in pixels, specified as a positive decimal scalar.

The default focal length changes depending on where you place the sensor on the ego vehicle.

Image Width

Horizontal camera resolution, in pixels, specified as a positive integer.

Default: 640

Image Height

Vertical camera resolution, in pixels, specified as a positive integer.

Default: 480

Principal Point X

Horizontal image center, in pixels, specified as a positive decimal scalar.

Default: 320

Principal Point Y

Vertical image center, in pixels, specified as a positive decimal scalar.

Default: 240

Detection Parameters

To view all camera detection parameters in the app, expand the Sensor Limits, Lane Settings, and Accuracy & Noise Settings sections.

ParameterDescription
Detection Type

Type of detections reported by camera, specified as one of these values:

  • Objects — Report object detections only.

  • Objects & Lanes — Report object and lane boundary detections.

  • Lanes — Report lane boundary detections only.

Default: Objects

Detection Probability

Probability that the camera detects an object, specified as a decimal scalar in the range (0, 1].

Default: 0.9

False Positives Per Image

Number of false positives reported per update interval, specified as a nonnegative decimal scalar. This value must be less than or equal to the maximum number of detections specified in the Limit # of Detections parameter.

Default: 0.1

Limit # of Detections

Select this parameter to limit the number of simultaneous object detections that the sensor reports. Specify Limit # of Detections as a positive integer less than 263.

To enable this parameter, set the Detection Type parameter to Objects or Objects & Lanes.

Default: off

Detection Coordinates

Coordinate system of output detection locations, specified as one of these values:

  • Ego Cartesian — The app outputs detections in the coordinate system of the ego vehicle.

  • Sensor Cartesian — The app outputs detections in the coordinate system of the sensor.

Default: Ego Cartesian

Sensor Limits

ParameterDescription
Max Speed (m/s)

Fastest relative speed at which the camera can detect objects, in meters per second, specified as a nonnegative decimal scalar.

Default: 50

Max Range (m)

Farthest distance at which the camera can detect objects, in meters, specified as a positive decimal scalar.

Default: 150

Max Allowed Occlusion

Maximum percentage of object that can be blocked while still being detected, specified as a decimal scalar in the range [0, 1).

Default: 0.5

Min Object Image Width

Minimum horizontal size of objects that the camera can detect, in pixels, specified as positive decimal scalar.

Default: 15

Min Object Image Height

Minimum vertical size of objects that the camera can detect, in pixels, specified as positive decimal scalar.

Default: 15

Lane Settings

ParameterDescription
Lane Update Interval (ms)

Frequency at which the sensor updates lane detections, in milliseconds, specified as a decimal scalar.

Default: 100

Min Lane Image Width

Minimum horizontal size of objects that the sensor can detect, in pixels, specified as a decimal scalar.

To enable this parameter, set the Detection Type parameter to Lanes or Objects & Lanes.

Default: 3

Min Lane Image Height

Minimum vertical size of objects that the sensor can detect, in pixels, specified as a decimal scalar.

To enable this parameter, set the Detection Type parameter to Lanes or Objects & Lanes.

Default: 20

Boundary Accuracy

Accuracy with which the sensor places a lane boundary, in pixels, specified as a decimal scalar.

To enable this parameter, set the Detection Type parameter to Lanes or Objects & Lanes.

Default: 3

Limit # of Lanes

Select this parameter to limit the number of lane detections that the sensor reports. Specify Limit # of Lanes as a positive integer.

To enable this parameter, set the Detection Type parameter to Lanes or Objects & Lanes.

Default: off

Accuracy & Noise Settings

ParameterDescription
Bounding Box Accuracy

Positional noise used for fitting bounding boxes to targets, in pixels, specified as a positive decimal scalar.

Default: 5

Process Noise Intensity (m/s^2)

Noise intensity used for smoothing position and velocity measurements, in meters per second squared, specified as a positive decimal scalar.

Default: 5

Has Noise

Select this parameter to enable adding noise to sensor measurements.

Default: off

To access these parameters, add at least one radar sensor to the scenario.

  1. On the app toolstrip, click Add Radar.

  2. On the Sensors tab, select the sensor from the list. The parameter values changes based on the sensor you select.

ParameterDescription
EnabledEnable or disable the selected sensor. Select this parameter to capture sensor data during simulation and visualize that data in the Bird's-Eye Plot pane.
NameName of sensor.
Update Interval (ms)

Frequency at which the sensor updates, in milliseconds, specified as an integer multiple of the app sample time defined under Settings, in the Sample Time (ms) parameter.

The default Update Interval (ms) value of 100 is an integer multiple of the default Sample Time (ms) parameter value of 10. Having the update interval be a multiple of the sample time ensures that the app samples and displays the detections found at these intervals during simulation.

If you update the app sample time such that a sensor is no longer a multiple of the app sample time, the app prompts you with the option to automatically update the Update Interval (ms) parameter to the closest integer multiple.

Default: 100

TypeType of sensor, specified as either Radar for radar sensors or Vision for camera sensors.

Sensor Placement

ParameterDescription
X (m)

X-axis position of the sensor in the vehicle coordinate system, in meters, specified as a decimal scalar.

The X-axis points forward from the vehicle. The origin is located at the center of the vehicle's rear axle.

Y (m)

Y-axis position of the sensor in the vehicle coordinate system, in meters, specified as a decimal scalar.

The Y-axis points to the left of the vehicle. The origin is located at the center of the vehicle's rear axle.

Height (m)

Height of the sensor above the ground, in meters, specified as a positive decimal scalar.

Default: 1.1

Roll

Orientation angle of the sensor about its X-axis, in degrees, specified as a decimal scalar.

Roll is clockwise-positive when looking in the forward direction of the X-axis, which points forward from the sensor.

Default: 0

Pitch

Orientation angle of the sensor about its Y-axis, in degrees, specified as a decimal scalar.

Pitch is clockwise-positive when looking in the forward direction of the Y-axis, which points to the left of the sensor.

Default: 1

Yaw

Orientation angle of the sensor about its Z-axis, in degrees, specified as a decimal scalar.

Yaw is clockwise-positive when looking in the forward direction of the Z-axis, which points up from the ground. However, the Sensor Canvas has a bird's-eye-view perspective that looks in the reverse direction of the Z-axis. Therefore, when viewing sensor coverage areas on this canvas, Yaw is counterclockwise-positive.

Detection Parameters

To view all radar detection parameters in the app, expand the Advanced Parameters and Accuracy & Noise Settings sections.

ParameterDescription
Detection Probability

Probability that the radar detects an object, specified as a decimal scalar in the range (0, 1].

Default: 0.9

False Alarm Rate

Probability of a false detection per resolution rate, specified as a decimal scalar in the range [1e-07, 1e-03].

Default: 1e-06

Field of View Azimuth

Horizontal field of view of radar, in degrees, specified as a positive decimal scalar.

Default: 20

Field of View Elevation

Vertical field of view of radar, in degrees, specified as a positive decimal scalar.

Default: 5

Max Range (m)

Farthest distance at which the radar can detect objects, in meters, specified as a positive decimal scalar.

Default: 150

Range Rate Min, Range Rate Max

Select this parameter to set minimum and maximum range rate limits for the radar. Specify Range Rate Min and Range Rate Max as decimal scalars, in meters per second, where Range Rate Min is less than Range Rate Max.

Default (Min): -100

Default (Max): 100

Has Elevation

Select this parameter to enable the radar to measure the elevation of objects. This parameter enables the elevation parameters in the Accuracy & Noise Settings section.

Default: off

Has Occlusion

Select this parameter to enable the radar to model occlusion.

Default: on

Advanced Parameters

ParameterDescription
Reference Range

Reference range for a given probability of detection, in meters, specified as a positive decimal scalar.

The reference range is the range at which the radar detects a target of the size specified by Reference RCS, given the probability of detection specified by Detection Probability.

Default: 100

Reference RCS

Reference RCS for a given probability of detection, in decibels per square meter, specified as a nonnegative decimal scalar.

The reference RCS is the target size at which the radar detects a target, given the reference range specified by Reference Range and the probability of detection specified by Detection Probability.

Default: 0

Limit # of Detections

Select this parameter to limit the number of simultaneous detections that the sensor reports. Specify Limit # of Detections as a positive integer less than 263.

Default: off

Detection Coordinates

Coordinate system of output detection locations, specified as one of these values:

  • Ego Cartesian — The app outputs detections in the coordinate system of the ego vehicle.

  • Sensor Cartesian — The app outputs detections in the coordinate system of the sensor.

  • Sensor spherical — The app outputs detections in a spherical coordinate system. This coordinate system is centered at the radar and aligned with the orientation of the radar on the ego vehicle.

Default: Ego Cartesian

Accuracy & Noise Settings

ParameterDescription
Azimuth Resolution

Minimum separation in azimuth angle at which the radar can distinguish between two targets, in degrees, specified as a positive decimal scalar.

The azimuth resolution is typically the 3 dB downpoint in the azimuth angle beamwidth of the radar.

Default: 4

Azimuth Bias Fraction

Maximum azimuth accuracy of the radar, specified as a nonnegative decimal scalar.

The azimuth bias is expressed as a fraction of the azimuth resolution specified by the Azimuth Resolution parameter. Units are dimensionless.

Default: 0.1

Elevation Resolution

Minimum separation in elevation angle at which the radar can distinguish between two targets, in degrees, specified as a positive decimal scalar.

The elevation resolution is typically the 3 dB downpoint in the elevation angle beamwidth of the radar.

To enable this parameter, in the Detection Parameters section, select the Has Elevation parameter.

Default: 10

Elevation Bias Fraction

Maximum elevation accuracy of the radar, specified as a nonnegative decimal scalar.

The elevation bias is expressed as a fraction of the elevation resolution specified by the Elevation Resolution parameter. Units are dimensionless.

To enable this parameter, under Detection Parameters, select the Has Elevation parameter.

Default: 0.1

Range Resolution

Minimum range separation at which the radar can distinguish between two targets, in meters, specified as a positive decimal scalar.

Default: 2.5

Range Bias Fraction

Maximum range accuracy of the radar, specified as a nonnegative decimal scalar.

The range bias is expressed as a fraction of the range resolution specified in the Range Resolution parameter. Units are dimensionless.

Default: 0.05

Range Rate Resolution

Minimum range rate separation at which the radar can distinguish between two targets, in meters per second, specified as a positive decimal scalar.

To enable this parameter, in the Detection Parameters section, select the Range Rate Min, Range Rate Max parameter and set the range rate values.

Default: 0.5

Range Rate Bias Fraction

Maximum range rate accuracy of the radar, specified as a nonnegative decimal scalar.

The range rate bias is expressed as a fraction of the range rate resolution specified in the Range Rate Resolution parameter. Units are dimensionless.

To enable this parameter, under the Detection Parameters section, select the Range Rate Min, Range Rate Max parameter and set the range rate values.

Default: 0.05

Has Noise

Select this parameter to enable adding noise to sensor measurements.

Default: off

Has False Alarms

Select this parameter to enable false alarms in sensor detections.

Default: off

To access these parameters, on the app toolstrip, click Settings.

Simulation Settings

ParameterDescription
Sample Time (ms)

Frequency at which the simulation updates, in milliseconds.

Increase the sample time to speed up simulation. This increase has no effect on actor speeds, even though actors can appear to go faster during simulation. The actor positions are just being sampled and displayed on the app at less frequent intervals, resulting in faster, choppier animations. Decreasing the sample time results in smoother animations, but the actors appear to move slower, and the simulation takes longer.

The sample time does not correlate to the actual time. For example, if the app samples every 0.1 seconds (Sample Time (ms) = 100) and runs for 10 seconds, the amount of elapsed actual time might be less than the 10 seconds of elapsed simulation time. Any apparent synchronization between the sample time and actual time is coincidental.

Default: 10

Stop Condition

Stop condition of simulation, specified as one of these values:

  • First actor stops — Simulation stops when the first actor reaches the end of its trajectory.

  • Set time — Simulation stops at the time specified by the Stop Time (s) parameter.

Default: Set time

Stop Time (s)

Stop time of simulation, in seconds, specified as a positive decimal scalar.

To enable this parameter, set the Stop Condition parameter to Set time.

Default: 0.1

Use RNG Seed

Select this parameter to use a random number generator (RNG) seed to reproduce the same results for each simulation. Specify the RNG seed as a nonnegative integer less than 232.

Default: off

Programmatic Use

expand all

drivingScenarioDesigner opens the Driving Scenario Designer app.

drivingScenarioDesigner(scenarioFileName) opens the app and loads the specified scenario MAT-file into the app. This file must be a scenario file saved from the app. This file can include all roads, actors, and sensors in the scenario. It can also include only the roads and actors component, or only the sensors component.

If the scenario file is not in the current folder or not in a folder on the MATLAB path, specify the full path name. For example:

drivingScenarioDesigner('C:\Desktop\myDrivingScenario.mat');

You can also load prebuilt scenario files. Before loading a prebuilt scenario, add the folder containing the scenario to the MATLAB path. For an example, see Generate Detections from Scenario.

drivingScenarioDesigner(scenario) loads the specified drivingScenario object into the app. The ClassID properties of actors in this object must correspond to these default Class ID parameter values in the app:

  • 1 — Car

  • 2 — Truck

  • 3 — Bicycle

  • 4 — Pedestrian

  • 5 — Barrier

When you create actors in the app, the actors with these Class ID values have a default set of dimensions, radar cross-section patterns, and other properties. The camera and radar sensors process detections differently depending on type of actor specified by the Class ID values.

When importing drivingScenario objects into the app, the behavior of the app depends on the ClassID of the actors in that scenario.

  • If an actor has a ClassID of 0, the app returns an error. In drivingScenario objects, a ClassID of 0 is reserved for an object of an unknown or unassigned class. The app does not recognize or use this value. Assign these actors one of the app Class ID values and import the drivingScenario object again.

  • If an actor has a nonzero ClassID that does not correspond to a Class ID value, the app returns an error. Either change the ClassID of the actor or add a new actor class to the app. On the app toolstrip, select Add Actor > New Actor Class.

  • If an actor has properties that differ significantly from the properties of its corresponding Class ID actor, the app returns a warning. The ActorID property referenced in the warning corresponds to the ID value of an actor in the list at the top of the Actors tab. The ID value precedes the actor name. To address this warning, consider updating the actor properties or its ClassID value. Alternatively, consider adding a new actor class to the app.

drivingScenarioDesigner(___,sensors) loads the specified sensors into the app, using any of the previous syntaxes. Specify sensors as a radarDetectionGenerator object, visionDetectionGenerator object, or cell array of such objects. If you specify sensors along with a scenario file that contains sensors, the app does not import the sensors from the scenario file.

For an example of importing sensors, see Import Programmatic Driving Scenario and Sensors.

Limitations

HERE HD Live Map — Import Limitations

When importing HERE HDLM data, these road and lane features are not supported:

  • Lanes with varying widths — In the generated road network, each lane is set to have the maximum width found along its entire length. Consider a HERE HDLM lane with a width that varies from 2 to 4 meters along its length. In the generated road network, the lane width is 4 meters along its entire length.

  • Roads with varying numbers of lanes along their lengths — In the generated road network, each road is set to have the maximum number of lanes along its entire length. Consider a HERE HDLM road with 3 lanes on one half and 2 lanes on the other half. In the generated road network, the road has 3 lanes along its entire length.

  • Multiple lane marking styles along a lane — In the generated road network, each lane is set to have the marking style of the lane segment with the maximum width along the road. Consider a HERE HDLM lane with 2 lane segments. The first lane segment is 2 meters wide and has solid markings. The second lane segment is 4 meters wide and has dashed markings. In the generated road network, the lane has a fixed width of 4 meters throughout and dashed markings along its entire length.

These modifications to the road networks can sometimes cause roads to overlap in the driving scenario. Consider the HERE HDLM roads for the divided highway highlighted in blue in the table. Due to the unsupported features, in the imported driving scenario, the lane widths of the roads increase. This limitation causes the roads to overlap and appear as one road. Sensors that detect lanes are unable to detect the covered lanes.

HERE HDLM Road NetworkImported Driving Scenario

In addition to the unsupported features, the basemap used in the app might have slight differences from the map used in the HERE HDLM service. Some issues with the imported roads might also be due to missing or inaccurate map data in the HERE HDLM service. To check where the issue stems from in the map data, use the HERE HD Live Map Viewer to view the geometry of the HERE HDLM road network. This viewer requires a valid HERE license. For more details, see the HERE Technologies website.

HERE HD Live Map — Route Selection Limitations

When selecting HERE HD Live Map roads to import from a region of interest, the maximum allowable size of the region is 20 square kilometers. If you specify a driving route that is greater than 20 square kilometers, the app draws a region that is optimized to fit as much of the beginning of the route as possible into the display. This figure shows an example of a region drawn around the start of a route that exceeds this maximum size.

OpenDRIVE Import Limitations

  • You can import only lanes, lane type information, and roads. The import of road objects and traffic signals is not supported.

  • OpenDRIVE files containing large road networks can take up to several minutes to load. In addition, these road networks can cause slow interactions on the app canvas. Examples of large road networks include ones that model the roads of a city or ones with roads that are thousands of meters long.

  • Lanes with variable widths are not supported. The width is set to the highest width found within that lane. For example, if a lane has a width that varies from 2 meters to 4 meters, the app sets the lane width to 4 meters throughout.

  • Roads with lane type information specified as driving, border, restricted, shoulder, and parking are supported. Lanes with any other lane type information are imported as border lanes.

  • Roads with multiple lane marking styles specified as 'Unmarked', 'Solid', 'DoubleSolid', 'Dashed', 'DoubleDashed', 'SolidDashed', and 'DashedSolid' are supported.

  • Lane marking styles Bott Dots, Curbs, and Grass are not supported. Lanes with these marking styles are imported as unmarked.

Euro NCAP Limitations

  • Scenarios of speed assistance systems (SAS) are not supported. These scenarios require the detection of speed limits from traffic signs, which the app does not support.

3D Display Limitations

These limitations describe how 3D Display visualizations differ from the cuboid visualizations that appear on the Scenario Canvas.

  • Roads do not form junctions with unmarked lanes at intersections. The roads and their lane markings overlap.

  • Not all actor or lane marking colors are supported. The 3D display matches the selected color to the closest available color that it can render.

  • Lane type colors of nondriving lanes are not supported. If you select a nondriving lane type, in the 3D display, the lane displays as a driving lane.

  • On the Actors tab, specified Roll and Pitch parameter values of an actor are ignored. In the Waypoints table, z (m) values (that is, elevation values) are also ignored. During simulation, actors follow the elevation and banking angle of the road surface.

  • Multiple marking styles along a lane are not supported. The 3D display applies the first lane marking style of the first lane segment along the entire length of the lane.

  • Actors with a 3D Display Type of Cuboid do not move in the 3D display. During simulation, these actors remain stationary at their initial specified positions.

More About

expand all

Tips

  • You can undo (press Ctrl+Z) and redo (press Ctrl+Y) changes you make on the scenario and sensor canvases. For example, you can use these shortcuts to delete a recently placed road center or redo the movement of a radar sensor.

Compatibility Considerations

expand all

Behavior changed in R2018b

References

[1] European New Car Assessment Programme. Euro NCAP Assessment Protocol - SA. Version 8.0.2. January 2018.

[2] European New Car Assessment Programme. Euro NCAP AEB C2C Test Protocol. Version 2.0.1. January 2018.

[3] European New Car Assessment Programme. Euro NCAP LSS Test Protocol. Version 2.0.1. January 2018.

[4] Dupuis, Marius, et al. OpenDRIVE Format Specification. Revision 1.4, Issue H, Document No. VI2014.106. Bad Aibling, Germany: VIRES Simulationstechnologie GmbH, November 4, 2015.

Introduced in R2018a


[1] You need to enter into a separate agreement with HERE in order to gain access to the HDLM services and to get the required credentials (access_key_id and access_key_secret) for using the HERE Service.