Main Content

Generate Scenario Variants by Modifying Actor Dimensions

This example shows how to generate scenario variants from a seed scenario by varying the ego vehicle and target vehicle dimensions. In this example, you will generate variants of a European New Car Assessment Programme (Euro NCAP®) Car-to-Pedestrian Nearside Child (CPNC) collision scenario by modifying the dimensions of the actors in the scenario. The collision point in the generated variant is ensured to be the same as that of the seed scenario. The collision point is a position on the ego vehicle at which the ego vehicle and target vehicle collide. This example assumes that the ego vehicle and the target vehicle always collide at 90 degrees.

  • If the ego vehicle collides with a target vehicle 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 vehicle. You can specify which target vehicle to consider for generating the scenario variants.

This example uses the 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.

  • Create a seed scenario.

  • Extract properties from the seed scenario and use them to create scenario variants.

  • Specify new dimensions for one or more actors in the seed scenario.

  • Generate the scenario variants.

Create Seed Scenario

Create the CPNC seed scenario by using the helperCreateNCAPScenario function.

seedScenario = helperCreateNCAPScenario("AEBModifiedCPNC")
seedScenario = 
  drivingScenario with properties:

        SampleTime: 0.0100
          StopTime: Inf
    SimulationTime: 0
         IsRunning: 1
            Actors: [1x4 driving.scenario.Actor]
          Barriers: [0x0 driving.scenario.Barrier]
       ParkingLots: [0x0 driving.scenario.ParkingLot]

Extract Properties from Seed Scenario

Extract properties from the seed scenario and store these properties in a ScenarioDescriptor object by using the getScenarioDescriptor function.

seedScenarioDescriptor = getScenarioDescriptor(seedScenario,Simulator="DrivingScenario")
seedScenarioDescriptor = 
  ScenarioDescriptor with properties:

    status: "DescriptorCreated"

Specify New Actor Dimension Values

Specify the ActorIDs of the ego and target actors whose dimensions you want to modify. You can find the ActorID and the name of an actor by inspecting the Actors property of the seed scenario stored as a drivingScenario object.

egoID = 1;
targetID = 2;

Modify Dimensions of Ego Vehicle

Create a scenario variant object by using the variationProperties object. Use the generated scenario variant object to store the new dimension values required for generating the variants.

variation1 = variationProperties();

Specify new dimension value for the ego vehicle by using the varyActorProperties object function.

egoDimensions = struct(Length=1.5,Width=1.5,Height=1.4);
varyActorProperties(variation1,egoID,Dimension=egoDimensions);

Add collision to variation by use the varyCollisionProperties object function. The varyCollisionProperties object function examines the possibility of a collision for the new actor dimensions. If a collision does not occur, the function uses a wait time modification approach to create the collision event. In this approach, the function checks the arrival time of the ego vehicle and the target vehicle at the collision point. If the ego vehicle arrives at the collision point ahead of the target vehicle, the function computes a wait time for the ego vehicle. The ego vehicle then waits at its first waypoint to ensure that it collides with the target vehicle while traveling along its trajectory. Similarly, if the target vehicle arrives at the collision point ahead of the ego vehicle, the function computes a wait time for the target vehicle to ensure a collision.

varyCollisionProperties(variation1,egoID,targetID);

To generate multiple variations of the seed scenario with ego vehicle of different dimensions, call the varyActorProperties object function for each variation. Similarly, for collision, call the varyCollisionProperties object function.

Specify a second-dimension value for the ego vehicle to create another scenario variant.

variation2 = variationProperties();
egoDimensions = struct(Length=1.5,Width=2,Height=1);
varyActorProperties(variation2,egoID,Dimension=egoDimensions);
varyCollisionProperties(variation2,egoID,targetID);

Modify Dimensions of Ego Vehicle and Target Vehicle

Vary actor properties and collision properties by using the varyActorProperties object function and the varyCollisionProperties object function respectively.

variation3 = variationProperties();
egoDimensions = struct(Length=2.5,Width=1,Height=2);
varyActorProperties(variation3,egoID,Dimension=egoDimensions);
targetDimensions = struct(Length=2.025,Width=0.67,Height=1.5);
varyActorProperties(variation3,targetID,Dimension=targetDimensions);
varyCollisionProperties(variation3,egoID,targetID);

Generate Scenario Variants

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

variation = [variation1 variation2 variation3];
[variantDescriptors,~] = 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");

Display the seed scenario and the generated variants by using the helperVisualizeVariants helper function. You can notice that the target actors in each of these scenarios wait at their first waypoint for a particular amount of time before they travel along their trajectory. You can also notice that the wait time of the target vehicle in each scenario is different in order to ensure the collision event occurs. The collision points in the three generated scenario variations remain the same as that of the seed scenario.

variantTitles = ["Scenario Variant 1:New Ego Dimension","Scenario Variant 2: New Ego Dimension","Scenario Variant 3: New Ego and Target Dimensions"];

helperVisualizeVariants(seedScenario,variantScenarios, ...
    Title="Generated Scenario Variations",VariantTitles=variantTitles, ...
    ActorIndicators=targetID,StopAtCollision="on");

Figure Variant Visualization contains 4 axes objects and other objects of type subplottext, uipanel. Axes object 1 with title Seed Scenario contains 13 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:New Ego Dimension contains 13 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: New Ego Dimension contains 13 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: New Ego and Target Dimensions contains 13 objects of type patch, line. One or more of the lines displays its values using only markers

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 dimension variation example scenario in 3D simulation environment.

You can define the collision properties to add to the scenario variants by using the getCollisionData function and the varyCollisionProperties object function.

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

collisionsInScenario = getCollisionData(seedScenarioDescriptor);

Also you can specify the ego and target IDs to get details of collision between the specified actor 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;

The varyCollisionProperties also accepts a collision object as an input,

varyCollisionProperties(variationPropertiesObj,collisionData);

This example demonstrates how to generate scenario variants by modifying the dimensions of the actors in the scenario. For information on how to generate scenario variants by modifying the actor dimensions, speed, and collision point, see Generate Scenario Variants for Testing AEB Pedestrian Systems.

References

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

See Also

Functions

Related Topics