OpenDRIVE®  is an open file format that enables you to specify large and complex road networks. Using the Driving Scenario Designer app, you can import roads and lanes from an OpenDRIVE file into a driving scenario. You can then add actors and sensors to the scenario and generate synthetic lane and object detections for testing your driving algorithms developed in MATLAB®. Alternatively, to test driving algorithms developed in Simulink®, you can use a Scenario Reader block to read the road network and actors into a model.
Open the Driving Scenario Designer app. At the MATLAB command prompt, enter:
To import an OpenDRIVE file, on the app toolstrip, select Import > OpenDRIVE Road Network. The file you select must be a valid OpenDRIVE file of type
.xml. In addition,
the file must conform with OpenDRIVE format specification version 1.4H.
From your MATLAB root folder, navigate to and open this file:
Because you cannot import an OpenDRIVE road network into an existing scenario file, the app prompts you to save your current driving scenario.
The Scenario Canvas of the app displays the imported road network. The roads in this network are thousands of meters long. Zoom in (press Ctrl+Plus) on the road to inspect it more closely.
The imported road network shows a pair of two-lane roads intersecting with a single two-lane road.
Verify that the road network imported as expected, keeping in mind the following limitations and behaviors within the app.
The Driving Scenario Designer app does not support all components of the OpenDRIVE specification.
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
supported. Lanes with any other lane type information are imported as border
Roads with multiple lane marking styles specified as
'DashedSolid' are supported.
Lane marking styles
Grass are not supported. Lanes with these marking
styles are imported as unmarked.
In the Driving Scenario Designer app, the orientation of roads can differ from the orientation of roads in other tools that display OpenDRIVE roads. The table shows this difference in orientation between the app and the OpenDRIVE ODR Viewer.
|Driving Scenario Designer||OpenDRIVE ODR Viewer|
In the OpenDRIVE ODR viewer, the X-axis runs along the bottom of the viewer, and the Y-axis runs along the left side of the viewer.
In the Driving Scenario Designer app, the Y-axis runs along the bottom of the canvas, and the X-axis runs along the left side of the canvas. This world coordinate system in the app aligns with the vehicle coordinate system (XV,YV) used by vehicles in the driving scenario, where:
The XV-axis (longitudinal axis) points forward from a vehicle in the scenario.
The YV-axis (lateral axis) points to the left of the vehicle, as viewed when facing forward.
For more details about the coordinate systems, see Coordinate Systems in Automated Driving Toolbox.
In the Driving Scenario Designer app, the location and orientation of roads are defined by road centers. When you create a road in the app, the road centers are always in the middle of the road. When you import OpenDRIVE road networks into the app, however, some roads have their road centers on the road edges. This behavior occurs when the OpenDRIVE roads are explicitly specified as being right lanes or left lanes.
Consider the divided highway in the imported OpenDRIVE file. First, enable road interactions so that you can see the road centers. In the bottom-left corner of the Scenario Canvas, click the Configure the Scenario Canvas button , and then select Enable road interactions.
The lanes on the right side of the highway have their road centers on the right edge.
The lanes on the left side of the highway have their road centers on the left edge.
You can add actors and sensors to a scenario containing OpenDRIVE roads. However, you cannot add other roads to the scenario. If a scenario contains an OpenDRIVE road network, the Add Road button in the app toolstrip is disabled. In addition, you cannot import additional OpenDRIVE road networks into a scenario.
Before adding an actor and sensors, if you have road interactions enabled, consider disabling them to prevent you from accidentally dragging road centers and changing the road network. If road interactions are enabled, in the bottom-left corner of the Scenario Canvas, click the Configure the Scenario Canvas button , and then clear Disable road interactions.
Add an ego vehicle to the scenario by right-clicking one of the roads in the canvas and selecting Add Car. To specify the trajectory of the car, right-click the car in the canvas, select Add Waypoints, and add waypoints along the road for the car to pass through. After you add the last waypoint along the road, press Enter. The car autorotates in the direction of the first waypoint.
Add a camera sensor to the ego vehicle. On the app toolstrip, click Add Camera. Then, on the sensor canvas, add the camera to the predefined location representing the front window of the car.
Configure the camera to detect lanes. In the left pane, on the
Sensors tab, expand the Detection Parameters
section. Then, set the Detection Type parameter to
To generate lane detections from the camera, on the app toolstrip, click Run. As the scenario runs, the Ego-Centric View displays the scenario from the perspective of the ego vehicle. The Bird’s-Eye Plot displays the left-lane and right-lane boundaries of the ego vehicle.
To export the detections to the MATLAB workspace, on the app toolstrip, click Export > Export Sensor Data. Name the workspace variable and click OK.
The Export > Export MATLAB Function option is disabled. If a scenario contains OpenDRIVE roads, then you cannot export a MATLAB function that generates the scenario and its detections.
After you generate the detections, click Save to save the scenario file. In addition, you can save the sensor models as separate files. You can also save the road and actor models together as a separate scenario file.
You can reopen this scenario file from the app. Alternatively, at the MATLAB command prompt, you can use this syntax.
When you reopen this file, the Add Road button remains disabled.
If you are developing a driving algorithm in Simulink, you can use a Scenario Reader block to read the roads and actors from the scenario file into your model. Scenario files containing large OpenDRIVE road networks can take up to several minutes to read into models.
If you are developing a driving algorithm in Simulink, you can use a Scenario Reader
block to read roads and actors from the scenario file or
object into your model. This block does not directly read sensor data. To add sensors created
in the app to a Simulink model, you can generate a model containing your scenario and sensors by
selecting Export > Export Simulink Model. In this model, a Scenario Reader block reads the scenario and
Generator and Vision Detection
Generator blocks model the sensors.
 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.