Add road network to driving scenario





roadNetwork(scenario,'OpenDRIVE',filePath) imports roads and lanes from an OpenDRIVE® road network file into a driving scenario. This function supports OpenDRIVE format specification version 1.4H [1].


collapse all

Create an empty driving scenario.

scenario = drivingScenario;

Import an OpenDRIVE road network into the scenario.

filePath = fullfile(matlabroot,'examples','driving','intersection.xodr');  

Plot the scenario and zoom in on the road network.


Input Arguments

collapse all

Driving scenario, specified as a drivingScenario object. scenario must contain no roads and no other OpenDRIVE road network.

Path to a valid OpenDRIVE file of type .xml or .xodr, specified as a character vector or string scalar.

Example: 'OpenDRIVE','C:\Desktop\myRoadNetwork.xodr'


  • 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. 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 function sets the lane width to 4 meters throughout.

  • Roads with multiple lane marking styles are not supported. The function applies the first found marking style to all lanes in the road. For example, if a road has Dashed and Solid lane markings, the function applies Dashed lane markings throughout.

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


[1] 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 R2018b