Main Content


Get RoadRunner HD Map from Driving Scenario in MATLAB

Since R2023a



rrMap = getRoadRunnerHDMap(scenario) returns a RoadRunner HD Map object, rrMap for the road network and static actors in the driving scenario, scenario. RoadRunner HD Map is a road data model for representing high-definition ma data in a RoadRunner scene. Use the rrMap object to inspect the scenario representation and modify elements. Then, you can writerrMap to a .rrhd binary file using the write function, and import the .rrhd file into RoadRunner.There may be variations between the original scenario and the exported scenario. For details, see Limitations.


collapse all

Create a driving scenario object.

scenario = helperCreateDrivingScenario;

Plot the scenario.


Figure contains an axes object. The axes object with xlabel X (m), ylabel Y (m) contains 5 objects of type patch, line.

Export the driving scenario directly to a .rrhd binary file.

export(scenario,"RoadRunner HD Map","directExportScenario.rrhd")

Alternatively, you can first get the RoadRunner HD Map object for the scenario and plot it.

rrMap = getRoadRunnerHDMap(scenario);

Figure contains an axes object. The axes object contains 2 objects of type line. These objects represent Lane Boundaries, Lane Centers.

You can inspect it and make any desired modifications. Then, write the RoadRunner HD Map to a .rrhd binary file.


Import the map into RoadRunner. Specify the import options to enable overlap groups.

rrApp = roadrunner("D:\RR\TestProjects");
impOpts = roadrunnerHDMapImportOptions(BuildOptions=roadrunnerHDMapBuildOptions(EnableOverlapGroupsOptions=enableOverlapGroupsOptions(IsEnabled=false)));
importScene(rrApp,fullfile(pwd,"4wayIntersection.rrhd"),"RoadRunner HD Map",impOpts)

Helper Functions

helperCreateDrivingScenario creates a four way intersection driving scenario with an ego vehicle and a pedestrian.

function scenario = helperCreateDrivingScenario

% Create scenario and add roads
scenario = drivingScenario;
roadCenters = [0 40 0;
    0 -40 0];
marking = [laneMarking('Solid')
laneSpecification = lanespec(2, 'Width', 3.5, 'Marking', marking);
road(scenario, roadCenters, 'Lanes', laneSpecification, 'Name', 'Road');

roadCenters = [-40 0 0;
    40 0 0];
marking = [laneMarking('Solid')
laneSpecification = lanespec(2, 'Width', 3.5, 'Marking', marking);
road(scenario, roadCenters, 'Lanes', laneSpecification, 'Name', 'Road1');

% Add ego vehicle
egoVehicle = vehicle(scenario, ...
    'ClassID', 1, ...
    'Position', [-1.75 30 0], ...
    'FrontOverhang', 0.9, ...
    'Wheelbase', 2.8, ...
    'Mesh', driving.scenario.carMesh, ...
    'Name', 'Vehicle Under Test');
waypoints = [-1.75 30 0;
    -1.75 10.629767723813 0;
    -0.980075893866154 4.2738387109925 0;
    4.2738387109925 -0.980075893866154 0;
    10.629767723813 -1.75 0;
    30 -1.75 0];
speed = 2.77777777777778;
yaw =  [-90;-90;-69.38;-20.62;0;0];
smoothTrajectory(egoVehicle, waypoints, speed, 'Yaw', yaw);

% Add the non-ego actors
euroncappedestriantarget = actor(scenario, ...
    'ClassID', 4, ...
    'Length', 0.6, ...
    'Width', 0.5, ...
    'Height', 1.8, ...
    'Position', [9.5 -7.75 0], ...
    'PlotColor', [237 177 32] / 255, ...
    'Name', 'Euro NCAP Pedestrian Target');
waypoints = [9.5 -7.75 0;
    9.5 -6.75 0;
    9.5 10 0];
speed = [0;1.38888888888889;1.38888888888889];
waittime = [7.82;0;0];
trajectory(euroncappedestriantarget, waypoints, speed, waittime);

Input Arguments

collapse all

Driving scenario, specified as a drivingScenario object.

Output Arguments

collapse all

RoadRunner HD Map road data model, specified as a roadrunnerHDMap object. rrMap defines a simple data structure to represent road layouts using lanes, lane boundaries, lane markings, and junctions. This object provides functions that support reading, writing, and plotting HD map data.

RoadRunner HD Map Export Limitations

A RoadRunner Scene Builder license is required to build a scene from the HD map file. Without a RoadRunner Scene Builder license, you can import the HD map file and only view the map as nodes and links in RoadRunner.

Composite Lane Specifications

  • Roads that use composite lane specifications (compositeLaneSpec) and form loops or intersect with themselves are not supported.

  • Composite lane specifications for creating roads with varying widths are not supported

Lane Markings and Lane Type

  • For lane markings created using the laneMarking object and lane types created using the laneType object, only Color name-value argument is supported. Only white and yellow colors are supported.

  • For roads that form loops, multiple lane marking styles are not supported.

Parking Lot

  • Driving scenarios containing parking lots added using the parkingLot function are not supported.


  • Barriers with gaps between segments created using the barrier function with SegmentGap name-value argument, are not supported. Such barriers will be laid out without any gaps in the RoadRunner HD map representation.

  • For barriers, setting the SegmentLength, Width, and Height properties are not supported. These properties are calculated automatically based on the asset size during import to RoadRunner.

Static Actors

  • Static actors such as pedestrians and bicycles are not supported. To represent these actors in RoadRunner, you can either download a cuboid FBX and place it under Assets/Vehicles/ or edit the map to point to their own assets.

Road Groups and Road Networks

  • Road junctions and intersections added using the roadGroup function are not supported.

  • Road networks created using the roadNetwork function are not supported when they use road groups.

Version History

Introduced in R2023a