Main Content

Scenario

Current RoadRunner scenario

Since R2025a

    Description

    The Scenario object represents the current scenario in RoadRunner Scenario. Use a Scenario object to specify the scenario in which to add scenario components, such as actors and logic.

    Creation

    To return the Scenario object that represents your current RoadRunner scenario, extract the Scenario property of your roadrunnerAPI object and assign it to a variable. For example, scnro = roadrunnerAPI(rrApp).Scenario creates the Scenario object scnro.

    Properties

    expand all

    Scenario actors, specified as an array of one of these types of objects:

    • Vehicle — Represents a vehicle actor in the RoadRunner scenario.

    • Character — Represents a character actor in the RoadRunner scenario.

    • MovableObject — Represents a movable object actor in the RoadRunner scenario.

    Logic for the scenario, specified as a PhaseLogic object.

    Object Functions

    addActorAdd actor to RoadRunner scenario
    findSceneAnchorExtract object for specified scene anchor
    validateCheck RoadRunner scenario for critical errors

    Examples

    collapse all

    Extract a Scenario object in MATLAB® to represent your current RoadRunner scenario.

    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);
    
    Extract the object for your scenario from the Scenario property of the authoring API object rrApi. The extracted Scenario object enables you to specify the scenario in which to add scenario components such as actors and logic.
    scnro = rrApi.Scenario;

    Version History

    Introduced in R2025a