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
seedScenario = helperCreateNCAPScenario("AEBModifiedCPNC")
seedScenario = drivingScenario with properties: SampleTime: 10.0000e-003 StopTime: Inf SimulationTime: 0.0000e+000 IsRunning: 1 Actors: [1×4 driving.scenario.Actor] Barriers: [0×0 driving.scenario.Barrier] ParkingLots: [0×0 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
seedScenarioDescriptor = getScenarioDescriptor(seedScenario,Simulator="DrivingScenario")
seedScenarioDescriptor = ScenarioDescriptor with properties: status: "DescriptorCreated"
Specify New Actor Dimension Values
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
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.
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
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]; [variantDescriptors,~] = generateVariants(seedScenarioDescriptor,variation);
Extract the scenario from the
ScenarioDescriptor object by using the
getScenario function. The
getScenario function returns the generated variants as a
numVariants = size(variantDescriptors,2); variantScenarios = repelem(drivingScenario,numVariants); for iter = 1:numVariants variantScenarios(iter) = getScenario(variantDescriptors(iter),Simulator="DrivingScenario"); end
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.
variationTitle = ["Scenario Variant 1:New Ego Dimension","Scenario Variant 2: New Ego Dimension","Scenario Variant 3: New Ego and Target Dimensions"]; helperVisualizeVariants(seedScenario,variantScenarios, ... FigureTitle="Generated Scenario Variations",GridPlotTitles=variationTitle, ... Row=1,Column=4,ActorIndicators=targetID);
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
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;
varyCollisionProperties also accepts a collision object as an input,
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.
 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.