Main Content

Generate RoadRunner Scenario Variants by Modifying Actor Assets

This example shows how to modify actor assets in a seed scenario to generate scenario variants for RoadRunner simulator.

In this example you:

  • Create a seed scenario descriptor.

  • Specify new assets for the ego vehicle, parked vehicle, and pedestrian.

  • Generate scenario variants, and visualize them in RoadRunner.

Create Seed Scenario

This example requires the Automated Driving Toolbox™ Test Suite for Euro NCAP® Protocols support package. Check if the support package is installed.

helperCheckSupportPackageInstalled

Create an AEB Car-to-Pedestrian Nearside Child Obstructed (CPNCO) seed scenario. In this scenario, the ego vehicle moves forward toward a child pedestrian, walking across its path from the nearside, resulting in a collision between the front side of the ego vehicle and the pedestrian.

Specify the type of AEB test scenario, and generate a scenario descriptor for it by using the ncapScenario function.

ncapTestName = "VRU AEB Crossing CPNCO";
seedScenarioDescriptor = ncapScenario(ncapTestName);

This figure shows the AEB CPNCO seed scenario in RoadRunner that contains an ego vehicle, a pedestrian, and two parked vehicles.

Note: You can visualize the seed scenario in RoadRunner by using the getScenario function.

AEB Car-to-Pedestrian Nearside Child Obstructed seed scenario in RoadRunner.

Vary Actor Assets

To create scenario variants, you must create a variationProperties object that contains asset information.

Initialize an array of variationProperties objects. Specify the variationCount value as 3 to create three scenario variants.

variationCount = 3;
variations(variationCount) = variationProperties;

This figure shows you the name and ID for these actors in the seed scenario:

  • Actor with ID 1 — Ego vehicle

  • Actor with ID 2 — Pedestrian

  • Actor with ID 3 — First parked vehicle

  • Actor with ID 4 — Second parked vehicle

Labeled name and IDs of the actors in the seed scenario.

RoadRunner contains assets for actors such as vehicles and pedestrians. For more information, see Actors in RoadRunner Scenario (RoadRunner Scenario). You can find these assets in the Asset folder located on your RoadRunner project path. You can also place a custom .fbx asset file inside the the Asset folder.

Specify the path to the RoadRunner asset file to use as the ego vehicle asset in your first scenario variant.

actorID1 = 1;
assetFile1 = "Vehicles/PickupTruck.fbx_rrx";
variations(1) = helperSetAsset(variations(1),actorID1,assetFile1);

Specify the path to the RoadRunner asset file to use as the pedestrian asset in your second scenario variant.

actorID2 = 2;
assetFile2 = "Characters/Citizen Male Child01.rrchar_rrx.rrmeta";
variations(2) = helperSetAsset(variations(2),actorID2,assetFile2);

Specify the paths to the RoadRunner asset files to use as the ego vehicle, pedestrian, and parked vehicle assets in your third scenario variant.

actorID3 = 3;
actorID4 = 4;
assetFile3 = "Vehicles/CompactCar.fbx_rrx";
assetFile4 = "Vehicles/Suv.fbx_rrx";
variations(3) = helperSetAsset(variations(3),actorID1,assetFile1);
variations(3) = helperSetAsset(variations(3),actorID2,assetFile2);
variations(3) = helperSetAsset(variations(3),actorID3,assetFile3);
variations(3) = helperSetAsset(variations(3),actorID4,assetFile4);

Generate Scenario Variants and Visualize in RoadRunner

Create an array of variant ScenarioDescriptor objects by using the generateVariants function.

[variantDescriptors,variantInfo] = generateVariants(seedScenarioDescriptor,variations);
Connection status: 1
Connected to RoadRunner Scenario server on localhost:60729, with client id {dd0fcdb5-ed0e-4edf-b3ae-d29cbd00eb30}

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 workflow tasks in the RoadRunner application, such as opening, closing, and saving scenes and projects. Use the helperCopyNCAPAssetToLibrary helper function to copy Euro NCAP assets to the Assets folder of your RoadRunner project.

rrApp = roadrunnerSetup;
helperCopyNCAPAssetToLibrary

Create a RoadRunner scenario from your scenario descriptor object for the first generated variant by using the getScenario function. In this variant, the ego vehicle travels with a speed of 2.77 meters per second.

Note: You can visualize the seed scenario in RoadRunner by using seedScenarioDescriptor, in place of variantDescriptors, as an input to the getScenario function. While this example visualizes the first scenario variant by default, you also visualize other variants by specifying a variantNumber value in the range 1 to 3.

variantNumber = 1;
rrSim = getScenario(variantDescriptors(variantNumber),Simulator="RoadRunner",SimulatorInstance=rrApp);

To view the scenario from the ego vehicle view or chase view, in the Simulation pane, in the Camera section, set Camera View to Follow or Front. Note that the default value of the Actor attribute is VUT, which is the ego vehicle for the scenario in this example.

set(rrSim,SimulationCommand="Start")
while strcmp(get(rrSim,"SimulationStatus"),"Running")
    pause(1)
end

This figure shows your first variant in RoadRunner, which contains a modified ego vehicle asset.

First generated scenario variant which contains a modified ego asset.

This figure shows your second variant in RoadRunner, which contains a modified asset for the pedestrian.

Second generated scenario variant which contains a modified asset for pedestrian.

This figure shows your third variant in RoadRunner, which contains modified assets for the ego vehicle, parked vehicles, and pedestrian.

AEB Car-to-Pedestrian Nearside Child Obstructed scenario variants in Unreal 3D simulation.

Stop the RoadRunner simulation.

close(rrApp)

Further Exploration

You can visualize the scenario in the Unreal Engine® 3D simulation environment by following these steps:

  1. Create variant scenarios for the DrivingScenario simulator using this command: variantScenario = getScenario(variantDescriptors,Simulator="DrivingScenario");

  2. Enter this command to open the first variant scenario in the Driving Scenario Designer app: drivingScenarioDesigner(variantScenario(1))

  3. On the app toolstrip, select 3D Display > View Simulation in 3D Display.

  4. After the app opens the Simulation 3D Viewer window, on the app toolstrip, click Run.

AEB Car-to-Pedestrian Nearside Child Obstructed scenario variants in Unreal 3D simulation.

In this example, you have explored asset variations for the AEB CPNCO scenario. You can also generate variants for other scenarios by changing the value of ncapTestName. For more information on test names, see the ncapScenario function.

This example has shown you how to generate scenario variants by modifying actor assets. You can also vary parameters other than actor assets to create scenario variants. For more information on how to generate scenario variants by modifying actor dimensions, speed, waypoints, and collision points, see the Generate Scenario Variants for Testing AEB Pedestrian Systems example.

Additionally, you can generate scenario variants as per the Euro NCAP specifications that contains asset variation. You can specify asset variations using the Euro NCAP variants by using the helperNCAPVariationProperties helper function, attached to this example as a supporting file. This helper function generates an array of variationProperties objects, variations.

egoAssetInfo = struct("ID",actorID1,AssetPath=assetFile1);

variations = helperNCAPVariationProperties(ncapTestName,egoAssetInfo);

Then, follow the rest of the procedure from the Generate Scenario Variants and Visualize in RoadRunner section to generate 22 variants with modified actor assets, defined by the Euro NCAP specifications.

References

[1] European New Car Assessment Programme (Euro NCAP). Assessment Protocol – Vulnerable Road User Protection. Version 11.3. Euro NCAP, June 2023. https://cdn.euroncap.com/media/77300/euro-ncap-assessment-protocol-vru-v113.pdf

See Also

Functions

Related Topics