Main Content


Poses of ego bodies

Since R2020b


[egoIDs,poseStruct] = egoPose(capsuleListObj) returns the ego ID and the states for each ego body in the specified capsule list.


[egoIDs,poseStruct] = egoPose(capsuleListObj,selectEgoIDs) specifies which ego bodies to return the ID and states for.

[egoIDs,poseStruct,status] = egoPose(capsuleListObj,selectEgoIDs) returns an indicator of whether each ID in selectEgoIDs exists.


collapse all

Add ego bodies to an environment using the dynamicCapsuleList object. Modify the properties of the ego bodies. Remove an ego body from the environment. Visualize the states of all objects in the environment at different timestamps.

Create the dynamicCapsuleList object. Extract the maximum number of steps to use as the number of time stamps for the object paths.

capsuleList = dynamicCapsuleList;
numSteps = capsuleList.MaxNumSteps;

Add Ego Bodies

Specify the states for the two ego bodies as a linear path from x = 0 m to x = 100 m. The two ego bodies are separated by 5 m in opposite directions on the y-axis.

egoState = linspace(0,1,numSteps)'.*[100 0 0];
egoState1 = egoState+[0 5 0];
egoState2 = egoState+[0 -5 0];

Generate default poses and geometric structures for the two ego bodies using ego IDs.

[egoIDs,egoPoseStruct] = egoPose(capsuleList,[1 2]);
[egoIDs,egoGeomStruct] = egoGeometry(capsuleList,egoIDs);

Update Ego Bodies

Assign the states to the ego bodies.

egoPoseStruct(1).States = egoState1;
egoPoseStruct(2).States = egoState2;

Increase the radius of the first ego body to 2 m.

egoGeomStruct(1).Geometry.Radius = 2;

update the ego bodies using the updateEgoPose and updateEgoGeometry object functions.


Visualize the ego bodies.

axis equal

Remove Ego Body

Remove the first ego body from the capsule list by specifying its ID.


Visualize the ego bodies again.

axis equal

Input Arguments

collapse all

Dynamic capsule list, specified as a dynamicCapsuleList or dynamicCapsuleList3D object.

Ego body IDs, specified as a vector of positive integers. The function returns the ego IDs and states for only the ego bodies specified in this vector.

Output Arguments

collapse all

IDs of ego bodies, returned as a vector of positive integers.

States for ego bodies, returned as a structure or structure array. Each structure contains a matrix of states for each ego body. The state matrix size depends on whether you are using a dynamicCapsuleList or dynamicCapsuleList3D object.

Data Types: struct

Indication of ego body existence, returned as a N-element column vector of ones, zeros, and negative ones. Each value indicates whether the associated body exists (1), updated (0), or a duplicate (-1). If you specify the same ego body ID more than once in the selectEgoIDs argument, then the function marks all instances of that ID after the first as duplicates and ignores them.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2020b