Main Content

Generate Scenario Variants for Lane Keep Assist Testing

This example shows you how to generate scenario variants from a seed scenario to use for lane keep assist (LKA) testing in accordance with the European New Car Assessment Programme (Euro NCAP®) test protocol standards.

Unintentional lane changes by vehicles are a major cause of accidents. The Euro NCAP specifies LKA test procedures to track the lane change behavior of autonomous vehicles. You can create a seed scenario based on the LKA test protocols, and then use the seed scenario to generate virtual driving scenarios to perform safety assessments.

In this example, you:

  • Create a seed scenario specific to the Euro NCAP test standards for LKA testing.

  • Extract a scenario descriptor from the seed scenario and use it to create scenario variants.

  • Collect actor parameters for generating variations. The parameters to vary in the seed scenario, includes actor waypoints, speed, and yaw.

  • Generate variants for input scenario.

  • Visualize the generated scenario variants next to the seed scenario.

  • Export the scenario variants to the ASAM OpenSCENARIO® file format.

Create Seed Scenario

Create a seed scenario for LKA solid lane test by specifying the type of LKA test to the helperCreateNCAPScenario function.

LKATestType = "LKASolidLane";
seedScenario = helperCreateNCAPScenario(LKATestType)
seedScenario = 
  drivingScenario with properties:

        SampleTime: 10.0000e-003
          StopTime: Inf
    SimulationTime: 0.0000e+000
         IsRunning: 1
            Actors: [1×1 driving.scenario.Vehicle]
          Barriers: [0×0 driving.scenario.Barrier]
       ParkingLots: [0×0 driving.scenario.ParkingLot]

Extract Parameters for Scenario Variant Generation

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

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

Get the LKA testing parameters for the Euro NCAP protocol standards by using the helperGetNCAPParameters function.

LKAParams =  helperGetNCAPParameters("LKA");

Perform Parameter Variations

Create a variant object by using the variationProperties object to store scenario parameter variations.

Specify the ActorID value of the ego actor.

egoID = 1;

Calculate the actor properties to vary for the seed scenario by using the helperLKATrajectoryInfo function. Use these calculated actor properties as an input to the varyActorProperties object function to add actor variations to the scenario.

  • waypoints — Actor positions in the navigation coordinate system, in meters, returned as a P-by-3 matrix. P is the number of waypoints. Each waypoint represents the position of the actor at that time in the form [x y z].

  • speed — Ego actor speed in meters per second, returned as a P-element column vector. Each row specifies the speed of the actor at the corresponding waypoint.

  • yaw — Ego yaw angle in degrees, returned as a P-element column vector. Each row specifies the yaw angle of the actor at the corresponding waypoint.

numVariations = size(LKAParams.lateralVelocity,2);
variants = variationProperties.empty(numVariations,0);
for vCounter = 1:numVariations
    variants(vCounter) = variationProperties;
	[waypoints,speed,yaw] = helperLKATrajectoryInfo(seedScenario,LKAParams.lateralVelocity(vCounter), ...
        LKAParams.d1(vCounter),LKAParams.d2(vCounter),LKAParams.yaw(vCounter));
    varyActorProperties(variants(vCounter),egoID,Waypoints=waypoints,Yaw=yaw,Speed=speed);
end

Generate Scenario Variants

Create an array of ScenarioDescriptor objects containing generated scenario variants by using the generateVariants function.

[variantDescriptors, ~] = generateVariants(seedScenarioDescriptor,variants);

Get a drivingScenario object containing scenario variants from scenarioDescriptor objects 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 Generated Variants

Specify the figure heading and grid plot titles.

figHeading = "Variant for " + LKATestType;
gridPlotTitles = "";
for iter = 1:numVariants
    gridPlotTitles(iter) = "Lateral Velocity = " + num2str(LKAParams.lateralVelocity(iter)) + " m/s";
end

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

helperVisualizeVariants(seedScenario,variantScenarios,FigureTitle=figHeading, ...
    GridPlotTitles=gridPlotTitles,Mode="ChasePlotTopView",Waypoints="off");

Export to ASAM OpenSCENARIO

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

for iter = 1:numVariants
    export(variantScenarios(iter),"OpenSCENARIO","variantScenario_" + LKATestType + iter + ".xosc")
end

Explore Other Scenarios

In this example, you have explored scenario variant generation for LKA testing with a solid lane. To generate scenario variants for another LKA testing scenario, change the LKATestType variable to the below mentioned test types, and then follow the rest of the procedure in this example to generate a seed scenario and its scenario variants. You can specify one of these options, which are in accordance with the Euro NCAP test protocol standards.

  • LKASolidLane — Solid Lane tests.

  • LKADashedLane — Dashed Lane tests.

  • LKANoLaneMarking — No Lane marking test.

For example, to generate a seed scenario for a dashed lane LKA test, use this code.

LKATestType = "LKADashedLane";

seedScenario = helperCreateNCAPScenario(LKATestType)

References

[1] European New Car Assessment Programme (Euro NCAP). Test Protocol – Lane Support Systems, Version 4.2. Euro NCAP, November 2022. https://cdn.euroncap.com/media/75440/euro-ncap-lss-test-protocol-v42.pdf

See Also

Functions

Related Topics