setCameraMode
Set camera mode to visualize RoadRunner scenario simulation using MATLAB
Since R2026a
Description
setCameraMode(
sets the camera mode of the specified RoadRunner Scenario application
rrApp,cameramode)rrApp to the specified mode cameramode for
simulation visualization.
setCameraMode(
sets options using one or more name-value arguments. For example,
rrApp,cameramode,Name=Value)FocusActorID=1 specifies to position the camera on the actor with ID
1.
Examples
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
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:
| Value | Resolution |
|---|---|
"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
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
See Also
roadrunner | openScenario | simulateScenario | exportVideo
Topics
- RoadRunner Scenario Fundamentals (RoadRunner Scenario)
- Simulate a RoadRunner Scenario Using MATLAB Functions
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)