getAttribute
Get runtime attribute of actor
Description
returns the specified runtime attribute of the runtimeAttr
= getAttribute(actorSim
,'RuntimeAttrName
')Simulink.ActorSimulation
object actorSim
. When you use this function inside the stepImpl
method of MATLAB®
System object™, the function returns the states from the previous time step except the actor
ID
.
Examples
Get Runtime Attributes of Actor
Create a Simulink.ScenarioSimulation
object for a
scenario with multiple actors.
rrApp = roadrunner('C:\Project\TestHighwayRoute'); openScenario(rrApp,'myScenario1'); sim = createSimulation(rrApp);
Start the simulation.
set(sim,'SimulationCommand','Start');
Pause the simulation.
set(sim,'SimulationCommand','Pause');
Get all actors from the simulation.
actorsim = get(sim, 'ActorSimulation');
Get the first two actors from the list.
one = actorsim(1); two = actorsim(2);
Get the ID of the first actor.
id = getAttribute(one,'ID')
id = uint64 1
Get the pose of the first actor.
pose = getAttribute(one,'Pose')
pose = 0.1096 0.9940 -0.0000 -28.1452 -0.9940 0.1096 0.0000 -3.2291 0.0000 0.0000 1.0000 -0.0000 0 0 0 1.0000
Get the velocity of the second actor.
velocity = getAttribute(two,'Velocity')
velocity = 6.9507 2.8702 0.0000
Get the angular velocity of the first actor.
angvelocity = getAttribute(two,'AngularVelocity')
angvelocity = 0 0.23 0
Get the wheel poses of the second actor.
wheelposes = getAttribute(two,'WheelPoses')
wheelposes = getAttribute(two,'WheelPoses') wheelposes(:,:,1) = 0.9972 -0.0671 -0.0330 -0.5672 -0.0747 -0.8946 -0.4405 1.3838 0 0.4417 -0.8971 0.3441 0 0 0 1.0000 wheelposes(:,:,2) = 0.9974 -0.0650 -0.0320 0.5672 -0.0725 -0.8948 -0.4406 1.3838 0 0.4417 -0.8971 0.3441 0 0 0 1.0000 wheelposes(:,:,3) = 1.0000 0 0 -0.5672 0 -0.8971 -0.4417 -1.3295 0 0.4417 -0.8971 0.3441 0 0 0 1.0000 wheelposes(:,:,4) = 1.0000 0 0 0.5672 0 -0.8971 -0.4417 -1.3295 0 0.4417 -0.8971 0.3441 0 0 0 1.0000
Get the map location of the first actor.
ml = getAttribute(one,'MapLocation')
ml = struct with fields: IsOnLane: 1 LocationOnLane: [1×1 struct]
ml.IsOnLane
ans = logical 1
ml.LocationOnLane
ans = struct with fields: LaneID: '{7c2e895c-6b90-4892-aa6e-9ed116db53b5}' Position: 0.5359 Angle: 0.0014
Input Arguments
actorSim
— Actor
Simulink.ActorSimulation
object
Actor from which to return runtime attribute, specified as a
Simulink.ActorSimulation
object.
Example: actorSim
RuntimeAttrName
— Name of runtime attribute
ID
| Pose
| Velocity
| AngularVelocity
| WheelPoses
| MapLocation
| Children
| Parent
Name of runtime attribute to be retrieved, specified as one of these strings.
ID
Pose
Velocity
AngularVelocity
WheelPoses
MapLocation
Children
Parent
Output Arguments
runtimeAttr
— Runtime attribute of actor
uint64
| double
| struct
Runtime attribute of actor, returned as data type corresponding to input argument
RuntimeAttrName
.
Runtime Attribute | Description |
---|---|
ID | Actor identifier, returned as a uint64 . |
Pose | Position and orientation of actor in the RoadRunner Scenario coordinate system, returned as a 4-by-4 array. |
Velocity | Velocity of actor in the x-, y-and z- directions, returned as a 1-by-3 vector. Units are in meters per second. |
AngularVelocity | Angular velocity of actor in the x-, y-and z- directions, returned as a 1-by-3 vector. Units are in radians per second. |
WheelPoses | Runtime pose of each wheel of vehicle-type actor, returned as a multidimensional 4-by-4-by-N array. N is the number of wheels of the vehicle-type actor.
|
MapLocation | Location of vehicle-type actor with respect to its closest lane, returned
as a struct . |
Children | Immediate children of specified actor, if any, returned as an array
of If the specified actor does not have any child actors, then an empty array is returned. |
Parent | Immediate parent of specified actor, returned as an
If the
specified actor itself is a parent, then the
|
This table describes the fields of the MapLocation
structure.
Field Name | Description |
---|---|
IsOnLane | Boolean value indicating if the vehicle is located on a lane. A vehicle is considered to be on a certain lane if its model origin lies in between the left and right boundaries of this lane. |
LocationOnLane | Current lane of vehicle, returned as a struct . If a
vehicle straddles several lanes, the most aligned lane is returned. |
The table describes the fields of the LocationOnLane
structure of
the MapLocation
structure.
Field Name | Description |
---|---|
LaneID | UUID identifier of the most aligned lane, returned as a string. |
Position | Position of the vehicle on the lane-center polyline (in s-value). The s-value is a double value within [0, 1] that indicates a position on a 3-D polyline with 0 at the start and 1 at the end of the polyline. |
Angle | Angle between the vehicle travel direction and tangent at the lane position. Units are in radians. |
Version History
Introduced in R2022a
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
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)