generateVariants
Generate variant scenario descriptors from seed scenario descriptor using specified variations
Since R2023a
Syntax
Description
generates scenario variant descriptors using the seed scenario descriptor
variantDescriptors
= generateVariants(descriptor
,variations
)descriptor
and variation properties object
variations
.
[
also returns a structure, variantDescriptors
,variantInfo
] = generateVariants(descriptor
,variations
)variantInfo
, containing the properties of
actor and collision variations.
Note
This function requires the Automated Driving Toolbox™ Test Suite for Euro NCAP® Protocols support package. You can install Automated Driving Toolbox Test Suite for Euro NCAP Protocols from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.
Examples
Generate Variant Scenario from Seed Scenario
Load a driving scenario into the workspace.
load("scenarioWithSingleActor.mat")
Create a scenario descriptor from the input seed scenario.
seedScenarioDescriptor = getScenarioDescriptor(scenario,Simulator="DrivingScenario");
Create a variationProperties
object.
variation = variationProperties;
Specify actor dimension variations.
dimension=struct("Length",2,"Width",2,"Height",4);
Add a speed variation for the actor with an actorID
of 1
.
varyActorProperties(variation,1,Speed=10,Dimension=dimension);
Using the seed scenario descriptor and the speed variation, generate a scenario variant descriptor.
scenarioVariantDescriptor = generateVariants(seedScenarioDescriptor,variation);
Generate a variant scenario, as a drivingScenario
object, from the scenario variant descriptor object.
scenarioVariant = getScenario(scenarioVariantDescriptor,Simulator="DrivingScenario");
Create a custom figure window to plot the seed scenario and the scenario variant.
figScene = figure; set(figScene,Position=[200 200 600 300]) hCarViewPanel1 = uipanel(figScene,Position=[0 0 0.5 1],Title="Input Seed Scenario"); hCarPlot1 = axes(hCarViewPanel1); hCarViewPanel2 = uipanel(figScene,Position=[0.5 0 0.5 1],Title='Generated Scenario Variant'); hCarPlot2 = axes(hCarViewPanel2);
Plot both the scenarios and run the simulation. Observe the actor speed and dimension variation in the generated scenario variant.
plot(scenario,Waypoints="on",Parent=hCarPlot1) plot(scenarioVariant,Waypoints="on",Parent=hCarPlot2) flag1 = 1; flag2 = 1; while (flag1 || flag2) if(flag1) flag1 = advance(scenario); end if(flag2) flag2 = advance(scenarioVariant); end pause(0.01) end
Input Arguments
descriptor
— Scenario descriptor
ScenarioDescriptor
object
Scenario descriptor, specified as a ScenarioDescriptor
object. The
ScenarioDescriptor
object stores scene, actor, and vehicle
information extracted from a seed scenario.
To get a ScenarioDescriptor
object from an input scenario, use the
getScenarioDescriptor
function.
variations
— Variation properties
1-by-N vector of variationProperties
objects
Variation properties, specified as a 1-by-N vector of variationProperties
objects. N is the number of scenarios
with variation properties. The variationProperties
object stores actor
and collision variation properties to use to create scenario variants.
Output Arguments
variantDescriptors
— Scenario variant descriptors
1-by-N vector of scenarioDescriptor
objects
Scenario variant descriptors, returned as a 1-by-N vector of
ScenarioDescriptor
objects. N is the number of
variant scenarios. For each variation specified in the input
variations
argument, this function generates a scenario variant
descriptor.
The generateVariants
function extracts information from the
input seed scenario descriptor descriptor
, modifies the actor and
collision properties specified by the variations
input argument,
and stores the returned scenario variant descriptors in
variantDescriptors
. You can use these scenario variant descriptors to
perform safety assessments for various automated driving applications.
variantInfo
— Variant information
1-by-N array of structures
Variant information, returned as a 1-by-N array of structures. N is the number of scenarios with variant information. Each structure contains these fields:
Field | Description |
---|---|
ValidVariant | Valid variant flag, returned as |
ActorVariationProperties | Actor variation properties, returned as a structure with these fields:
|
CollisionVariationProperties | Collision variation properties, returned as a structure with these fields:
|
Messages | Messages and warnings related to the generated variants, returned as a string scalar or character vector. The
|
BehaviorUnderTest | Behavioral safety assessment test parameters, returned as a structure with these fields:
|
EventTime (since R2024a) | Time at which an event occurs, returned as a scalar. For example, for a collision event, this field represents the time at which the collision occurs. Units are in seconds. |
EgoTrajectory (since R2024a) | Trajectory information of the ego vehicle, returned as a structure with these fields:
Note If the function is unable to identify an ego, it returns the trajectory data of its first identified actor. |
Limitations
To apply collision variations, your seed scenario must contain actor collisions.
The collision side of an actor in the seed scenario must match the collision side of that actor for which you generate variants.
To generate actor collision fraction variations, the actors in the seed scenario must collide at 0 degree and 90 degree angles.
Version History
Introduced in R2023aR2024a: Output variantInfo
structure contains additional fields
The output variantInfo
structure now includes a field
EventTime
which specifies the time at which the event occurs.
The output variantInfo
structure now includes a structure,
EgoTrajectory
, with these fields:
Timestamps
Waypoints
Velocity
Roll
Pitch
Yaw
AngularVelocity
EgoCenterWaypoints
R2023b_plus: Output variantInfo
structure contains additional safety assessment test parameters
The output variantInfo
structure now includes a structure,
BehaviorUnderTest
, with these additional fields:
HandoverTime
StartTestTime
EndTestTime
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)