getCollisionData
Syntax
Description
returns collision information for all possible pairs of colliding actors in the specified
scenario collisionInfo
= getCollisionData(descriptor
)descriptor
.
specifies options using one or more name-value arguments. For example,
collisionInfo
= getCollisionData(descriptor
,Name=Value
)Actor1ID=2
checks for collision between the actor with the ID 2, and
all other actors in the scenario.
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
Extract Collision Information From Scenario
Load a driving scenario containing actor collision into the workspace.
load("scenarioWithSingleCollision.mat")
Create a scenarioDescriptor
object using the loaded driving scenario scenario
.
scenarioDescriptor = getScenarioDescriptor(scenario,Simulator="DrivingScenario");
Extract collision information from the scenarioDescriptor
object.
collisionsInScenario = getCollisionData(scenarioDescriptor);
Display the extracted collision information.
disp(collisionsInScenario.Collision)
Collision with properties: Time: 0.4981 Point: [28.4345 4.0853] Actor1Info: [1×1 struct] Actor2Info: [1×1 struct]
Extract Collision Information From Scenario with Multiple Collisions
Load a driving scenario containing multiple actor collisions into the workspace.
load("scenarioWithMultipleCollisions.mat")
Create a scenarioDescriptor
object using the loaded driving scenario scenario
.
scenarioDescriptor = getScenarioDescriptor(scenario,Simulator="DrivingScenario");
Extract collision information from the scenarioDescriptor
object.
collisionsInScenario = getCollisionData(scenarioDescriptor);
Display the extracted information of first collision.
disp(collisionsInScenario(1).Collision)
Collision with properties: Time: 3.0102 Point: [30.5809 -1.0907] Actor1Info: [1×1 struct] Actor2Info: [1×1 struct]
Display the extracted information of second collision.
disp(collisionsInScenario(2).Collision)
Collision with properties: Time: 1.6756 Point: [1.1088 -1.1493] Actor1Info: [1×1 struct] Actor2Info: [1×1 struct]
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, and uses this information to generate the
scenario variants. You can use these scenario variants to perform safety assessments for
various automated driving applications.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: getCollisionData(D,Actor1ID=[2 3],Actor2ID=[5 6])
checks for
collisions of all possible pairs of the actors with IDs 2 and 3 and those with IDs 5 and
6.
Actor1ID
— First actor ID
positive integer | row vector of positive integer
First actor ID, specified as a positive integer or a row vector of positive integers.
If you do not specify Actor2ID
, the function checks for
collision between each actor specified by Actor1ID
and all other
actors in the scenario.
If you specify Actor2ID
, the function checks collision for
all possible pairs between the actors specified by Actor1ID
and
those specified by Actor2ID
.
Data Types: single
| double
| uint8
Actor2ID
— Second actor ID
positive integer | row vector of positive integer
Second actor ID, specified as a positive integer or a row vector of positive integers.
If you do not specify Actor1ID
, the function checks for
collision between each actor specified by Actor2ID
and all other
actors in the scenario.
If you specify Actor1ID
, the function checks collision for
all possible pairs between the actors specified by Actor2ID
and
those specified by Actor1ID
.
Data Types: single
| double
| uint8
Output Arguments
collisionInfo
— Collision information between pairs of colliding actors
array of structures | []
Collision information between pairs of colliding actors, returned as an array of structures. Each structure in the array contains these fields:
Actor1ID
— ID of the first colliding actor in the pair, returned as a positive integer.Actor2ID
— ID of the second colliding actor in the pair, returned as a positive integer.Collision
— Collision information, returned as acollision
object. Thecollision
object has these properties:Property Description Time
Simulation time at which collision occurs.
Units are in seconds.
Point
Coordinates of the collision point in the world frame.
Units are in meters
Actor1Info
Information about the first actor in the collision pair, returned as a structure.
Actor2Info
Information about the second actor in the collision pair, returned as a structure.
Each
Actor1Info
andActor2Info
structure contains these fields:Field Description ID
ID of the corresponding actor, returned as a positive integer.
Position
Position of the actor at the time of collision, returned as a three-element numeric row vector of the form [latitude longitude altitude].
Units are in meters.
Speed
Speed of the actor at the time of collision, returned as a scalar.
Units are in meters per second.
Yaw
(since R2024a)Yaw angle of the actor at the time of collision, returned as a scalar. Units are in radians.
CollisionFraction
Point of collision relative to the collision side of the actor, returned as a fraction in the range [0, 1]. For more information, see Collision Fraction.
CollisionSide
Side of the actor at which collision occurs, returned as
Front
,Left
,Back
, orRight
.
Note
If the input scenario contains no collisions, or no collisions between the
specified pairs of actors Actor1ID
and
Actor2ID
, the function returns
collisionInfo
as an empty array,
[]
.
More About
Collision Fraction
The collision fraction specifies the relative position on the
collision side of a vehicle at which the collision occurs. For example, if the center of the
front edge of the ego vehicle Actor-1
collides with the left corner on
the front edge of the target vehicle Actor-2
, then the collision fraction
of Actor-1
is 0.5
.
Collision fraction is defined by the equation
where Exl and Eyl are the x- and y-coordinates of the left corner of the ego vehicle collision side, Txl and Tyl are the x- and y-coordinates of the collision point on the target vehicle, and WE is the width of the collision side of the ego vehicle.
Version History
Introduced in R2023aR2024a: Output collisionInfo
structure contains additional actor yaw information
The output Actor1Info
and Actor2Info
structure now
includes an additional Yaw
field, specifying the yaw angles of the actor
at the time of collision.
See Also
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)