Main Content

Generate Scenario Variants for Testing AEB Pedestrian Systems

This example shows how to generate variants of a car-to-pedestrian collision scenario that you can use for testing automated emergency braking (AEB) systems. In this example, you generate variants of a European New Car Assessment Programme (Euro NCAP®) Car-to-Pedestrian Turning Adult (CPTA) Nearside Turn collision scenario by modifying the collision point, the speed, and the dimensions of the actors in the scenario. The collision point is position on the ego vehicle at which the ego vehicle and target actor collide. This example assumes that the ego vehicle and the target actor always collide at 90 degrees with one another.

  • If the ego vehicle collides with a target actor multiple times, this example generates scenario variants based on only the first collision instance.

  • If the ego vehicle collides with multiple target actors at various times in a scenario, this example generates scenario variants for only one target actor. You can specify which target actor to consider for generating the scenario variants.

This example uses drivingScenario object to create a seed scenario and provides helper functions to generate the variants from the seed scenario. The rest of the example demonstrates the steps involved in generating the scenario variants.

Generate Seed Scenario - Create a collision scenario by using the helperCreateNCAPScenario helper function. The helper function generates the CPTA Nearside Turn test scenario of the Euro NCAP test protocol. A scenario can contain any number of actors and collision instances. This example generates a variant based on the first collision instance that occurs between the vehicle and the specified actor.

Generate Variant of Seed Scenario - Modify the seed scenario by using the functions of ScenarioVariant class. These functions enable you to generate variants of the seed scenario by altering the dimensions of the actors in the scenario, the collision fraction, or the speed of the ego actor. The collision point specifies the relative position on the front edge of the ego vehicle that first collides with the left corner (Txl,Tyl) on the front edge of the target actor. The collision point (CP) (Txl,Tyl) equation:

CP=|Exl-Txl|+|Eyl-Tyl|Egowidth

The value of the collision fraction must be in the range [0, 1]. Use the varyCollisionProperties object function of the variationProperties object to add a collision event to the generated scenario variants. You can either specify a new collision fraction for the variant or fix the collision fraction as the same as that of the seed scenario.

Simulate and Visualize Scenario Variants - Simulate and display the generated scenario variants by using the plot function.

Generate Seed Scenario

Create a drivingScenario object of the CPTA Nearside Turn Euro NCAP seed scenario by using the helperCreateNCAPScenario helper function. The function sets the actor dimensions, positions, speed values, and trajectories as per the Euro NCAP test protocol standards. The scenario contains an ego vehicle and an actor. The target actor is a pedestrian, which is the moving target that collides with the ego vehicle. The collision occurs only once during the simulation time.

seedScenario = helperCreateNCAPScenario("CPTANearsideTurn");

Create Object to Store Variant Parameters

Extract information about the seed scenario by using the getScenarioDescriptor function. The getScenarioDescriptor function creates a ScenarioDescriptor object that stores information about the actors in the seed scenario, their trajectories, and the collision event. However, the properties of the ScenarioDescriptor object are hidden.

seedScenarioDescriptor = getScenarioDescriptor(seedScenario,Simulator="DrivingScenario");

Modify Actor Dimension and Speed

Specify the ActorID values of the ego vehicle and the target actor for which you want to modify parameters. You can find the ActorID values and the names of the ego vehicle and the target actor by inspecting the Actors property of the drivingScenario object.

egoID = 1;
targetID = 2;
table([seedScenario.Actors.ActorID],[seedScenario.Actors.Name],VariableNames={'ActorID','Name'})
ans=1×2 table
    ActorID                Name            
    _______    ____________________________

    1    2     "Ego"    "Target Pedestrian"

Use the varyActorProperties object function of the variationProperties object to specify the actor parameters required to generate the scenario variant and use the varyCollisionProperties object function of the variationProperties object to add collision to the generated variation.

Define the parameters for generating four scenario variants by modifying the speed, dimension, or both of one or more actors in the seed scenario.

1) Create a scenario variant by specifying the new ego vehicle speed

Specify the new speed value for the ego vehicle in meters per second. Use the varyActorProperties object function to store the new speed values to the variationProperties object variation1.

newEgoSpeed = 5;
variation1 = variationProperties;
varyActorProperties(variation1,egoID,Speed=newEgoSpeed);
varyCollisionProperties(variation1,egoID,targetID,Actor1CollisionFraction=0.5,Actor2CollisionFraction=0);

2) Create a scenario variant by specifying new ego vehicle dimensions

Specify the new dimension values for the ego vehicle as a structure. The unit for the dimension is in meters.

egoDimensions = struct(Length=2,Height=3);

Store the new ego dimension values to the variationProperties object variation2 by using the varyActorProperties object function and add collision to the variation using varyCollisionProperties object function.

variation2 = variationProperties;
varyActorProperties(variation2,egoID,Dimension=egoDimensions);
varyCollisionProperties(variation2,egoID,targetID,Actor1CollisionFraction=0.5,Actor2CollisionFraction=0);

3) Create a scenario variant by specifying new ego vehicle and target actor dimensions

Specify the new dimension value for the ego and the target vehicle as a structure. The unit for the dimension is in meters.

variation3 = variationProperties;
egoDimensions = struct(Length=2,Height=3);
targetDimensions = struct(Length=1.5,Width=1,Height=1.8);

Store the new dimension values to the variationProperties object variation3 by using the varyActorProperties object function.

varyActorProperties(variation3,egoID,Dimension=egoDimensions);
varyActorProperties(variation3,targetID,Dimension=targetDimensions);
varyCollisionProperties(variation3,egoID,targetID,Actor1CollisionFraction=0.5,Actor2CollisionFraction=0);

4) Create a scenario variant by specifying new ego vehicle dimensions, speed, and trajectory

Specify the new dimension for the ego vehicle as a structure. The unit for dimensions is meters.

variation4 = variationProperties;
egoDimensions = struct(Length=2,Height=3);

Specify the new speed value for the ego vehicle in meters per second.

newEgoSpeed = 35;

If the trajectory of the ego vehicle is a curved path, the radius of curvature of the trajectory can also be varied depending on the speed of the ego vehicle. The radius of curvature of the ego trajectory increases for higher speed values and decreases for lower speed values. Use the helperGenerateTrajectoryatTurn helper function to modify the radius of curvature of an actor trajectory. The method returns a set of waypoints and yaw values required to generate the necessary trajectory.

[newWaypoints,newYaw] = helperGenerateTrajectoryatTurn(seedScenarioDescriptor,egoID,newEgoSpeed);

Store the new dimension, speed, waypoints, and yaw values to the variationProperties object variation4 by using the varyActorProperties object function.

newSpeed = ones(size(newWaypoints,1),1)*newEgoSpeed;
varyActorProperties(variation4,egoID,Dimension=egoDimensions,Speed=newSpeed,Waypoints=newWaypoints,Yaw=newYaw);

Specify the new collision fraction value by using the varyCollisionProperties object function.

varyCollisionProperties(variationProperties,egoID,targetID,Actor1CollisionFraction=value);

For example, to specify the new collision point value of 0.3, the syntax must be,

varyCollisionProperties(variationPropertiesParameter,egoID,targetID,Actor1CollisionFraction=0.3);

varyCollisionProperties(variation4,egoID,targetID,Actor1CollisionFraction=0.5,Actor2CollisionFraction=0);

Generate Scenario Variants

Generate variants of the seed scenario by using the generateVariants function. The function generates a scenario variant descriptor for each variation specified in the input object. The output of the function is variantDescriptors which contains the generated ScenarioDescriptor of the variations.

variation = [variation1 variation2 variation3 variation4];
[variantDescriptors,~] = generateVariants(seedScenarioDescriptor,variation);

Convert the ScenarioDescriptor object to a drivingScenario object by using the getScenario function.

numVariants = size(variantDescriptors,2);
variantScenarios = repelem(drivingScenario,numVariants);
for iter = 1:numVariants
    variantScenarios(iter) = getScenario(variantDescriptors(iter),Simulator="DrivingScenario");
end

Visualize the seed scenario and the Generated Scenario variants.

variationTitle is a list of titles that depict the variant being generated. These tiles will be added to the respective plot while visualizing the variations.

variationTitle = ["Scenario Variant 1: Change Ego Speed";
    "Scenario Variant 2: Change Ego Vehicle Dimension";
    "Scenario Variant 3: Change Ego and Target Actor dimensions";
    "Scenario Variant 4: Change Ego Speed, Trajectory and Dimension"];

Plot the seed scenario and the generated variants by using helperVisualizeVariants. You can notice the variations in the speed values of the ego vehicle and the dimensions of the actor. Also, the collision point remains the same as that in the seed scenario for all the generated scenario variants.

helperVisualizeVariants(seedScenario,variantScenarios, ...
    FigureTitle="Generated Scenario Variants",GridPlotTitles=variationTitle, ...
    Row=2,Column=3,ActorIndicators=targetID,StopAtCollision="on");

Export Generated Scenario Variants to ASAM OpenSCENARIO Format

To export the generated scenario variants to the ASAM OpenSCENARIO® file format, use the export function of the drivingScenario object. The function writes the files to the current working directory.

Specify the filenames to export each of the generated scenario variants.

fileName = ["VariantEgoSpeed"; "VariantEgoDimension"; "VariantActorDimensions"; "VariantEgoSpeedandDimension"];

Use the getScenario function to create a drivingScenario object from a ScenarioDescriptor object. Every iteration of the loop creates a variant scenario using the variant ScenarioDescriptor object and further exports the scenario object to an OpenSCENARIO file.

for i = 1:size(variantScenarios, 2)
    export(variantScenarios(i), "OpenSCENARIO", strcat(fileName(i), ".xosc"));
end

Further Exploration

Define the collision properties to add to the scenario variants by using the function getCollisionData and varyCollisionProperties.

Extract the collision properties from the seed scenario using the getCollisionData function.

collisionsInScenario = getCollisionData(seedScenarioDescriptor);

Or you may also specify the ego and target IDs to only get details of collision between the specified pair.

collisionsInScenario = getCollisionData(seedScenarioDescriptor,Actor1ID=egoID,Actor2ID=targetID);

Use the extracted collision details in collisionsInScenario that stores all the information related to the collision in the seed scenario, to recreate similar collision in variants.

collisionData = collisionsInScenario.Collision;

varyCollisionProperties also accepts a collision object as input,

varyCollisionProperties(variationPropertiesObj,collisionData);

You can also use the varyCollisionProperties object function to modify the collision in different ways. You can use the following name-value pairs to create custom collisions:

  • Actor1CollisionFraction — To fix collision point on Actor1.

  • Actor2CollisionFraction — To fix collision point on Actor2.

  • VariationType — To fix the parameter that should be changed to create the variation. Inputs are 'WaitTime', 'EntryTime' and 'Waypoints'.

For example, if the new actor1 collision point value is 0.8, and we want to change the actor waypoints to achieve the desired variation, the syntax must be,

varyCollisionProperties(variationPropertiesObj,CollisionObj,Actor1CollisionFraction=0.8,VariationType="Waypoints");

Note that when variation type is set to 'Waypoints', make sure that ego and target vehicle are starting on a straight road. Waypoint variation changes the starting position of the ego or the target and keeps collision consistent by pushing back one of the actors in a straight line.

References

[1] European New Car Assessment Programme (Euro NCAP). Test Protocol – AEB VRU systems. Version 3.0.4. EuroNCAP, April 2021. Available from: https://cdn.euroncap.com/media/62795/euro-ncap-aeb-vru-test-protocol-v304.pdf.

See Also

Functions

Related Topics