Contenido principal

insertNode

Insert node in span sequence

Since R2025a

    Description

    spanNode = insertNode(spanSequence,distance) inserts a new node at a specified distance in the span sequence. The inserted node allows precise manipulation of the span sequence by acting as its localized control point. The position of each node is specified by its distance from the starting point of the reference line of the road.

    example

    Examples

    collapse all

    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 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 scene in RoadRunner by using the newScene function, specifying the roadrunner object rrApp.

    newScene(rrApp)
    

    Create a RoadRunner authoring API object, 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 lane 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 components, such as roads and lanes.
    scn = rrApi.Scene;

    Extract the object for your RoadRunner project from the Project property of the authoring API object rrApi. The extracted Project (RoadRunner)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 add lane markings to the lanes in your scene.

    scn = rrApi.Project;

    Use the addLineArcRoad function to add a new road with a line-arc horizontal curve type to the scene. 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. Set the control points of the road to -100 and 50 on the X- axis and Y- axis, respectively.

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

    Extract the reference lane from the ReferenceLane property of the road rrRoad. The extracted property ReferenceLane defines the center line of the road.

    refLane = rrRoad.ReferenceLane;

    Use the getAsset function to retrieve the LaneMarkingStyle objects for dashed solid yellow lane marking and solid yellow lane marking. These objects define the lane marking assets used to mark the spans in the lane marking profile of the reference lane.

    dashedSolidYellowMarkingStyle = getAsset(prj, "<PROJECT>/Assets/Markings/DashedSolidYellow.rrlms", "LaneMarkingStyle");
    solidDoubleYellowMarkingStyle = getAsset(prj, "<PROJECT>/Assets/Markings/SolidDoubleYellow.rrlms", "LaneMarkingStyle");

    Use the LaneMarkingProfile property of the refLane object to extract the lane marking profile of the reference lane.

    refLaneMarkingProfile = refLane.LaneMarkingProfile;

    Insert nodes in the lane marking profile at three 30-meter spans using the insertNode function. This divides the lane marking profile into four spans by inserting nodes at 30 meters, 60 meters, and 90 meters.

    insertNode(refLaneMarkingProfile, 30);
    insertNode(refLaneMarkingProfile, 60);
    insertNode(refLaneMarkingProfile, 90);
    

    Input Arguments

    collapse all

    Span sequence, specified as a SpanSequence object.

    Distance of the node along the span sequence specified as a numeric scalar. Units are in meters. This distance is measured relative to the start of the span sequence and must lie within the range [0, total length of the span sequence].

    By default, a span sequence in RoadRunner includes two fixed nodes— one at the start (0 meters) and one at the end (equal to the total length of the span sequence). These nodes define the initial span and cannot be repositioned. You can add additional nodes at custom distances along the span sequence.

    Data Types: double

    Output Arguments

    collapse all

    New node inserted in the span sequence, returned as a SpanSequenceNode object.

    Version History

    Introduced in R2025a

    See Also

    (RoadRunner) | (RoadRunner) | (RoadRunner) |