driving.scenario.targetsToEgo

Convert actor poses to ego vehicle coordinates

Description

example

targetPoses = driving.scenario.targetsToEgo(actorPoses,egoPose) converts the poses of target actors from the world coordinates of a driving scenario to the coordinate system of an ego vehicle with pose egoPose. See Ego Vehicle and Targets for more details.

Examples

collapse all

Create a driving scenario containing three vehicles. Find the target poses of two of the vehicles as viewed by the third vehicle. Target poses are returned in the ego-centric coordinate system of the third vehicle.

Create a driving scenario.

scenario = drivingScenario;

Create the target actors.

actor(scenario,'Position',[10 20 30], ...
    'Velocity',[12 113 14], ...
    'Yaw',54, ...
    'Pitch',25, ...
    'Roll',22, ...
    'AngularVelocity',[24 42 27]);

actor(scenario,'Position',[17 22 12], ...
    'Velocity',[19 13 15], ...
    'Yaw',45, ...
    'Pitch',52, ...
    'Roll',2, ...
    'AngularVelocity',[42 24 29]);

Add the ego vehicle actor.

ego = actor(scenario,'Position',[1 2 3], ...
    'Velocity',[1.2 1.3 1.4], ...
    'Yaw',4, ...
    'Pitch',5, ...
    'Roll',2, ...
    'AngularVelocity',[4 2 7]);

Use actorPoses to return the poses of all the actors. Pose properties (position, velocity, and orientation) are in scenario coordinates.

allposes = actorPoses(scenario);

Use driving.scenario.targetsToEgo to convert only the target poses to the ego-centric coordinates of the ego actor. Examine the pose of the first actor.

targetposes1 = driving.scenario.targetsToEgo(allposes(1:2),ego);
disp(targetposes1(1))
            ActorID: 1
           Position: [7.8415 18.2876 27.1675]
           Velocity: [18.6826 112.0403 9.2960]
               Roll: 16.4327
              Pitch: 23.2186
                Yaw: 47.8114
    AngularVelocity: [-3.3744 47.3021 18.2569]

Alternatively, use targetPoses to obtain all non-ego actor poses in ego vehicle coordinates. Compare these poses to the previously calculated poses.

targetposes2 = targetPoses(ego);
disp(targetposes2(1))
            ActorID: 1
            ClassID: 0
           Position: [7.8415 18.2876 27.1675]
           Velocity: [18.6826 112.0403 9.2960]
               Roll: 16.4327
              Pitch: 23.2186
                Yaw: 47.8114
    AngularVelocity: [-3.3744 47.3021 18.2569]

Input Arguments

collapse all

Actor poses in world coordinates, specified as a structure or an array of structures. Poses are the positions, velocities, and orientations of actors.

Each actor pose structure has these fields.

FieldDescription
ActorID

Scenario-defined actor identifier, specified as a positive integer.

Position

Position of actor, specified as an [x y z] real-valued vector. Units are in meters.

Velocity

Velocity (v) of actor in the x-, y-, and z-directions, specified as a [vx vy vz] real-valued vector. Units are in meters per second.

Roll

Roll angle of actor, specified as a real scalar. Units are in degrees.

Pitch

Pitch angle of actor, specified as a real scalar. Units are in degrees.

Yaw

Yaw angle of actor, specified as a real scalar. Units are in degrees.

AngularVelocity

Angular velocity (ω) of actor in the x-, y-, and z-directions, specified as an [ωx ωy ωz] real-valued vector. Units are in degrees per second.

For full definitions of these structure fields, see the actor and vehicle functions.

Ego vehicle pose in world coordinates, specified as a structure. A pose is the position, velocity, and orientation of an actor.

The ego vehicle pose structure has these fields.

FieldDescription
ActorID

Scenario-defined actor identifier, specified as a positive integer.

Position

Position of actor, specified as an [x y z] real-valued vector. Units are in meters.

Velocity

Velocity (v) of actor in the x-, y-, and z-directions, specified as a [vx vy vz] real-valued vector. Units are in meters per second.

Roll

Roll angle of actor, specified as a real scalar. Units are in degrees.

Pitch

Pitch angle of actor, specified as a real scalar. Units are in degrees.

Yaw

Yaw angle of actor, specified as a real scalar. Units are in degrees.

AngularVelocity

Angular velocity (ω) of actor in the x-, y-, and z-directions, specified as an [ωx ωy ωz] real-valued vector. Units are in degrees per second.

For full definitions of these structure fields, see the actor and vehicle functions.

Output Arguments

collapse all

Target poses in ego vehicle coordinates, specified as a structure or an array of structures. Poses are the positions, velocities, and orientations of actors.

Each target pose structure has these fields.

FieldDescription
ActorID

Scenario-defined actor identifier, specified as a positive integer.

ClassIDClassification identifier, specified as a nonnegative integer. 0 is reserved for an object of an unknown or unassigned class.
Position

Position of actor, specified as an [x y z] real-valued vector. Units are in meters.

Velocity

Velocity (v) of actor in the x-, y-, and z-directions, specified as a [vx vy vz] real-valued vector. Units are in meters per second.

Roll

Roll angle of actor, specified as a real scalar. Units are in degrees.

Pitch

Pitch angle of actor, specified as a real scalar. Units are in degrees.

Yaw

Yaw angle of actor, specified as a real scalar. Units are in degrees.

AngularVelocity

Angular velocity (ω) of actor in the x-, y-, and z-directions, specified as an [ωx ωy ωz] real-valued vector. Units are in degrees per second.

For full definitions of these structure fields, see the actor and vehicle functions.

More About

collapse all

Ego Vehicle and Targets

In a driving scenario, you can specify one actor as the observer of all other actors, similar to how the driver of a car observes all other cars. The observer actor is called the ego actor, or more specifically, the ego vehicle. From the perspective of the ego vehicle, all other actors (vehicles, pedestrians, and so on) are the observed actors, or targets. Ego vehicle coordinates are centered and oriented with reference to the ego vehicle. The coordinates of the driving scenario are world coordinates.

Introduced in R2017a