Main Content

startRoadRunnerForScenario

Create and launch RoadRunner scenario from driving scenario

Since R2024a

Description

The startRoadRunnerForScenario function exports a RoadRunner HD Map road data model to represent the road network and static actors in a driving scenario. It also exports a CSV file with trajectory data for each dynamic actor in the driving scenario. The launched RoadRunner application then imports the HD Map and the CSV trajectory files to create the RoadRunner scenario.

To control the mapping between driving scenario actors and their corresponding RoadRunner scenario actors, you must specify the AssetPath argument for each vehicle and other actor object in the driving scenario. If you do not specify the AssetPath argument, then the startRoadRunnerForScenario function uses the default asset path mapping between the driving scenario actors and their corresponding RoadRunner scenario assets based on Class ID as illustrated in this table:

Driving Scenario Class IDDriving Scenario Actor TypeRoadRunner Asset
1CarAssets/Vehicles/ADT Vehicles/SK_Sedan.fbx
2Box TruckAssets/Vehicles/ADT Vehicles/SK_BoxTruck.fbx
3BicycleAssets/Vehicles/Cuboid.rrvehicle
4PedestrianAssets/Characters/Citizen_Male.rrchar
All other class IDsAll other custom dynamic actorsAssets/Vehicles/Cuboid.rrvehicle

You can modify the default asset path mapping using these commands:

s = settings;
s.drivingscenario.actors.DefaultClassIDToAssetPathMapping

rrApp = startRoadRunnerForScenario(scenario) creates a RoadRunner scenario using the static and dynamic elements of the driving scenario scenario, and launches the RoadRunner application with the created scenario, rrApp.

example

rrApp = startRoadRunnerForScenario(scenario,fileName="scenarioName") additionally specifies the file name for the RoadRunner HD Map and CSV trajectory files that the function exports. If you do not specify the file name, the function names the exported files as untitled.

Note

Ensure that you have write access to the directory when you run the startRoadRunnerForScenario function.

Examples

collapse all

Create a driving scenario.

 scenario = drivingScenario;

Add roads and define three lanes.

roadCenters = [-10 0 0; 60 0 0; 120 30 0; 180 60 0];
lspc = lanespec(3);
rd1 = road(scenario,roadCenters,Lanes=lspc);

Add a barrier to both sides of the road.

barrier(scenario,rd1)
barrier(scenario,rd1,RoadEdge="left")

Add an ego vehicle that travels in the center lane at a velocity of 30 m/s. Specify its RoadRunner asset path to export as an ambulance.

egovehicle = vehicle(scenario,ClassID=1,AssetPath="Assets/Vehicles/Ambulance.fbx");
egopath = [1.5 0 0; 60 0 0; 111 25 0];
egospeed = 30;
smoothTrajectory(egovehicle,egopath,egospeed);

Add a second vehicle which travels ahead of the ego vehicle at 40 m/s in the right lane, and changes lanes close to the ego vehicle. Specify its asset path to export as a pickup truck.

ftargetcar = vehicle(scenario,ClassID=1,AssetPath="Assets/Vehicles/PickupTruck.fbx");
ftargetpath = [8 2; 60 -3.2; 120 33];
ftargetspeed = 40;
smoothTrajectory(ftargetcar,ftargetpath,ftargetspeed);

Add a third vehicle which travels in the left lane at 30 m/s. Specify its asset path to export as a sedan.

ltargetcar = vehicle(scenario,ClassID=2,AssetPath="Assets/Vehicles/ADT Vehicles/SK_Sedan.fbx");
ltargetpath = [-5.0 3.5 0; 60 3.5 0; 111 28.5 0];
ltargetspeed = 30;
smoothTrajectory(ltargetcar,ltargetpath,ltargetspeed);

Plot the scenario.

plot(scenario)

Export the driving scenario to a RoadRunner scenario and launch RoadRunner application. Specify the file name.

rrApp = startRoadRunnerForScenario(scenario,FileName="myScenario");

Figure contains an axes object. The axes object with xlabel X (m), ylabel Y (m) contains 8 objects of type patch, line.

Input Arguments

collapse all

Driving scenario for export to RoadRunner scenario, specified as a drivingScenario object.

Output Arguments

collapse all

RoadRunner application object handle, returned 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.

Version History

Introduced in R2024a