Main Content

LaneWidthProfile

Width profile for lane boundaries in RoadRunner scene

Since R2025a

    Description

    The LaneWidthProfile object defines the geometry of the outer boundary of a lane within a RoadRunner scene. Use this object to specify how the width of a lane changes along its length. A lane width profile consists of a sequence of parametric spans, represented as an ordered collection of nodes connected by spans between each pair of adjacent nodes. Each node in the sequence represents a specific location along the road and contains information about the lane width and the slope of the width at that point. RoadRunner represents the position of each node as its distance from the starting point of the reference line of the road. The LaneWidthProfile object smoothly interpolates the width and the slope values between these nodes across each span, resulting in a continuous and realistic width profile for the lane boundary. The interpolation process enables you to create gradual transitions in lane width and accurately author complex, realistic road layouts, including lane tapers and merges.

    Creation

    To retrieve the LaneWidthProfile object of a lane or a reference lane from your RoadRunner scene, extract the WidthProfile property of the lane or reference lane. For example, widthProfile1 = rrLane1.WidthProfile extracts the LaneWidthProfile property of the lane rrLane1.

    Properties

    expand all

    This property is read-only.

    Nodes of the span sequence in the lane width profile, represented as an array of LaneWidthNode objects.

    This property is read-only.

    Spans of the span sequence in the lane width profile, represented as an array of LaneWidthSpan objects.

    Object Functions

    insertNodeInsert node in span sequence

    Examples

    collapse all

    Create a RoadRunner scene with a horizontal road that contains multiple driving lanes and a single merge lane. Merge lanes enable vehicles to safely converge from multiple lanes to a single lane, such as due to a narrowing road or lane closures.

    Create a roadrunner object, specifying the path to an existing project. For example, this code shows the path to a project, on a Windows® machine, located at "C:\RR\MyProject". This code assumes that RoadRunner is installed in the default location, and returns an object, rrApp, that provides functions for performing basic tasks such as opening, closing, and saving scenes and projects.

    rrApp = roadrunner(ProjectFolder="C:\RR\MyProject");

    Note: If you are opening RoadRunner from MATLAB® for the first time, or if you have changed the RoadRunner installation location since you last opened it from MATLAB, you can use the roadrunnerSetup (RoadRunner) function to specify new default project and installation folders to use when opening RoadRunner. You can save these folders between MATLAB sessions by selecting the Across MATLAB sessions option from the corresponding drop down.

    Create a new RoadRunner scene in the current project by using the newScene function, specifying the roadrunner object rrApp.

    newScene(rrApp);

    Create an object for the RoadRunner authoring API, rrApi, that references the object for the current RoadRunner instance rrApp. The rrApi object enables you to programmatically author scenes, such as by adding and modifying road and lanes components, using MATLAB.

    rrApi = roadrunnerAPI(rrApp);

    Extract the object for your scene from the Scene property of the authoring API object rrApi. The extracted Scene object enables you to specify the scene in which to add scene elements such as roads and lanes.

    scn = rrApi.Scene;

    Extract the Project object for your RoadRunner project from the Project property of the authoring API object rrApi. The extracted Project object enables you to specify the project folder for the current RoadRunner session from which to retrieve asset objects. You can use the asset objects to assign markings to the lanes in your scene.

    prj = rrApi.Project;

    Add a horizontal road 200 meters in length to the scene by using the addLineArcRoad function. Specify the position of the road by specifying the positions of its control points along the X- and Y-axes of the RoadRunner local coordinate system. These control points define the positions of the start and end of the road. You can modify the positions of the control points to adjust the length and direction of the road relative to the scene origin. You can also add control points between the start and end points of the line-arc curve to adjust the curvature and radius of the road curve.

    controlPoints = [-100 0; 100 0];
    rrHorizontalRoad = addLineArcRoad(scn,controlPoints);

    Extract the reference lane of the road from the ReferenceLane property of the road object rrHorizontalRoad. The reference lane defines the center lane, or reference line, of a road in a RoadRunner scene. This lane has no width and serves as the basis for positioning all other lanes, which RoadRunner arranges outward from the reference line..

    refLane = rrHorizontalRoad.ReferenceLane;

    Use the getAsset (RoadRunner Scenario) function to extract a lane marking style object, which represents the DashedSingleWhite.rrlms asset, from the project prj. To define the marking profile of the reference lane, first extract the lane marking profile object refLaneMarkingProfile of the reference lane object refLane. Then, extract the lane marking span object refLaneSpan, which represents the span on which to place the lane marking, from the Spans property of the lane marking profile object refLaneMarkingProfile. Lastly, set the LaneMarkingStyle property of the extracted span object to mark the reference lane with the dashed white marking style.

    dashedWhiteMarkingStyle = getAsset(prj,"<PROJECT>/Assets/Markings/DashedSingleWhite.rrlms","LaneMarkingStyle");
    refLaneMarkingProfile = refLane.LaneMarkingProfile;
    refLaneSpan = refLaneMarkingProfile.Spans;
    refLaneSpan.LaneMarkingStyle = dashedWhiteMarkingStyle;

    Add a driving lane on the left side of the horizontal road with a forward direction of travel by using the addLaneToLeft function. Use the LaneType and TravelDirection properties of the added lanes to specify the type and travel direction of the lane.

    horizontalLane1 = addLaneToLeft(refLane);
    horizontalLane1.LaneType = "Driving";
    horizontalLane1.TravelDirection = "Forward";

    Split the lane marking profile into four spans by inserting two nodes, at distances of 90 meters and 110 meters, by using the insertNode function.

    insertNode(horizontalLane1.LaneMarkingProfile,90);
    insertNode(horizontalLane1.LaneMarkingProfile,110);

    Extract the object that represents the lane marking profile of the lane from the LaneMarkingProfile property of the horizontalLane1 object. The lane marking profile represents the markings on the outer boundary of the lane.

    horLane1MarkingProfile = horizontalLane1.LaneMarkingProfile;

    Now, extract the span object horLane1Span, which represents the span on which to place the desired lane marking, from the Spans property of the lane marking profile object horLane1MarkingProfile. Mark the first span of the lane marking profile with dashed white marking type.

    horLane1Span = horLane1MarkingProfile.Spans(1);
    horLane1Span.LaneMarkingStyle = dashedWhiteMarkingStyle;

    Extract a lane marking style object, solidWhiteMarkingStyle, that represents the solid single white marking style, and use it to mark the third span of the lane marking profile.

    solidWhiteMarkingStyle = getAsset(prj,"<PROJECT>/Assets/Markings/solidsingleWhite.rrlms","LaneMarkingStyle");
    horizontalLane1Span = horizontalLane1.LaneMarkingProfile.Spans(3);
    horizontalLane1Span.LaneMarkingStyle = solidWhiteMarkingStyle;

    Add a driving lane on the right side of the horizontal road with a forward direction of travel, and mark its boundary with the solid single white marking style.

    horizontalLane2 = addLaneToRight(refLane);
    horizontalLane2.LaneType = "Driving";
    horizontalLane2.TravelDirection = "Forward";
    horLane2MarkingProfile = horizontalLane2.LaneMarkingProfile;
    horLane2Span = horLane2MarkingProfile.Spans;
    horLane2Span.LaneMarkingStyle = solidWhiteMarkingStyle;

    Add a merge lane to the left of the first horizontal lane, and add the solid white marking style to it.

    shortLane = addLaneToLeft(horizontalLane1);
    shortLane.LaneType = "Driving";
    shortLane.TravelDirection = "Forward";
    shortLaneSpan = shortLane.LaneMarkingProfile.Spans(1);
    shortLaneSpan.LaneMarkingStyle = solidWhiteMarkingStyle;

    Configure the width profile for the merge lane by specifying the WidthProfile property of the lane. The merge lane width reduces to 0 at 110 meters from the start of the road. To create a width profile at the boundary of the merge lane, insert a node at 90 meters from the start of the road, and set the start and end slope of the node using the StartSlope and EndSlope properties, respectively. By specifying the slope at the start and end of the final node of the width profile, and specifying a width of 0, the width profile gradually reduces the merge lane to a width of 0.

    shortLaneWidthProfile = shortLane.WidthProfile;
    widthChangingNode = insertNode(shortLaneWidthProfile,90);
    widthChangingNode.StartSlope = 0;
    widthChangingNode.EndSlope = 0.10;
    endNode = shortLaneWidthProfile.Nodes(end);
    endNode.Distance = 110;
    endNode.StartWidth = 0;
    endNode.EndWidth = 0;
    endNode.StartSlope = 0.10;
    endNode.EndSlope = 0.0;

    A three-lane road in a RoadRunner scene, in which the leftmost lane merges into the center lane, converging into a two-lane road.

    Version History

    Introduced in R2025a