Main Content

roadrunnerLaneInfo

Generate lane information in RoadRunner HD Map format from lane boundary points

Since R2023a

    Description

    laneInfo = roadrunnerLaneInfo(lbPts) generates lane and lane boundary information in RoadRunner HD Map format from the input lane boundary points.

    example

    [laneInfo,geographicBoundary] = roadrunnerLaneInfo(lbPts) additionally returns the spatial bounds of the geometric data specified by the lane boundary points.

    [___] = roadrunnerLaneInfo(lbPts,Name=Value) specifies options using one or more name-value arguments, in addition to any combination of output arguments from previous syntaxes. For example, SmoothBoundaries=true specifies to smooth and align the input lane boundary points.

    Note

    This function requires the Scenario Builder for Automated Driving Toolbox™ support package. You can install Scenario Builder for Automated Driving Toolbox from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

    Examples

    collapse all

    Load a MAT file containing 2D lane boundary point data into the workspace. The data includes a 2-by-1 cell array, laneBoundaryPoints, which contains the lane boundary points for two road segments, each with four lane boundaries.

    load("laneBoundaryPointsJunctions.mat")
    laneBoundaryPoints
    laneBoundaryPoints=2×1 cell array
        {1×4 cell}
        {1×4 cell}
    
    

    Using the lane boundary points, generate lane and geographic boundary information for a RoadRunner HD Map scene model. Set the MinJunctionLength parameter to 10. This parameter value specifies that, if the distance between two road segments is greater than 10 meters, the function adds a perpendicular road between the two road segments to form a junction connecting them.

    [laneInfo,geographicBoundary] = roadrunnerLaneInfo(laneBoundaryPoints, ...
        MinJunctionLength=10);

    Create an empty RoadRunner HD Map by using the roadrunnerHDMap object.

    rrMap = roadrunnerHDMap;

    Add the generated lane and geographic boundary information to the RoadRunner HD Map object.

    rrMap.Lanes = laneInfo.Lanes;
    rrMap.LaneBoundaries = laneInfo.LaneBoundaries;
    rrMap.GeographicBoundary = geographicBoundary;

    Plot the map.

    plot(rrMap)

    Write the RoadRunner HD Map to a binary file, which you can import into RoadRunner.

    write(rrMap,"lanes.rrhd")

    Specify the path to your local RoadRunner installation folder. This code shows the path for the default installation location on Windows®.

    rrAppPath = "C:\Program Files\RoadRunner " + matlabRelease.Release + "\bin\win64";

    To open RoadRunner using MATLAB®, specify the path to your RoadRunner project. This code shows the default path for a sample project folder location in Windows®.

    rrProjectPath = "C:\RR\MyProjects";

    Open RoadRunner by using the roadrunner object.

    rrApp = roadrunner(rrProjectPath,InstallationFolder=rrAppPath);

    Copy the RoadRunner HD Map file to the RoadRunner project.

    copyfile("lanes.rrhd",rrProjectPath+"\Assets")

    Specify options to import RoadRunner HD Map into RoadRunner. Set your build options for the RoadRunner HD Map so that it does not create overlap groups, instead creating an automatic junction where the two roads intersect.

    overlapGroupsOptions = enableOverlapGroupsOptions(IsEnabled=false);
    buildOptions = roadrunnerHDMapBuildOptions(EnableOverlapGroupsOptions=overlapGroupsOptions);
    importOptions = roadrunnerHDMapImportOptions(BuildOptions=buildOptions);

    Import the lanes.rrhd scene file into RoadRunner.

    importScene(rrApp,"lanes.rrhd","RoadRunner HD Map",importOptions)

    Built RoadRunner scene containing junction

    Load a MAT file containing 3D lane boundary point data into the workspace. The data includes a cell array, laneBoundaryPoints, which contains the lane boundary points for one road segment with four lane boundaries. The z-coordinates of lane boundaries represent the road elevation information.

    load("laneBoundaryPoints3d.mat")
    laneBoundaryPoints
    laneBoundaryPoints = 1×1 cell array
        {1×4 cell}
    
    

    Generate lane information in RoadRunner HD Map format from lane boundary points by using the roadrunnerLaneInfo function.

    [laneInfo,geographicBoundary] = roadrunnerLaneInfo(laneBoundaryPoints);

    Create an empty RoadRunner HD Map by using the roadrunnerHDMap object.

    rrMap = roadrunnerHDMap;

    Add the generated lane and geographic boundary information to the RoadRunner HD Map object.

    rrMap.Lanes = laneInfo.Lanes;
    rrMap.LaneBoundaries = laneInfo.LaneBoundaries;
    rrMap.GeographicBoundary = geographicBoundary;

    Plot the map.

    plot(rrMap)

    Write the RoadRunner HD Map to a binary file, which you can import into RoadRunner.

    write(rrMap,"lanes.rrhd")

    Specify the path to your local RoadRunner installation folder. This code shows the path for the default installation location on Windows®.

    rrAppPath = "C:\Program Files\RoadRunner " + matlabRelease.Release + "\bin\win64";

    To open RoadRunner using MATLAB®, specify the path to your RoadRunner project. This code shows the default path for a sample project folder location in Windows®.

    rrProjectPath = "C:\RR\MyProjects";

    Open RoadRunner by using the roadrunner object.

    rrApp = roadrunner(rrProjectPath,InstallationFolder=rrAppPath);

    Copy the RoadRunner HD Map file to the RoadRunner project.

    copyfile("lanes.rrhd",rrProjectPath+"\Assets")

    Specify options to import RoadRunner HD Map into RoadRunner. Set your build options for the RoadRunner HD Map so that it does not create overlap groups, instead creating an automatic junction where the two roads intersect.

    overlapGroupsOptions = enableOverlapGroupsOptions(IsEnabled=false);
    buildOptions = roadrunnerHDMapBuildOptions(EnableOverlapGroupsOptions=overlapGroupsOptions);
    importOptions = roadrunnerHDMapImportOptions(BuildOptions=buildOptions);

    Import the lanes.rrhd scene file into RoadRunner.

    importScene(rrApp,"lanes.rrhd","RoadRunner HD Map",importOptions)

    Built RoadRunner scene containing an elevated road

    Input Arguments

    collapse all

    Lane boundary points, specified as an M-by-1 cell array. M is the number of road segments. Each cell of the array contains a 1-by-N cell array. N is the number of lane boundaries in a road segment, and it must be greater than one. Each cell of each N-element cell array contains a P-by-2 or P-by-3 matrix, where P is the number of lane boundary points for that road segment.

    • If a matrix is a P-by-2 matrix, then each row represents the (x, y) coordinates of a lane boundary point. The z-coordinate of each lane boundary point is 0.

    • If a matrix is a P-by-3 matrix, then each row represents the (x, y, z) coordinates of a lane boundary point.

    Note

    • The x- or y-coordinate values of the lane boundary points stored in a matrix must increase or decrease monotonically.

    • Lane boundaries must be in left-to-right order with respect to the travel direction of the ego vehicle.

    • You must place lane boundary points for different road segments in their order of occurrence along the travel direction of the ego vehicle.

    Data Types: cell

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: roadrunnerLaneInfo(lbPts,SmoothBoundaries=true) specifies to smooth and align input lane boundary points.

    Road segment connection flag, specified as a logical 1 (true) or 0 (false).

    • true or 1 — The function automatically connects consecutive road segments and specifies alignment between them.

    • false or 0 — The function does not connect consecutive road segments. Use this option to manually specify the connection between two road segments.

    Data Types: logical

    Minimum distance, in meters, at which to create a junction between two consecutive road segments, specified as a real positive scalar. If the distance between two consecutive road segments exceeds this value, then the function adds a perpendicular road between the two road segments to form a junction. The perpendicular road has three lanes, and it is 50 meters long and 10.5 meters wide. By default, the function does not create a junction between two consecutive road segments.

    Data Types: single | double

    Boundary smoothing, specified as a logical 1 (true) or 0 (false). When you specify this argument as true, the function smooths data using a Savitzky-Golay filter and aligns the start and end points of all lane boundaries of each road segment. The function does not support smoothing of 3D lane boundary points. If you enable smoothing and specify 3D lane boundary points, the function discards the z-coordinate values of the 3D lane boundary points and returns smoothed 2D points with only x- and y-coordinates.

    Data Types: logical

    Level of smoothing, specified as a real scalar in the range [0, 1]. The specified value scales the heuristic window length to adjust the level of smoothing. Values closer to 0 produce shorter moving window lengths, resulting in less smoothing. Values closer to 1 produce longer moving window lengths, resulting in more smoothing. For more information on smoothing, see smoothdata.

    Data Types: single | double

    Savitzky-Golay degree, specified as a positive integer. This value specifies the degree of the polynomial in the Savitzky-Golay filter that fits the data within each window. For more information, see smoothdata.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Output Arguments

    collapse all

    Lane information in RoadRunner HD map format, returned as a structure with these fields:

    Spatial bounds of the geometric data represented in the 3D coordinate space of the RoadRunner HD Map projection, returned as a 2-by-3 matrix of the form [xmin ymin zmin; xmax ymax zmax]. The elements in the first row of the matrix represent the minimum position of each axis in an axis-aligned 3D bounding box, and the elements in the second row represent each corresponding maximum position.

    Data Types: double

    Version History

    Introduced in R2023a