Main Content

addClothoidFitRoad

Add clothoid curve type road to RoadRunner scene

Since R2025a

    Description

    rrRoad = addClothoidFitRoad(scn,referencePoints) creates a new segmented curve type road and adds it to the specified RoadRunner scene, scn. The referencePoints argument specifies the position of the reference lane on the road. This function creates a segmented road curve using a clothoid curve fit for the horizontal curve and a cubic curve fit for the vertical curve.

    rrRoad = addClothoidFitRoad(___,Name=Value) creates a new clothoid fit curve type road using optional arguments, and adds it to the specified RoadRunner scene, scn.

    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;

    Use the addClothoidFitRoad function to create a clothoid fit curve type road and add it to the scene. Specify the 3-D coordinates for the reference lane.

    referencePoints = [-40 20 0; -10 0 0; 0 30 0; 20 30 0; 0 40 0];
    rrRoad = addClothoidFitRoad(scn,referencePoints,"HorizontalFitTolerance=4.5")

    Input Arguments

    collapse all

    Scene to which to add the road, specified as a Scene object.

    Position of the reference lane on the road, specified as an N-by-3 numeric matrix. N is the number of control points for the reference lane. Each row specifies the XYZ- coordinates of a control point in the RoadRunner local coordinate system.

    Name-Value Arguments

    collapse all

    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: addClothoidFitRoad(scn,referencePoints,"HorizontalFitTolerance=4.5") specifies the maximum allowable deviation between the road alignment and the ideal clothoid curve to 4.5 meters

    Tolerance of the horizontal clothoid curve fit, specified as a numeric scalar. This argument sets the tightness of the horizontal curve fit data, in meters, with respect to the provided reference points. A lower tolerance creates a more accurate fit, while a higher tolerance allows for greater deviation.

    Data Types: double

    Tolerance of the vertical cubic curve fit, specified as a numeric scalar. This argument sets the tightness of the vertical curve fit data, in meters, with respect to the provided reference points. A lower tolerance creates a more accurate fit, while a higher tolerance allows for greater deviation.

    Data Types: double

    Output Arguments

    collapse all

    Clothoid fit curve type road, returned as a Road object.

    Version History

    Introduced in R2025a