Main Content

Generate RoadRunner Scenario Using Tabular Data for AEB Car-to-Car Testing

Since R2024a

This example shows how to create an automated emergency braking (AEB) seed scenario using tabular data and generate variants by varying the speeds of the ego and target vehicles.

In this example, you use scene, lane, actor and event specification tables to create a European New Car Assessment Programme (Euro NCAP®) Car-to-Car Crossing Straight Crossing Path (CCCscp) seed scenario. In this scenario the ego and target vehicles move toward a junction on straight, perpendicular paths, resulting in a collision between the front side of the ego and a side of the target. This example also shows how to generate variants from the seed scenario by varying the ego and target vehicle speeds, keeping the collision point consistent with the seed scenario. The collision point is the position on the ego vehicle at which the ego vehicle and target vehicle collide.

In this example, you:

  • Create scene, actor, and event specification tables for AEB Car-to-Car testing.

  • Generate a seed scenario descriptor using tabular data.

  • Perform parameter variations.

  • Generate scenario variants and visualize them in RoadRunner.

Create Scenario Specification Tables

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


Specify the European New Car Assessment Programme Euro NCAP test name for the Safety Assist Automatic Emergency Braking Car-to-Car Crossing Straight Crossing Path (SA AEB CCCscp) test. Generate the Euro NCAP test specifications by using the ncapSpec function.

Note: You can generate tables for various types of Euro NCAP test scenarios by specifying their test names. For more information on Euro NCAP test names, see the ncapSpec function.

ncapTestName = "SA AEB CCCscp";
[variationSpec,ncapTestSpec,specInfo] = ncapSpec(ncapTestName)
variationSpec=30×3 table
    EgoSpeed    PrimaryTargetSpeed         PrimaryTargetDirection     
    ________    __________________    ________________________________

          0           5.5556          "Nearside Perpendicular"        
          0           8.3333          "Nearside Perpendicular"        
          0           11.111          "Nearside Perpendicular"        
          0           13.889          "Nearside Perpendicular"        
          0           16.667          "Nearside Perpendicular"        
     5.5556           5.5556          "Nearside/Farside Perpendicular"
     5.5556           8.3333          "Nearside/Farside Perpendicular"
     5.5556           11.111          "Nearside/Farside Perpendicular"
     5.5556           13.889          "Nearside/Farside Perpendicular"
     5.5556           16.667          "Nearside/Farside Perpendicular"
     8.3333           5.5556          "Nearside/Farside Perpendicular"
     8.3333           8.3333          "Nearside/Farside Perpendicular"
     8.3333           11.111          "Nearside/Farside Perpendicular"
     8.3333           13.889          "Nearside/Farside Perpendicular"
     8.3333           16.667          "Nearside/Farside Perpendicular"
     11.111           5.5556          "Nearside/Farside Perpendicular"

ncapTestSpec = struct with fields:
       SceneSpec: [1×1 struct]
    ScenarioSpec: [1×1 struct]

specInfo = struct with fields:
          NCAPTestFullName: "Safety Assist Automatic Emergency Braking Car-to-Car Crossing straight crossing path"
    StartToStopEgoDistance: 2.9000

Create the scene, lane, actor, and event specification tables by using the helperProcessNCAPSpec helper function.

[sceneData,laneData,actorData,eventData] = helperProcessNCAPSpec(ncapTestSpec,specInfo)
sceneData=5×6 table
      RoadElementType      Length_Radius    DeltaHeading    RoadElementID    LaneSpecID    ParentIntersectionID
    ___________________    _____________    ____________    _____________    __________    ____________________

    "Straight"                  600               0               1               1                  3         
    "Straight"                  600               0               2               1                  3         
    "SymmetricJunction"           8             NaN               3             NaN                NaN         
    "Straight"                  600               0               4               1                  3         
    "Straight"                  600               0               5               1                  3         

laneData=1×4 table
    LaneSpecID    LeftLaneCount    RightLaneCount         LaneMarking      
    __________    _____________    ______________    ______________________

        1               1                1           {'Solid,Dashed,Solid'}

actorData=2×8 table
    ActorID    ActorType    ActorName                           Dimension                           RelativePosition    Heading    RoadID    LaneID
    _______    _________    _________    _______________________________________________________    ________________    _______    ______    ______

       1         "Car"        "VUT"      "4.02,1.8,1.43,0.78,0.68,2.56"                              "53.8378%,50%"     "Along"      1         1   
       2         "Car"        "GVT"      "4.020000,1.800000,1.430000,0.780000,0.680000,2.560000"     "80.7445%,50%"     "Along"      4         1   

eventData=4×6 table
    EventID    ActorID        EventType         Speed     Distance    EventTrigger
    _______    _______    __________________    ______    ________    ____________

       1          1       "AcceleratedStart"    16.667     69.444     {'0s'      }
       2          2       "AcceleratedStart"    16.667     69.444     {'9.3333s' }
       3          1       "TurnLeft2"           16.667        NaN     {0×0 double}
       4          2       "TurnLeft2"           16.667        NaN     {0×0 double}

Generate Seed Scenario Descriptor Using Tabular Data

Obtain the road width information from the Euro NCAP test specification table ncapTestSpec.

roadWidth = ncapTestSpec.SceneSpec.RoadWidth;

Create a ScenarioDescriptor object by using the table2scenario function.

seedScenarioDescriptor = table2scenario(sceneData,actorData,eventData,LaneSpec=laneData,roadWidth=roadWidth);

Perform Parameter Variations

Specify the path to your RoadRunner ego asset.

assetPath = fullfile("Vehicles\Sedan.fbx.rrmeta");

Specify a subset of 25 variations from the list of all variations variationSpec.

subsetVariationSpec = variationSpec(6:30,:);

Store the proprety variations in a variationProperties object by using the helperCreateVariationProperties helper function.

variationProperties = helperCreateVariationProperties(seedScenarioDescriptor,subsetVariationSpec,assetPath);

Generate Scenario Variants and Visualize in RoadRunner

Create an array of variant ScenarioDescriptor objects by using the generateVariantsfunction.

variantDescriptors = generateVariants(seedScenarioDescriptor,variationProperties);
Connection status: 1
Connected to RoadRunner Scenario server on localhost:41097, with client id {1e49a5d9-b13b-4c67-a4dc-d669eafa33f9}

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

rrApp = roadrunnerSetup;

Create a RoadRunner scenario from your scenario descriptor object for the first generated variant by using the getScenario function. In this variant, the ego and target vehicles travel with a speed of 20 meters per second.

Note: You can visualize the seed scenario in RoadRunner by using the seedScenarioDescriptor as an input to the getScenario function. You can also visualize other variants by specifying a variantNumber value in the range 1 to 25.

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.

while strcmp(get(rrSim,"SimulationStatus"),"Running")

This figure shows the collision of the ego and target vehicle simulated in RoadRunner.

RoadRunner simulation instance showing collision between ego and target vehicle

Stop the RoadRunner simulation.


Further Exploration

You can also generate scenarios by creating your own scene, lane, actor, and event specification tables. For more information, see the table2scenario function.

You can export the scenario to the ASAM OpenSCENARIO® file format, and use the exported files to visualize it in other simulators like Unreal® and CARLA.


[1] European New Car Assessment Programme (Euro NCAP). Test Protocol – AEB Car-to-Car Systems, Version 4.2. Euro NCAP, June 2023.

See Also


Related Topics