Contenido principal

setCameraMode

Set camera mode to visualize RoadRunner scenario simulation using MATLAB

Since R2026a

    Description

    setCameraMode(rrApp,cameramode) sets the camera mode of the specified RoadRunner Scenario application rrApp to the specified mode cameramode for simulation visualization.

    example

    setCameraMode(rrApp,cameramode,Name=Value) sets options using one or more name-value arguments. For example, FocusActorID=1 specifies to position the camera on the actor with ID 1.

    Examples

    collapse all

    Visualize a scenario simulation in the follow camera mode using MATLAB®.

    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 (RoadRunner) 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 the TrajectoryCutIn.rrscenario scenario in RoadRunner Scenario by using the openScenario function. This scenario is included by default in RoadRunner projects, and is located in the Scenarios folder of the project.

    filename = "TrajectoryCutIn.rrscenario";
    openScenario(rrApp,filename);

    Set the camera mode with which to visualize the scenario simulation of the rrApp object by using the setCameraMode function. To visualize the simulation in follow mode, set the cameramode argument to "follow". In the follow camera mode, RoadRunner positions the camera behind the selected actor in the scenario. Select the ID of the actor on which to position the camera during simulation by using the FocusActorID argument. To adjust the follow height and distance for the camera, change the FollowHeight and FollowDistance values, respectively.

    cameramode = "follow";
    setCameraMode(rrApp,cameramode,FocusActorID=1,FollowHeight=3,FollowDistance=7);

    Run the simulation by using the simulateScenario function.

    simulateScenario(rrApp);

    Input Arguments

    collapse all

    RoadRunner application associated with a project, specified as a roadrunner object. This object provides functions for performing common workflow tasks such as opening, closing, and saving scenes and projects. rrApp provides functions that support importing data from files and exporting scenes to other formats from RoadRunner.

    Camera mode with which to the visualize scenario simulation, specified as one of these values:

    ValueResolution
    "default"Use the default camera mode to visualize the scenario. In this mode, RoadRunner uses the camera mode utilized for scene editing, and returns the view to the default camera when switching from other camera types.
    "front" Use the front camera mode to visualize the scenario. In this mode, RoadRunner positions the camera at the front of the selected actor in the scenario.
    "follow"Use the follow camera mode to visualize the scenario. In this mode, RoadRunner positions the camera behind the selected actor in the scenario.
    "orbit"Use the orbit camera mode to visualize the scenario. In this mode, RoadRunner locks the camera position relative to the selected actor in the scenario, enabling orbital control. Orbital control includes rotating, zooming, and panning about the vehicle.

    Data Types: char | string

    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: setCameraMode(rrApp,"follow",FocusActorID=1) specifies to visualize the scenario simulation in the follow camera mode by positioning the camera behind the actor with ID 1.

    ID of the actor on which to position the camera during simulation, specified as a positive integer. RoadRunner orients the camera in the same direction as the forward motion direction of the selected actor. This argument is applicable only when the cameramode argument value is "front", "follow", or "orbit".

    Data Types: int32

    Follow height for the camera, in meters, specified as a positive real-valued scalar. Use this argument to specify the height at which to position the camera above the actor while following it. This argument is applicable only when the cameramode argument value is "follow".

    Data Types: double

    Follow distance for the camera, in meters, specified as a positive real-valued scalar. Use this argument to specify the distance between the camera and the back of the selected actor. This argument is applicable only when the cameramode argument value is "follow".

    Data Types: double

    Lock camera to actor orientation, specified as a logical 1 (true) or 0 (false). Use this argument to specify whether to lock the camera to the orientation of the actor on which the camera is positioned during simulation. If true, RoadRunner locks the camera to the orientation of the selected actor, enabling the camera to rotate and move with the selected actor. This argument is applicable only when the cameramode argument value is "orbit".

    Version History

    Introduced in R2026a