Main Content

Generate Variants of ACC Target Cut-In Scenario

This example shows how to generate scenario variants from a seed scenario by varying vehicle speed. Using this example, you can test the adaptive cruise control (ACC) application against a scenario in which a target vehicle cuts into the ego lane.

Create Seed Scenario

In this example, you create a seed scenario containing the ego vehicle and a target vehicle such that the target vehicle cuts into the ego lane. The seed scenario specifies the positions, dimensions, speed values, and trajectories of both vehicles per the European New Car Assessment Programme (Euro NCAP®) test protocols. This example assumes that the ego vehicle collides with a target actor in a seed scenario. You generate variants of a seed scenario by varying the ego speed, but keeping collision point and collision time constant.

Create a seed scenario for ACC target cut-in using the helperCreateNCAPScenario function.

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

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

Setup Parameters for Scenario Variant Generation

Get predefined parameters per the Euro NCAP ACC cut-in test scenario using the helperGetNCAPParameters function. As per the specification, data for one variation is retrieved.

ACCParams = helperGetNCAPParameters("ACCTargetCutIn")
ACCParams = struct with fields:
    radiusOfTurning: 250
       changeLength: 60
           egoSpeed: 33.3333
        targetSpeed: 19.4444
    timeToCollision: 1.5000

Specify the actor identifier for the ego and target actors. You can find the ActorID and the name of an actor by inspecting the Actors property of the seed scenario object.

egoID = 1;
targetID = 2;

Generate Scenario Variants

Create a ScenarioDescriptor object containing a scenario variant by using the helperGenerateVariant function. Additionally, this helper function returns the title to use to visualize the variant scenario. The scenario variant is generated by varying the actor and event parameters of the seed scenario.

[scenarioVariantDescriptors,gridPlotTitles] = helperGenerateVariant("ACCTargetCutIn", ...
    seedScenario,ACCParams,egoID,targetID);

Get a drivingScenario object containing scenario variant from the scenarioDescriptor object by using the getScenario function.

numVariants=numel(scenarioVariantDescriptors);
variantScenario = cell(1,numVariants);
for iter = 1:numVariants
    variantScenario{iter} = getScenario(scenarioVariantDescriptors{iter}, ...
        Simulator="DrivingScenario");
end

Visualize Generated Variant

Visualize the seed scenario and the generated variant by using the helperVisualizeVariants function.

helperVisualizeVariants(seedScenario,variantScenario,"Variation for ACC Target Cut-In", ...
    gridPlotTitles,mode="StandardFit",Row=1,Column=2,Legend="off",Waypoints="on");

{"String":"Figure Variant Visualization contains 2 axes objects and other objects of type subplottext, uipanel. Axes object 1 contains 9 objects of type patch, line. Axes object 2 contains 9 objects of type patch, line.","Tex":[],"LaTex":[]}

Export to ASAM OpenSCENARIO

Export generated scenario variants to ASAM OpenSCENARIO file format V1.0.

warning("off","driving:scenario:ExportOpenScenarioODWarning");
for iter = 1:numVariants
    export(variantScenario{iter},"OpenSCENARIO","VariantScenarioACCTargetCut-In" + ...
        iter + ".xosc");
end
warning("on","driving:scenario:ExportOpenScenarioODWarning");

Explore Other Scenarios

In this example, you have explored the scenario variant generation for ACC testing where a target vehicle cuts into the ego lane. You can use the same steps to create multiple scenario variants. To create multiple scenario variants you must specify their relevant parameters. This example provides an option "ACCTargetCutInModified" to use as an argument in helperGetNCAPParameters function that returns five set of parameters to use to create five scenario variants.

For example, to get five set of parameters to use to generate relevant scenario variants, use this command.

ACCParams = helperGetNCAPParameters("ACCTargetCutInModified")

Each parameter set results in a scenario variant. To visualize five generated scenario variants, use this command.

helperVisualizeVariants(seedScenario,variantScenario, ...

"Variation for ACC Target Cut-In",gridPlotTitles,Mode="StandardFit", ...

Row=2,Column=3,Legend="off",Waypoints="on");

References

[1] Assisted Driving - Highway Assist Systems - Test & Assessment Protocol, September 2020, Version 1.0. Available from: https://cdn.euroncap.com/media/58813/euro-ncap-ad-test-and-assessment-protocol-v10.pdf

See Also

Functions

Related Topics