Main Content

roadrunnerAPI

RoadRunner authoring API

Since R2025a

    Description

    The roadrunnerAPI object enables you to programmatically author RoadRunner scenarios, such as by adding actors, creating routes, and building scenario logic, using MATLAB®. By authoring scenarios programmatically, you can quickly automate repetitive authoring tasks, generate scenario variations for automated tests, and build and modify simulation parameters without switching between applications. To use the RoadRunner authoring API in MATLAB, you must first create a roadrunnerAPI object for your RoadRunner session.

    Creation

    Description

    rrApi = roadrunnerAPI(rrApp) returns the RoadRunner authoring API object rrApi for the current RoadRunner session rrApp.

    Input Arguments

    expand all

    RoadRunner application, specified as a roadrunner object.

    Properties

    expand all

    This property is read-only.

    Current RoadRunner scenario, represented as a Scenario object.

    Example: scnro = rrApi.Scenario extracts the scenario object scnro from the Scenario property of the RoadRunner authoring API rrApi.

    This property is read-only.

    Current RoadRunner project, represented as a Project object.

    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.

    Open an existing scene in RoadRunner by using the openScene function, specifying the roadrunner object rrApp and the filename of the specific scene that you want to open. Then, use the newScenario function to create a new scenario.

    openScene(rrApp,"ScenarioBasic.rrscene")
    newScenario(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 scenarios, such as by adding and modifying actors and logic components, using MATLAB.

    rrApi = roadrunnerAPI(rrApp);
    

    Limitations

    • If you do not open RoadRunner from MATLAB using the roadrunner function, or if you open a RoadRunner session before opening MATLAB, you must add the path to the folder containing the RoadRunner authoring API to your MATLAB session before you can use the RoadRunner authoring API functions. By default, the location of the RoadRunner authoring API folder on Windows is C:\Program Files\RoadRunner R20NNx\bin\win64\Tools\MATLAB\api, where R20NNx is the release version you are using.

    Version History

    Introduced in R2025a