Main Content

Import ASAM OpenDRIVE Roads into Driving Scenario

ASAM 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 ASAM 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.

The app supports importing road networks from OpenDRIVE® file versions 1.4 and 1.5, as well as ASAM OpenDRIVE file version 1.6.

To import ASAM OpenDRIVE roads and lanes into a drivingScenario object instead of into the app, use the roadNetwork function.

Import ASAM OpenDRIVE File

Open the Driving Scenario Designer app. At the MATLAB command prompt, enter:

drivingScenarioDesigner

To import an ASAM OpenDRIVE file, on the app toolstrip, click Import > ASAM OpenDRIVE File. The file you select must be a valid ASAM OpenDRIVE file of type .xodr or .xml.

From your MATLAB root folder, navigate to and open this file:

matlabroot/examples/driving/data/roundabout.xodr

Because you cannot import an ASAM 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.

Imported ASAM OpenDRIVE road network

Note

As of R2021b, the ASAM OpenDRIVE import feature offers functional and visual improvements, as well as a few additional limitations.

  • You can now add new roads to a scenario and export a MATLAB function after importing an ASAM OpenDRIVE road network.

  • You can now import roads with multiple lane specifications.

  • Imported roads show boundary lines that were not shown previously.

  • Road centers always appear in the middle of imported roads. Previously, some roads were showing road centers on the road edges.

  • Junctions are represented using a RoadGroup object that combines road segments within a junction. Previously, each road segment within a junction was represented separately. As a result, imported road networks now use a smaller number of roads.

  • The road IDs and number of roads in a driving scenario may not match those specified in the imported ASAM OpenDRIVE file.

  • Roads with sharp curvature cannot be imported.

Inspect Roads

The roads in the imported network are thousands of meters long. Use the mouse wheel to zoom in the road network and inspect it more closely. The road network contains a roundabout that connects six roads.

Roundabout in the imported road network

Verify that the road network imported as expected, keeping in mind the following limitations and behaviors within the app.

ASAM OpenDRIVE Import Limitations

The Driving Scenario Designer app does not support all components of the ASAM OpenDRIVE specification.

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

  • ASAM 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.

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

Road Orientation

In the Driving Scenario Designer app, the orientation of roads can differ from the orientation of roads in other tools that display ASAM OpenDRIVE roads. The table shows this difference in orientation between the app and the OpenDRIVE ODR Viewer.

Driving Scenario DesignerOpenDRIVE ODR Viewer

Orientation of roads in Driving Scenario Designer app

Orientation of roads in 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.

Coordinate system in Driving Scenario Designer app

For more details about the coordinate systems, see Coordinate Systems in Automated Driving Toolbox.

Add Actors and Sensors to Scenario

You can add actors and sensors to a scenario containing ASAM OpenDRIVE roads.

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 Enable 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 Forward Waypoints (Ctrl+F), 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.

Imported road after adding actor and its trajectory

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.

Sensor canvas showing camera added to front window of ego vehicle

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 Lanes.

Generate Synthetic Detections

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.

Illustration of generated lane detections

To export a MATLAB function that generates the scenario and its detections, on the app toolstrip, click Export > MATLAB Function.

To export the detections to the MATLAB workspace, on the app toolstrip, click Export > Export Sensor Data. Name the workspace variable and click OK.

Save Scenario

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.

drivingScenarioDesigner(scenarioFileName)

If you are developing a driving algorithm in Simulink, you can use a Scenario Reader block to read the roads and actors from the drivingScenario object or the scenario file into your model. Scenario files containing large ASAM OpenDRIVE road networks can take up to several minutes to read into models. The Scenario Reader 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 > Simulink Model. In this model, a Scenario Reader block reads the scenario and radar and vision sensor blocks model the sensors.

See Also

Apps

Blocks

Objects

Functions

Related Topics

External Websites