Main Content

updateEgoGeometry

Update geometric properties of ego bodies

Description

example

updateEgoGeometry(capsuleListObj,egoIDs,geomStruct) updates geometry parameters for the specified ego bodies in the capsule list. If a specified ego ID does not already exist, the function adds a new ego body with that ID to the list.

status = updateEgoGeometry(capsuleListObj,egoIDs,geomStruct) additionally returns an indicator of whether an ego body is added, updated, or a duplicate.

Examples

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.

updateEgoPose(capsuleList,egoIDs,egoPoseStruct);
updateEgoGeometry(capsuleList,egoIDs,egoGeomStruct);

Visualize the ego bodies.

show(capsuleList,'TimeStep',1:numSteps);
axis equal

Figure contains an axes object. The axes object contains 2 objects of type patch.

Remove Ego Body

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

removeEgo(capsuleList,1);

Visualize the ego bodies again.

show(capsuleList,'TimeStep',1:numSteps);
axis equal

Figure contains an axes object. The axes object contains an object of type patch.

Input Arguments

collapse all

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

IDs of ego bodies to update, specified as a vector of positive integers.

Geometry parameters for ego bodies, specified as a structure or structure array, where each structure contains the fields of the structure in the Geometry field of the ego body to be updated. The fields of this structure depend on whether you are using a dynamicCapsuleList or dynamicCapsuleList3D object.

Data Types: struct

Output Arguments

collapse all

Result of updating ego bodies, specified as N-element column vector of ones, zeros, and negative ones. N is the number of ego bodies specified in the egoIDs argument. Each value indicates whether the body is removed (1), not found (0), or a duplicate (-1). If you specify the same ego ID multiple times in the egoIDs input argument, then all entries besides the last are marked as a duplicate.

Extended Capabilities

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

Introduced in R2020b