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

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

helperCheckSupportPackageInstalled

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: 0.0100
          StopTime: Inf
    SimulationTime: 0
         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

Specify the ActorID value of the ego actor by using the identifyActorOfInterest function.

actorIDs = identifyActorOfInterest(seedScenarioDescriptor);

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

Calculate the actor lane drift waypoints to vary the seed scenario by using the generateWaypoints function. Use these calculated actor properties as an input to the varyActorProperties object function to add actor variations to the scenario.

laneWidth = 3.6; % Units are in meters
numVariations = size(LKAParams.lateralVelocity,2);
variants = variationProperties.empty(numVariations,0);
for vCounter = 1:numVariations
    variants(vCounter) = variationProperties;
    xPosition = seedScenario.Actors(actorIDs.EgoID,1).Position(1);
    yPosition = laneWidth-seedScenario.Actors(actorIDs.EgoID,1).Width/2-LKAParams.d1(vCounter)-LKAParams.d2(vCounter);
    zPosition = seedScenario.Actors(actorIDs.EgoID,1).Position(3);
    egoUpdatedStartPosition = [xPosition yPosition zPosition];
    waypoints = generateWaypoints(seedScenarioDescriptor,"LaneDrift",egoUpdatedStartPosition, ...
        LKAParams.Radius(vCounter),"curveDriftDistance",LKAParams.d1(vCounter), ...
        seedScenario.Actors(actorIDs.EgoID,1).Width,postDriftTravelDistance=0);
    varyActorProperties(variants(vCounter),actorIDs.EgoID,Waypoints=waypoints);
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.

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

Visualize Generated Variants

Specify the figure heading and grid plot titles.

figHeading = "Variant for " + LKATestType;
variantTitles = "";
numVariants = length(variantScenarios);
for iter = 1:numVariants
    variantTitles(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,Title=figHeading, ...
    VariantTitles=variantTitles,GridDimension=[3 4],Mode="ChasePlotTopView",Waypoints="off");

Figure Variant Visualization contains objects of type subplottext, uipanel.

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

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 LKA scenario in 3D simulation environment.

In this example, you have explored scenario variant generation for the 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