Main Content

addControlPoint

Add control point to line-arc road curve

Since R2025a

    Description

    controlPoint = addControlPoint(roadCurve,position) adds a control point to the specified line-arc road curve at the specified position.

    example

    Examples

    collapse all

    Use the addControlPoint function to add control points to a line-arc road curve to modify its shape.

    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 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 and scenarios, such as by adding and modifying roads, actors, and logic components, using MATLAB.

    rrApi = roadrunnerAPI(rrApp);
    
    Extract the scene and scenario objects from the Scene and Scenario properties of the authoring API object rrApi, respectively. The extracted Scene object enables you to specify the scene in which to add scene components such as roads and lanes. The extracted Scenario (RoadRunner Scenario) object enables you to specify the scenario in which to add scenario components such as actors and logic.
    scn = rrApi.Scene;
    scnro = rrApi.Scenario;
    Extract the 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 assets to roads in your scene, or to actors in your scenario.
    prj = rrApi.Project;

    To create a line-arc road, use the addLineArcRoad function and specify the scene in which to add the road and the xy-positions of the road control points. Then, extract the line-arc curve from the HorizontalCurve property of the road rrRoad.

    rrRoad = addLineArcRoad(scn,[-100 0; 100 0]);
    lineArc = rrRoad.HorizontalCurve;
    

    Use addControlPoint to Modify Line-Arc Road Curve

    You can modify existing road curves by adding additional control points to them or changing the positions of existing control points in the scene. To change the shape and increase the total length of the line-arc curve lineArc, use the addControlPoint function to add two new control points to the curve. Specify the positions of the control points so that the curve extends smoothly in the positive y-direction.

    newPoint = addControlPoint(lineArc,[200 50]);
    newPoint2 = addControlPoint(lineArc,[200 200]);

    By default, roads do not have any lanes and RoadRunner displays only their reference lanes in the scene editor. To add lanes to the road rrRoad, first extract the reference lane object from the ReferenceLane property. Then, to add lanes to the left and right of the reference lane, use the addLaneToLeft and addLaneToRight functions, respectively, specifying the ReferenceLane object.

    roadRef = rrRoad.ReferenceLane;
    leftLane = addLaneToLeft(roadRef);
    rightLane = addLaneToRight(roadRef);
    

    Input Arguments

    collapse all

    Line-arc road curve to which to add a control point, specified as a LineArcRoadCurve object.

    Example: controlPoint = addControlPoint(lineArc,[200 50]); adds a control point to the line-arc road curve lineArc at the position [200 50] .

    Position at which to place the control point in the RoadRunner local coordinate system, specified as a two-element vector.

    Output Arguments

    collapse all

    Control point on a road curve, returned as a LineArcRoadCurvePoint object.

    Version History

    Introduced in R2025a

    See Also

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