Main Content

ImportASAM OpenDRIVERoads into Driving Scenario

ASAM OpenDRIVE®is an open file format that enables you to specify large and complex road networks. Using theDriving Scenario Designerapp, 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 aScenario Readerblock 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 adrivingScenarioobject instead of into the app, use theroadNetworkfunction.

ImportASAM OpenDRIVEFile

To import an ASAM OpenDRIVE file into theDriving Scenario Designerapp, follow these steps:

  1. Open theDriving Scenario Designerapp. At the MATLAB command prompt, enter:

    drivingScenarioDesigner

  2. On the app toolstrip, clickImport>ASAM OpenDRIVE File.

  3. In the ASAM OpenDRIVE Import dialog box, browse for a valid ASAM OpenDRIVE file of type.xodror.xml.

    In this example, you navigate to this file, wherematlabrootis the root of your MATLAB folder:

    matlabroot/examples/driving/data/roundabout.xodr

    Note

    You cannot import an ASAM OpenDRIVE road network into an existing driving scenario. If you attempt to do so, the app prompts you to save your existing scenario.

  4. (Optional) If you do not want to see any errors or warnings that may occur during import, clear theShow errors and warningsparameter. By default, this parameter is selected.

  5. ClickImport. If you have selected theShow errors and warningsparameter, the Import ASAM OpenDRIVE Results dialog box displays any warnings and errors that occurr during import. You can copy these warnings and errors to a text file. Then, close the dialog box.

ASAM OpenDRIVE import dialog box to import the file

TheScenario Canvasof 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 aRoadGroupobject 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, number of roads, junction IDs, and number of junctions in a driving scenario may not match those specified in the imported ASAM OpenDRIVE file.

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 OpenDRIVEImport Limitations

TheDriving Scenario Designerapp 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.

  • Multiple lane specifications for one-way roads are not supported. The app applies the lane specifications of the first road segment to the entire one-way road. For example, if the first road segment of a one-way road has four lanes and the second road segment has three lanes, then the app applies four lanes to the entire one-way road.

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

  • Lane marking stylesBott Dots,Curbs, andGrassare not supported. Lanes with these marking styles are imported as unmarked.

Road Orientation

In theDriving Scenario Designerapp, 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 Designer OpenDRIVE ODR Viewer

Orientation of roads in Driving Scenario Designer app

Orientation of roads in OpenDRIVE ODR Viewer

In the OpenDRIVE ODR viewer, theX-axis runs along the bottom of the viewer, and theY-axis runs along the left side of the viewer.

In theDriving Scenario Designerapp, theY-axis runs along the bottom of the canvas, and theX-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:

  • TheXV设在(纵轴)从ve点前进hicle in the scenario.

  • TheYV-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, seeCoordinate 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 theScenario Canvas, click the Configure the Scenario Canvas button, and then clearEnable road interactions.

Add an ego vehicle to the scenario by right-clicking one of the roads in the canvas and selectingAdd Car. To specify the trajectory of the car, right-click the car in the canvas, selectAdd 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, pressEnter. 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, clickAdd 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

配置摄像头检测车道。在左边pane, on theSensorstab, expand theDetection Parameters部分。然后,设置theDetection Typeparameter toLanes.

Generate Synthetic Detections

To generate lane detections from the camera, on the app toolstrip, clickRun. As the scenario runs, theEgo-Centric Viewdisplays the scenario from the perspective of the ego vehicle. TheBird’s-Eye Plotdisplays 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, clickExport>MATLAB Function.

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

Save Scenario

After you generate the detections, clickSaveto 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 aScenario Readerblock to read the roads and actors from thedrivingScenarioobject 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. TheScenario Readerblock 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 selectingExport>Simulink Model. In this model, aScenario Readerblock reads the scenario and radar and vision sensor blocks model the sensors.

See Also

Apps

Blocks

Objects

Functions

Related Topics

External Websites