Contenido principal

Relocate Scenarios

In RoadRunner Scenario, you can move scenarios around within a scene and relocate scenarios to different scenes entirely. By relocating scenarios, you can test how driving algorithms handle the same scenario in various environments.

Relocate Scenario Within a Scene

RoadRunner Scenario uses an anchoring system in which you position the actors and path waypoints relative to specific anchor points, such as a point on a road or a point specifying an actor location. If you drag an anchor along a road, any actors that are attached to that anchor move with it. For example, this figure shows a scene anchor, and the scenario attached to it, moving from a straight portion of a road to a curved portion.

Anchor dragging a scenario with red and white car along road

You can drag anchors along only the road that they belong to. To move a scenario to an entirely new road, you must update the parent anchor of each actor. For more details on changing parent anchors, see Change Anchor Parent.

When relocating scenarios along a road, actors maintain their lane-relative positions. For example, suppose a car is in the rightmost lane (zero lanes from the road edge) and a turning lane forms as the road approaches an intersection. If you move the anchor along the road toward the intersection, the car moves into the turning lane to maintain a relative position of zero from the road edge.

Anchor selected and vehicle in rightmost lane before turning lane.

Anchor moved right and vehicle moves into turning lane on right road edge.

If you want a vehicle to stay in the same lane throughout a scenario, then you must set a predefined path for it. For an example of setting a predefined path, see Design Path Following Scenario.

Relocate Scenario to New Scene

RoadRunner Scenario provides both an interactive and a programmatic way to load an existing scenario into a new scene.

Note

When you load a scenario into a new scene, the new scene must contain anchors with the same names as the parent anchors of the scenario actors. If no such anchors exists in the new scene, then you must manually place your anchors into the scene.

When developing scenes for use with multiple scenarios, consider using consistent names for all scene anchors in the scenario. To change an anchor name, select the anchor and update the Name attribute. To add new anchors to scenes, use the Scene Anchor Tool. For more information on anchors, see Scenario Anchoring System.

To move or edit an anchor in a scene or scenario, you must activate the Scene Anchor Tool or Anchor Tool, respectively.

Relocate Scenarios Interactively

By default, when you open a scenario, the scenario opens into the scene that it was last saved with. To open a scenario into a different scene, follow these steps:

  1. Switch to scene editing mode. From the top-right corner of the RoadRunner application, select Scenario Editing, then Scene Editing.

    Scene Editing and Scenario Editing toggle with Scene Editing selected

  2. Open the scene that you want to load the scenario into. From the File menu, select Open Scene and, in the file explorer, select the scene file you want to use. For example, this figure shows the SanAntonio scene, which is one of the scenes included by default in the Scenes folder of RoadRunner projects.

    SanAntonio scene

  3. Switch to scenario editing mode. From the top-right corner of the RoadRunner application, select Scene Editing, then Scenario Editing.

    Scene Editing and Scenario Editing toggle with Scenario Editing selected

  4. Load the scenario into the opened scene. From the File menu, select Open Scenario into Current Scene and, in the file explorer, select the scenario file you want to use. For example, this figure shows the TrajectoryCutIn scenario, which is one of the scenarios included by default in the Scenarios folder of RoadRunner projects.

    Scenario loaded into SanAntonio scene

In this example, loading the TrajectoryCutIn scenario into the SanAntonio scene works because:

  • The scene contains a scene anchor named ScenarioStart.

  • The actors in the TrajectoryCutIn scenario have the scene anchor ScenarioStart as their parent.

The ScenarioBasic scene also has a scene anchor named ScenarioStart, so you can load the scenario into this scene as well.

Scenario loaded into ScenarioBasic scene

If you load a scenario into a new scene that does not have anchors with names corresponding to those in the scenario, RoadRunner displays this warning at the bottom of the RoadRunner Scenario interface, in the Attributes pane, and in the Output pane.

Unmapped anchors warning message that says: Anchors in the scenario do not have known locations in the scene. Select and place each anchor in the scene

To resolve this issue, remap the unmapped anchors. RoadRunner provides a list of all anchors in your scenario in the Unmapped Anchors section of the Attributes pane. To place an anchor and the accompanying scenario objects in the scene, select an anchor from the Unmapped Anchors pane, and then right-click the location on the road where you want to place it. The new anchor inherits the name and actors of the selected anchor in the Unmapped Anchors section of the Attributes pane.

Alternatively, you can remap unmapped anchors to existing anchors in the scene. First, select an anchor from the Unmapped Anchors pane, and the left-click an existing anchor on the road. An existing anchor inherits actors, but does not inherit the name of the selected unmapped anchor.

Note

Remapped anchors match the default anchor type specified in the Application Preferences.

Unmapped Anchors pane with a list of anchors

Relocate Scenarios Programmatically

You can programmatically relocate a scenario to a new scene by using MATLAB® functions. For example, this MATLAB code reproduces the example of loading the TrajectoryCutIn scenario into the SanAntonio scene. The code assumes that you have a project located in the directory C:\RR\MyProject, and that you are using Windows®.

projectFolder = fullfile("C:","RR","MyProject");
rrApp = roadrunner(projectFolder);
openScene(rrApp,"SanAntonio");
openScenario(rrApp,"TrajectoryCutIn",keepCurrentScene=true);

For more details on using these functions to relocate scenarios, see SaveScenario.

Alternatively, you can use the language-neutral gRPC® API. This command-line code is equivalent to the previously shown MATLAB code.

AppRoadRunner --projectPath="C:\RR\MyProject"
CmdRoadRunnerApi "LoadScene(file_path='SanAntonio')"
CmdRoadRunnerApi "LoadScenario(file_path='TrajectoryCutIn' keep_current_scene='true')"

For more details on using the gRPC API to relocate scenarios, see Reuse Scenarios in Multiple Scenes Using gRPC API.

Troubleshooting

When you relocate your scenario to a new scene, you must remap your anchors to roads compatible with the Lane Offset and Forward Offset values of the associated actors. For example, suppose you place an actor on a road with two lanes in your original scene and set Lane Offset to 1 lane(s). If, in a new scene, you remap the anchor for that actor to a road with only one lane, the Lane Offset value becomes invalid.

Actors with invalid Lane Offset or Forward Offset values display a red exclamation icon and this error in the Attributes pane: This point has an unreachable forward or lane offset. Lane offset errors occur when the original Lane Offset value of an actor is greater than the number of additional lanes, traveling in the same direction as the actor lane, on a road. Similarly, Forward Offset errors occur when the original forward offset value of an actor is greater than the distance from its anchor to the end of the road in its direction of travel.

Sedan actor with Attributes pane containing error message

To fix these errors, select the affected actor. Then, in the Attributes pane, replace any invalid Lane Offset or Forward Offset values with values that are valid for the new road. Alternatively, you can remap the anchor to a road compatible with the existing forward and lane offsets of the associated actor. To learn more about the Lane Offset and Forward Offset attributes, see Lane Offset and Point Offsets, respectively.

Selected sedan actor and accompanying attributes pane with the Lane Offset attribute highlighted

See Also

Topics