Main Content

Translate Scenario Between Driving Scenario and RoadRunner Scenario

The Driving Scenario Designer app and RoadRunner Scenario are both interactive editors that enable you to design scenarios for simulating and testing automated driving systems. Translating a scenario between a driving scenario and a RoadRunner scenario enables you to test the scenario in both environments without redesigning the scenario. The Automated Driving Toolbox™ Test Suite for Euro NCAP® Protocols support package includes these functions for translating scenarios between driving scenarios and RoadRunner scenarios.

  • getScenarioDescriptor function — Returns a scenario descriptor object containing properties from the input scenario. The input scenario can be a driving scenario or a scenario created using RoadRunner Scenario.

  • getScenario function — Creates a scenario object for the specified simulator, "DrivingScenario" or "RoadRunner", returned as a drivingScenario object or a RoadRunner ScenarioSimulation object, respectively. The getScenario function bases its output scenario on the specified scenario descriptor object, such as one returned by the getScenarioDescriptor function.

This figure shows the usage of these functions to translate scenarios between driving scenarios and RoadRunner scenarios.

For more information on the Driving Scenario Designer app, see Driving Scenario Designer. For more information on the Automated Driving Toolbox Test Suite for Euro NCAP Protocols support package, see Get Started with Euro NCAP Test Suite.

Prerequisites

Translating scenarios between driving scenarios and RoadRunner scenarios requires a RoadRunner installation and these products:

  • RoadRunner Scenario — To import the trajectories of dynamic actors from the driving scenario.

  • Automated Driving Toolbox Test Suite for Euro NCAP Protocols support package — To translate scenarios between driving scenarios and RoadRunner scenarios.

  • RoadRunner Asset Library Add-On (optional) — To map actor assets between driving scenarios and RoadRunner scenarios.

Translate Scenario from Driving Scenario to RoadRunner Scenario

Actor Mapping from MATLAB Driving Scenario to RoadRunner Scenario

When you use the getScenario function to generate a RoadRunner scenario from a driving scenario, the Automated Driving Toolbox Test Suite for Euro NCAP Protocols support package adds several dynamic actor assets to the RoadRunner project folder. This table illustrates the default mapping of dynamic actors in a driving scenario to a RoadRunner scenario based on the actor asset parameters in the driving scenario.

Driving Scenario Class IDDriving Scenario Actor TypeRoadRunner Asset Path
1CarAssets/Vehicles/Sedan.fbx
2Box TruckAssets/EuroNCAPTestSuite/Truck.rrvehicle.rrmeta
3BicycleAssets/EuroNCAPTestSuite/Bicyclist.rrvehicle.rrmeta
4PedestrianAssets/EuroNCAPTestSuite/Pedestrian.rrchar.rrmeta
All other class IDsAll other custom dynamic actorsAssets/Vehicles/ADT Vehicles/SK_Sedan.fbx

Translate Scenario from Driving Scenario to RoadRunner Scenario

Create a driving scenario.

scenarioDS = drivingScenario;

Add an intersection, comprised of two road segments to the scenario.

road(scenarioDS,[0 -25; 0 25],lanes=lanespec([1 1]))
ans = 
  Road with properties:

           Name: ""
         RoadID: 1
    RoadCenters: [2×3 double]
      RoadWidth: 7.3500
      BankAngle: [2×1 double]
        Heading: [2×1 double]

road(scenarioDS,[-25 0; 25 0],lanes=lanespec([1 1]))
ans = 
  Road with properties:

           Name: ""
         RoadID: 2
    RoadCenters: [2×3 double]
      RoadWidth: 7.3500
      BankAngle: [2×1 double]
        Heading: [2×1 double]

Create a smoothed trajectory by adding an ego vehicle, waypoints, speed, and yaw information to the scenario.

egoVehicle = vehicle(scenarioDS,ClassID=1);
waypoints = [-20 -2; 
              -5 -2; 
               2  5; 
               2 20];
speed = [6 5 5 6];
yaw = [0 0 90 90];
smoothTrajectory(egoVehicle,waypoints,speed,Yaw=yaw)

Plot the driving scenario.

plot(scenarioDS,Waypoints="on")

Create a driving scenario descriptor.

dsDescriptor = getScenarioDescriptor(scenarioDS);

Start the RoadRunner application interactively by using the roadrunnerSetup function. The function opens a dialog box in which you specify the project folder and installation folder to use when opening RoadRunner. The function returns a roadrunner object, rrApp, that enables you to perform common tasks in the RoadRunner application, such as opening, closing, and saving scenes and projects.

rrApp = roadrunnerSetup;

Update the RoadRunner Scenario visualization and the roadrunner object rrApp with the scenario from your driving scenario descriptor object.

getScenario(dsDescriptor,Simulator="RoadRunner",SimulatorInstance=rrApp);
Connection status: 1
Connected to RoadRunner Scenario server on localhost:54322, with client id {4288909b-cc65-4e84-b3af-f70a22577948}

This figure shows the scenario translated from the driving scenario to RoadRunner Scenario.

Exported driving scenario in RoadRunner.

Save the scenario in RoadRunner Scenario in the specified RoadRunner project folder.

saveScenario(rrApp,"FourWayScenario")

Stop and close the RoadRunner simulation.

close(rrApp)

Translate Scenario from RoadRunner Scenario to Driving Scenario

Actor Mapping from RoadRunner Scenario to Driving Scenario

When you use the getScenario function to generate a driving scenario from a RoadRunner scenario, the Automated Driving Toolbox Test Suite for Euro NCAP Protocols support package assigns actor parameters in the driving scenario based on the size of the actor assets in the RoadRunner scenario. This table illustrates the default mapping of dynamic actors in a RoadRunner scenario to a driving scenario based on the size of the actor assets in the RoadRunner scenario.

RoadRunner Asset Length (meters)RoadRunner Asset Width (meters)RoadRunner Asset Height (meters)Driving Scenario Class IDDriving Scenario ObjectDriving Scenario Actor Type
0.750.71.854ActorPedestrian
1.951<2.23ActorBicycle
NA>5NA2VehicleBox Truck
All other sizesAll other sizesAll other sizes1VehicleCar

Translate Scenario from RoadRunner Scenario to Driving Scenario

Start the RoadRunner application interactively by using the roadrunnerSetup function. The function opens a dialog box in which you specify the project folder and installation folder to use when opening RoadRunner. The function returns a roadrunner object, rrApp, that enables you to perform common tasks in the RoadRunner application, such as opening, closing, and saving scenes and projects.

rrApp = roadrunnerSetup;

Open the scenario "FourWayScenario" in RoadRunner Scenario from the specified RoadRunner project folder.

Note: You can create the "FourWayScenario" scenario by running the Translate Scenario from Driving Scenario to RoadRunner Scenario example.

openScenario(rrApp,"FourWayScenario")

This figure shows the scenario in RoadRunner Scenario.

FourWayScenario in RoadRunner Scenario

Create a RoadRunner Scenario simulation object.

rrSim = createSimulation(rrApp);
Connection status: 1
Connected to RoadRunner Scenario server on localhost:54322, with client id {0b0f5147-fe2d-499f-a8a7-c997a0dc752c}

Create a structure to store RoadRunner simulation information.

rrScenario.SimulatorInstance = rrApp;
rrScenario.SimulationInstance = rrSim;

Create a RoadRunner scenario descriptor.

rrDescriptor = getScenarioDescriptor(rrScenario);

Stop and close the RoadRunner simulation.

close(rrApp)

Create a driving scenario from your RoadRunner scenario descriptor object.

scenarioDS = getScenario(rrDescriptor,Simulator="DrivingScenario");

Plot the driving scenario translated from RoadRunner Scenario.

plot(scenarioDS,Waypoints="on")

Further Exploration

In this example, you have explored translating a scenario from a RoadRunner scenario to a driving scenario. You can also read the translated driving scenario into a Simulink® model by using the Scenario Reader block to obtain additional scene and actor information, such as actor poses. You can use this information to test an advanced driver assistance system (ADAS) or automated driving model built in Simulink. For more information, see the Test Open-Loop ADAS Algorithm Using Driving Scenario and Test Closed-Loop ADAS Algorithm Using Driving Scenario examples.

Limitations

Driving Scenario to RoadRunner Scenario Translation Limitations

Translating dynamic actors and other driving scenario elements to a RoadRunner scenario has these limitations:

  • The driving scenario must have at least one road.

  • Driving scenarios with road groups are not supported.

  • Dynamic actors with reverse motion are not supported.

  • Dynamic actors with spawn and despawn parameters are not supported.

  • Export operation is not supported for the Mac platform and MATLAB® Online™.

RoadRunner Scenario to Driving Scenario Translation Limitations

Translating scenarios from RoadRunner scenarios to driving scenarios does not retain scenario logic. For more information on logic in RoadRunner Scenario, see Define Scenario Logic (RoadRunner Scenario).

RoadRunner scenarios translated to driving scenarios have the same additional limitations as ASAM OpenDRIVE® files imported to driving scenarios. For more information, see ASAM OpenDRIVE Import Limitations.

See Also

Functions

Related Topics