driving.scenario.targetsToEgo
Convert target poses from scenario to ego coordinates
Syntax
Description
converts the poses of target actors from the world coordinates of a driving scenario
to the coordinate system relative to the pose of an ego actor. A
pose is the position, velocity, and orientation of an
actor. For more details on the coordinate systems of actors, see Ego Vehicle and Targets.targetPosesEgoCoords
= driving.scenario.targetsToEgo(targetPosesScenarioCoords
,egoPose
)
converts target poses by using the pose of the specified ego actor.targetPosesEgoCoords
= driving.scenario.targetsToEgo(targetPosesScenarioCoords
,egoActor
)
Examples
Convert Target Poses Between Ego Vehicle and Scenario Coordinates
In a simple driving scenario, obtain the poses of target vehicles in the coordinate system of the ego vehicle. Then convert these poses back to the world coordinates of the driving scenario.
Create a driving scenario.
scenario = drivingScenario;
Create target actors.
actor(scenario,'ClassID',1, ... 'Position',[10 20 30], ... 'Velocity',[12 113 14], ... 'Yaw',54, ... 'Pitch',25, ... 'Roll',22, ... 'AngularVelocity',[24 42 27]); actor(scenario,'ClassID',1, ... 'Position',[17 22 12], ... 'Velocity',[19 13 15], ... 'Yaw',45, ... 'Pitch',52, ... 'Roll',2, ... 'AngularVelocity',[42 24 29]);
Add an ego vehicle actor.
egoActor = actor(scenario,'ClassID',1, ... 'Position',[1 2 3], ... 'Velocity',[1.2 1.3 1.4], ... 'Yaw',4, ... 'Pitch',5, ... 'Roll',2, ... 'AngularVelocity',[4 2 7]);
Use the actorPoses
function to return the poses of all actors in the scenario. Pose properties (position, velocity, and orientation) are in the world coordinates of the driving scenario. Save the target actors to a separate variable and inspect the pose of the first target actor.
allPoses = actorPoses(scenario); targetPosesScenarioCoords = allPoses(1:2); targetPosesScenarioCoords(1)
ans = struct with fields:
ActorID: 1
Position: [10 20 30]
Velocity: [12 113 14]
Roll: 22
Pitch: 25
Yaw: 54
AngularVelocity: [24 42 27]
Use the driving.scenario.targetsToEgo
function to convert the target poses to the ego-centric coordinates of the ego actor. Inspect the pose of the first actor.
targetPosesEgoCoords = driving.scenario.targetsToEgo(targetPosesScenarioCoords,egoActor); targetPosesEgoCoords(1)
ans = struct with fields:
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 the targetPoses
function to obtain all target actor poses in ego vehicle coordinates. Display the first target pose, which matches the previously calculated pose.
targetPosesEgoCoords = targetPoses(egoActor); targetPosesEgoCoords(1)
ans = struct with fields:
ActorID: 1
ClassID: 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]
Use the driving.scenario.targetsToScenario
to convert the target poses back to the world coordinates of the scenario. Display the first target pose, which matches the original target pose.
targetPosesScenarioCoords = driving.scenario.targetsToScenario(targetPosesEgoCoords,egoActor); targetPosesScenarioCoords(1)
ans = struct with fields:
ActorID: 1
ClassID: 1
Position: [10.0000 20.0000 30.0000]
Velocity: [12.0000 113.0000 14.0000]
Roll: 22
Pitch: 25.0000
Yaw: 54
AngularVelocity: [24.0000 42.0000 27.0000]
Input Arguments
targetPosesScenarioCoords
— Target poses in world coordinates of scenario
structure | array of structures
Target poses in the world coordinates of a driving scenario, specified as a structure or an array of structures.
Each target pose structure must contain at least these fields.
Field | Description |
---|---|
ActorID | Scenario-defined actor identifier, specified as a positive integer. |
In R2024b:
| Front-axle position of the vehicle, specified as a three-element row vector in the form [x y z]. Units are in meters. Note If the driving scenario does not contain a
front-axle trajectory for at least one vehicle,
then the
|
Position | Position of actor, specified as a real-valued vector of the form [x y z]. Units are in meters. |
Velocity | Velocity (v) of actor in the x- y-, and z-directions, specified as a real-valued vector of the form [vx vy vz]. Units are in meters per second. |
Roll | Roll angle of actor, specified as a real-valued scalar. Units are in degrees. |
Pitch | Pitch angle of actor, specified as a real-valued scalar. Units are in degrees. |
Yaw | Yaw angle of actor, specified as a real-valued scalar. Units are in degrees. |
AngularVelocity | Angular velocity (ω) of actor in the x-, y-, and z-directions, specified as a real-valued vector of the form [ωx ωy ωz]. Units are in degrees per second. |
For full definitions of these structure fields, see the actor
and vehicle
functions.
egoPose
— Ego actor pose
structure
Ego actor pose in the world coordinates of a driving scenario, specified as a structure.
The ego actor pose structure must contain at least these fields.
Field | Description |
---|---|
ActorID | Scenario-defined actor identifier, specified as a positive integer. |
In R2024b:
| Front-axle position of the vehicle, specified as a three-element row vector in the form [x y z]. Units are in meters. Note If the driving scenario does not contain a
front-axle trajectory for at least one vehicle,
then the
|
Position | Position of actor, specified as a real-valued vector of the form [x y z]. Units are in meters. |
Velocity | Velocity (v) of actor in the x- y-, and z-directions, specified as a real-valued vector of the form [vx vy vz]. Units are in meters per second. |
Roll | Roll angle of actor, specified as a real-valued scalar. Units are in degrees. |
Pitch | Pitch angle of actor, specified as a real-valued scalar. Units are in degrees. |
Yaw | Yaw angle of actor, specified as a real-valued scalar. Units are in degrees. |
AngularVelocity | Angular velocity (ω) of actor in the x-, y-, and z-directions, specified as a real-valued vector of the form [ωx ωy ωz]. Units are in degrees per second. |
For full definitions of these structure fields, see the actor
and vehicle
functions.
egoActor
— Ego actor
Actor
object | Vehicle
object
Ego actor in the world coordinates of a driving scenario, specified as an
Actor
or Vehicle
object. The function converts the
coordinates of target actors relative to the pose of egoActor
. The
pose information is stored in the Position
,
Velocity
, Roll
, Pitch
,
Yaw
, and AngularVelocity
properties of the ego
actor.
For the full definitions of pose properties, see the actor
and vehicle
functions.
Output Arguments
targetPosesEgoCoords
— Target poses in ego actor coordinates
structure | array of structures
Target poses in ego vehicle coordinates, returned as a structure or an array of structures.
At a minimum, each returned target pose structure has these fields.
Field | Description |
---|---|
ActorID | Scenario-defined actor identifier, specified as a positive integer. |
In R2024b:
| Front-axle position of the vehicle, specified as a three-element row vector in the form [x y z]. Units are in meters. Note If the driving scenario does not contain a
front-axle trajectory for at least one vehicle,
then the
|
Position | Position of actor, specified as a real-valued vector of the form [x y z]. Units are in meters. |
Velocity | Velocity (v) of actor in the x- y-, and z-directions, specified as a real-valued vector of the form [vx vy vz]. Units are in meters per second. |
Roll | Roll angle of actor, specified as a real-valued scalar. Units are in degrees. |
Pitch | Pitch angle of actor, specified as a real-valued scalar. Units are in degrees. |
Yaw | Yaw angle of actor, specified as a real-valued scalar. Units are in degrees. |
AngularVelocity | Angular velocity (ω) of actor in the x-, y-, and z-directions, specified as a real-valued vector of the form [ωx ωy ωz]. Units are in degrees per second. |
The returned targetPosesEgoCoords
structures include
the same fields as those in the input
targetPosesScenarioCoords
structures. For example,
if the input structures include a ClassID
field, then the
returned structures also include ClassID
.
For full definitions of these structure fields, see the actor
and vehicle
functions.
More About
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 (such as vehicles and pedestrians) are the observed actors, called targets. Ego vehicle coordinates are centered and oriented with reference to the ego vehicle. The coordinates of the driving scenario are world coordinates.
Version History
Introduced in R2017a
See Also
Objects
Functions
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 (한국어)