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) Farside 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 used the ncapScenario functions to generate 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 ncapScenario function. The function generates the CPTA Farside 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

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

helperCheckSupportPackageInstalled

Create a ScenarioDescriptor object of the Vulnerable Road User Automatic Emergency Braking Turning Car-to-Pedestrian Turning Adult farside same (VRU AEB Turning CPTAfs) seed scenario by using the ncapScenario function. In this scenario, the ego vehicle moves forward toward an adult pedestrian crossing its path, starting in the same direction, walking across a junction from the farside, resulting in a collision between the front side of the ego vehicle and the pedestrian.

seedScenarioDescriptor = ncapScenario("VRU AEB Turning CPTAfs");

Modify Actor Dimension and Speed

Use the identifyActorOfInterest function to get the ActorIDs of the ego vehicle and the target actor for which you want to modify parameters.

actorIDs = identifyActorOfInterest(seedScenarioDescriptor);

Generate four scenario variants by specifying new values for the actor and collision parameters by using the varyActorProperties and the varyCollisionProperties object functions respectively.

1) Variant 1 — Modify ego speed and actor collision fraction values

Create a variationProperties object variation1. Specify the new values for ego speed and actor collision fraction parameters, and store them into the variationProperties object variation1.

variation1 = variationProperties;
newEgoSpeed = 15; % Unit is in meters per second.
varyActorProperties(variation1,actorIDs.EgoID,Speed=newEgoSpeed);
varyCollisionProperties(variation1,actorIDs.EgoID,actorIDs.TargetIDs,Actor1CollisionFraction=0.5,Actor2CollisionFraction=0);

2) Variant 2 — Modify ego dimension and actor collision fraction values

Create a variationProperties object, variation2. Specify the new ego dimension values as a structure. Store the new ego dimension values and the new actor collision fraction values into the variationProperties object variation2.

variation2 = variationProperties();
egoDimensions = struct(Length=2,Height=3); % Units are in meters.
varyActorProperties(variation2,actorIDs.EgoID,Dimension=egoDimensions);
varyCollisionProperties(variation2,actorIDs.EgoID,actorIDs.TargetIDs,Actor1CollisionFraction=0.5,Actor2CollisionFraction=0);

3) Variant 3 — Modify ego and target actor dimension and actor collision fraction values

Create a variationProperties object, variation3. Specify the new dimension values for the ego and the target vehicles as a structure. Store the new ego and target dimension values, and the new actor collision fraction values into the variationProperties object variation3.

variation3 = variationProperties();
egoDimensions = struct(Length=2,Height=3);% Units are in meters.
targetDimensions = struct(Length=1.5,Width=1,Height=1.8);% Units are in meters.
varyActorProperties(variation3,actorIDs.EgoID,Dimension=egoDimensions);
varyActorProperties(variation3,actorIDs.TargetIDs,Dimension=targetDimensions);
varyCollisionProperties(variation3,actorIDs.EgoID,actorIDs.TargetIDs,Actor1CollisionFraction=0.5,Actor2CollisionFraction=0);

4) Variant 4 — Modify ego dimension, speed, waypoint, yaw and actor collision fraction values

Create a variationProperties object, variation4. Specify the new ego dimension and speed values.

variation4 = variationProperties();
egoDimensions = struct(Length=2,Height=3); % Units are in meters.
newEgoSpeed = 10; % Unit is in meters per second.

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,actorIDs.EgoID,newEgoSpeed);

Store the new dimension, speed, waypoints, yaw, and actor collision values into the variationProperties object variation4.

varyActorProperties(variation4,actorIDs.EgoID,Dimension=egoDimensions,Speed=newEgoSpeed,Waypoints=newWaypoints,Yaw=newYaw);
varyCollisionProperties(variation4,actorIDs.EgoID,actorIDs.TargetIDs,Actor1CollisionFraction=0.5,Actor2CollisionFraction=0);

Generate Scenario Variants

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

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

Get an array of drivingScenario objects containing scenario variants from the ScenarioDescriptor objects by using the getScenario function.

variantScenarios = getScenario(variantDescriptors,Simulator="DrivingScenario");

Visualize Generated Variants

Convert the seed scenario descriptor to drivingScenario objects for visualization.

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

Specify the titles for each generated variant.

variantTitles = ["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"];

Visualize the seed scenario and the generated scenario variants by using helperVisualizeVariants helper function.

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, ...
    Title="Generated Scenario Variants",VariantTitles=variantTitles, ...
    ActorIndicators=actorIDs.TargetIDs,StopAtCollision="on",GridDimension = [2 3],CropType="SeedWaypoint");

Figure Variant Visualization contains 5 axes objects and other objects of type subplottext, uipanel. Axes object 1 with title Seed Scenario contains 10 objects of type patch, line. One or more of the lines displays its values using only markers Axes object 2 with title Scenario Variant 1: Change Ego Speed contains 10 objects of type patch, line. One or more of the lines displays its values using only markers Axes object 3 with title Scenario Variant 2: Change Ego Vehicle Dimension contains 10 objects of type patch, line. One or more of the lines displays its values using only markers Axes object 4 with title Scenario Variant 3: Change Ego and Target Actor dimensions contains 10 objects of type patch, line. One or more of the lines displays its values using only markers Axes object 5 with title Scenario Variant 4: Change Ego Speed, Trajectory and Dimension contains 10 objects of type patch, line. One or more of the lines displays its values using only markers

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"];

Export the generated scenario variants to ASAM OpenSCENARIO file format 1.0.

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

Further Exploration

You can visualize the scenario in a 3D simulation environment by following these steps:

  1. Enter this command to open the scenario in the Driving Scenario Designer app: drivingScenarioDesigner(variantScenarios(1));

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

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

Visualization of AEB scenario in 3D simulation environment.

You can 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=actorIDs.EgoID,Actor2ID=actorIDs.TargetIDs);

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/LSS VRU systems. Version 4.4. Euro NCAP, June 2023. Available from: https://cdn.euroncap.com/media/77299/euro-ncap-aeb-lss-vru-test-protocol-v44.pdf.

See Also

Functions

Related Topics