Main Content

getCollisionData

Get collision information of colliding actors

Since R2023a

Description

collisionInfo = getCollisionData(descriptor) returns collision information for all possible pairs of colliding actors in the specified scenario descriptor.

example

collisionInfo = getCollisionData(descriptor,Name=Value) specifies options using one or more name-value arguments. For example, 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

collapse all

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]

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

collapse all

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.

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

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

collapse all

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 a collision object. The collision object has these properties:

    PropertyDescription
    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 and Actor2Info structure contains these fields:

    FieldDescription
    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, or Right.

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

collapse all

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 diagram

Collision fraction is defined by the equation

CF=|ExlTxl|+|EylTyl|WE,

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 R2023a

expand all