Design driving scenarios, configure sensors, and generate synthetic object detections
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.
Import OpenDRIVE® roads and lanes into a driving scenario. The app supports OpenDRIVE format specification version 1.4H .
Export sensor detections to MATLAB®, or generate MATLAB code of the scenario that produced the detections.
Import the driving scenario into Simulink® model by using a Scenario Reader block. You can use the imported scenario to test your sensor fusion or vehicle control algorithms.
To learn more about using the app, see Driving Scenario Designer.
MATLAB Toolstrip: On the Apps tab, under Automotive, click the app icon.
MATLAB command prompt: Enter
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.
Create a curved road. From 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
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. From 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 Path 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.
For more details on prebuilt scenarios available from the app, see Generate Synthetic Detections from a Prebuilt Driving Scenario.
For more details on available Euro NCAP scenarios, see Generate Synthetic Detections from a Euro NCAP Scenario.
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','driving','drivingdata', ... '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. While the scenario simulation runs, inspect different aspects of the simulation 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.
Import an OpenDRIVE road network into the Driving Scenario Designer app. For a more detailed example, see Add OpenDRIVE Roads to Driving Scenario.
Open the Driving Scenario Designer app.
From the app toolstrip, select Open > OpenDRIVE Road Network. Then, from your MATLAB root folder, navigate to and open this file:
drivingScenarioDesigner opens the Driving Scenario
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
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:
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 Prebuilt Scenario.
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.
You can import only lanes 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 multiple lane marking styles are not supported. The app applies the first found marking style to all lanes in the road. For example, if a road has
Solid lane markings, the app applies
Dashed lane markings throughout.
Lane marking styles
Grass are not supported. Lanes with these marking
styles are imported as unmarked.
The Roads tab provides options for controlling the elevation and banking angle of a road.
When working with roads containing nondefault elevations or banking angles, keep these tips in mind:
When you add a road center to an elevated road, the default z-dimension of the road center is 0. To adjust the elevation of the road center to match the elevation of surrounding road centers, first select the road. Then, on the Roads tab, in the Road Centers section, adjust the z (m) parameter of the road center.
When you add an actor to a road, you do not have to change the actor position to match changes in elevation angle or banking angle. The actor follows the elevation and banking angle of the road automatically.
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 onto the junction, the app might be unable to compute the precise elevation of the actor. Therefore, the app cannot place the actor on that junction.
To address this issue, 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.
The Roads tab provides options for changing the number of lanes in a road and specifying its lane markings. You can specify the Number of lanes parameter as a:
Positive integer scalar, M — Create an M-lane road whose default lane markings indicate that the road is one-way.
Two-element vector of positive integers, [M N] — Create an (M+N)-lane road whose default lane markings indicate that the road is two-way. The first M lanes travel in one direction. The next N lanes travel in the opposite direction.
If you change the Number of lanes parameter from
a scalar to a vector, the default lane markings also change. If the change creates
an impossible road configuration, the app resets the Lane
Width (m) parameter for all lanes to the default of
3.6. This resetting can occur when the updated road
contains lanes with very small widths. For example, if a lane has a width that is
less than the width of one of its lane markings, then all lanes are reset to a width
of 3.6 meters.
Under Settings, the Sample Time (ms) parameter controls how frequently the simulation updates. 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, it might take less than 10
seconds for the 10 seconds of simulation time to elapse. Any apparent
synchronization between the sample time and actual time is coincidental.
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.
During simulation, the default camera and radar sensors update every 100 ms
(Update Interval (ms) =
ensure that the app samples and displays the detections found at these
intervals, the update interval must be an integer multiple of the app sample
time. By default, the app samples the simulation every 10 ms (Sample
Time (ms) =
10). For more details on the
app sample time, see Sample Time.
Behavior changed in R2018b
Starting in R2018b, in the Camera Settings group of the Driving Scenario Designer app, the Image Width and Image Height parameters set their expected values. Previously, Image Width set the height of images produced by the camera, and Image Height set the width of images produced by the camera.
If you are using R2018a, to produce the expected image sizes, transpose the values set in the Image Width and Image Height parameters.
 European New Car Assessment Programme. Euro NCAP Assessment Protocol - SA. Version 8.0.2. January 2018.
 European New Car Assessment Programme. Euro NCAP AEB C2C Test Protocol. Version 2.0.1. January 2018.
 European New Car Assessment Programme. Euro NCAP LSS Test Protocol. Version 2.0.1. January 2018.
 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.