getAttribute
Description
returns the specified run-time attribute of the runtimeAttr
= getAttribute(actorSim
,runtimeAttrName
)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 Run-time Attributes of Actor
Create a ScenarioSimulation
object by using the roadrunner
and createSimulation
functions.
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 the ActorSimulation
objects from the simulation.
actorSims = get(sim,"ActorSimulation");
Get the first and second ActorSimulation
objects.
actorOne = actorSims{1}; actorTwo = actorSims{2};
Get the ID of actorOne
.
id = getAttribute(actorOne,"ID")
id = uint64 1
Get the actor type of actorOne
. The actor type is returned as a
uint8
row vector.
actortype_uint8 = getAttribute(actorOne,"ActorType")
actortype_uint8 = 1×5 uint8 row vector 87 111 114 108 100
Convert the uint8
row vector into a character array to obtain a
readable word.
actortype_char = char(actortype_uint8)
ans = 'World'
Get the pose of actorOne
. For more information about actor poses,
see What Is a RoadRunner Pose Matrix?
pose = getAttribute(actorOne,"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 actorTwo
.
velocity = getAttribute(actorTwo,"Velocity")
velocity = 6.9507 2.8702 0.0000
Get the angular velocity of actorOne
.
angvelocity = getAttribute(actorTwo,"AngularVelocity")
angvelocity = 0 0.23 0
Get the wheel poses of actorTwo
.
wheelposes = getAttribute(actorTwo,"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 actorOne
.
ml = getAttribute(actorOne,"LaneLocation")
ml = struct with fields: IsOnLane: 1 LocationOnLane: [1×1 struct]
Check whether the actor is on its lane.
ml.IsOnLane
ans = logical 1
Get information about the lane the actor is on.
ml.LocationOnLane
ans = struct with fields: LaneID: '{7c2e895c-6b90-4892-aa6e-9ed116db53b5}' Position: 0.5359 Angle: 0.0014
Input Arguments
actorSim
— Actor
ActorSimulation
object
Actor to return run-time attributes from, specified as an ActorSimulation
object.
runtimeAttrName
— Name of run-time attribute
"ID"
| "Pose"
| "Velocity"
| "AngularVelocity"
| "WheelPoses"
| "LaneLocation"
| "Children"
| "Parent"
| "PhaseStatus"
| "ActorType"
| "TrafficSignalRuntime"
| "TrafficSignalControllerRuntime"
Name of run-time attribute to be retrieved, specified as one of these values:
"ID"
"Pose"
"Velocity"
"AngularVelocity"
"WheelPoses"
"LaneLocation"
"Children"
"Parent"
"PhaseStatus"
"ActorType"
"TrafficSignalRuntime"
"TrafficSignalControllerRuntime"
Data Types: string
| char
Output Arguments
runtimeAttr
— Run-time attribute of actor
scalar | array | structure
Run-time attribute of actor, returned as a scalar, array, structure, or object,
depending on the input argument runtimeAttrName
.
runtimeAttrName | Description |
---|---|
"ID" | Actor identifier, returned as a scalar of data type
uint64 . |
"Pose" | Position and orientation of actor in the RoadRunner Scenario coordinate system, returned as a 4-by-4 array. See What Is a RoadRunner Pose Matrix? for more information. |
"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" | Run-time pose of each wheel of vehicle-type actor, returned as a 4-by-4-by-N array. N is the number of wheels of the vehicle-type actor.
|
"LaneLocation" | Location of actor with respect to its mapped lane, returned as a
structure of type LaneLocation . |
"Children" | Immediate children of specified actor, if any, returned as a cell
array of If the specified actor does not have any child actors, then an empty cell array is returned. |
"Parent" | Immediate parent of specified actor, returned as an If the specified actor
itself is a parent, then the |
"PhaseStatus" | Information about all the phases of a particular actor, returned as
a structure of type |
"ActorType" | Type of actor in a scenario, returned as a Note To obtain a readable word, you must convert the
These are the possible outputs:
|
"TrafficSignalRuntime" | Run-time information about a traffic signal, returned as a
structure of type For more information about cosimulation of RoadRunner Scenario with traffic signal actors in MATLAB, see Simulate RoadRunner Scenarios with Traffic Signals in MATLAB. |
"TrafficSignalControllerRuntime" | Run-time information about a traffic signal controller, returned as
a structure of type For more information about cosimulation of RoadRunner Scenario with traffic signal controllers in MATLAB, see Simulate RoadRunner Scenarios with Traffic Signals in MATLAB. |
More About
LaneLocation
Structure
This table describes the fields of the
LaneLocation
structure:
Field Name | Description |
---|---|
IsOnLane | Boolean value indicating if the actor is located on a lane. An actor 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 actor, returned as a structure of type
LocationOnLane . If an actor straddles several lanes, the most
aligned lane is returned. |
This table describes the fields of the
LocationOnLane
structure of the LaneLocation
structure:
Field Name | Description |
---|---|
LaneID | Universal unique identifiers (UUID) of the most aligned lane, returned as a string. |
Position | Position of the actor 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 actor travel direction and tangent at the lane position. Units are in radians. |
PhaseStatus
Structure
This table describes the fields of the
PhaseStatus
structure:
Field Name | Description |
---|---|
PhaseID | Identifier of the phase, returned as a string. |
PhaseName | Name of phase, returned as a string. |
ActorID | Actor identifier, returned as a uint64 scalar. |
StartConditionStatus | Status of the start condition, returned as a structure of type
StartConditionStatus . |
EndConditionStatus | Status of the end condition, returned as a structure, returned as a structure
of type EndConditionStatus |
ActionType | Action type, returned as an enumeration variable. The value of the variable can be:
|
PhaseState | Run-time state of a phase, returned as an enumeration variable. The value of the variable can be:
|
ActionEventStatus | Action event dispatch status, returned as an enumeration variable. The value of the variable can be:
|
This table describes the fields of the StartConditionStatus
structure:
Field Name | Description |
---|---|
ConditionStatusID | Start condition status identifier, returned as a string. |
ConditionState | Run-time state of a start condition, returned as an enumeration
variable of the The value of
|
ConditionType | Type of condition, returned as an enumeration variable of the
The value
of
|
ConditionData | Data associated with a specific condition type, returned as a structure. |
This table describes the fields of the
EndConditionStatus
structure:
Field Name | Description |
---|---|
ConditionStatusID | End condition status identifier, returned as a string. |
ConditionState | Run-time state of an end condition, returned as an enumeration variable
of the The
value of
|
ConditionType | Type of condition, returned as an enumeration variable of the
The value
of
|
ConditionData | Data associated with a specific condition type, returned as a structure. |
TrafficSignalRuntime
Structure
This table describes the fields of the
TrafficSignalRuntime
structure:
Field Name | Description |
---|---|
SignalHead | Signal head specifications, returned as a structure of type
|
SignalConfiguration | Information about the current configuration of the specified traffic
signal, returned as a structure of type
|
This table describes the fields of the SignalHead
structure:
Field Name | Description |
---|---|
SignalID | UUID of traffic signal, returned first as a To convert the row vector into its alphanumeric form, use the char function, which returns the UUID as a character array. |
ControllerID | UUID of traffic signal controller, returned first as a
To convert the row vector into its alphanumeric form, use the char function, which returns the UUID as a character array. |
This table describes the fields of the SignalConfiguration
structure:
Field Name | Description |
---|---|
ConfigurationIndex | Current configuration index of the specified traffic signal, returned
as a Configuration index indicates the overall configuration of a traffic signal. For example, if the red bulb of a traffic signal is in the "On" state, and the green and yellow bulbs are "Off", then the traffic signal is red. A certain configuration index is assigned to every such possible configuration. |
NumBulbConfiguration | Number of bulb configurations for the specified signal, returned as a
|
BulbConfiguration | Bulb name and state for all bulbs of the specified traffic signal,
returned as a structure array of type
|
NumTurnConfiguration | Number of turn configurations for the specified traffic signal,
returned as a |
TurnConfiguration | Turn configuration information for the specified traffic signal,
returned as a structure array of type
|
This table describes the fields of the BulbConfiguration
structure array:
Field Name | Description |
---|---|
BulbName | Name of the bulb, returned first as a This field corresponds to the Node Name of the bulb as seen in the RoadRunner application. To obtain a readable word, you must
convert the |
BulbState | State of signal bulb, returned as an enumeration variable. Possible values of the variable are:
|
This table describes the fields of the
TurnConfiguration
structure array:
Field Name | Description |
---|---|
TimeLeft | Time remaining for the completion of the current turn type, returned as
a |
TurnType | Possible turn types:
Every turn type has a corresponding configuration type (maneuver signalization); together, this information (called turn state) determines the allowed turns at a traffic signal. |
ConfigurationType | Maneuver signalization at specified traffic signal, returned as an enumeration variable. The value of the variable can be:
A configuration type (maneuver signalization) is assigned to every turn type; together, this information (turn state) determines the allowed turns at a traffic signal. |
TrafficSignalControllerRuntime
Structure
This table describes the fields of
the TrafficSignalControllerRuntime
structure:
Field Name | Description |
---|---|
ControllerID | UUID of traffic signal controller, returned first as a
To convert the row vector into its alphanumeric form, use the char function, which returns the UUID as a character array. |
SignalPhase | Information about current signal phase, returned as a structure of type
|
SignalInterval | Information about the current signal phase interval, returned as a
structure of type |
PhaseTime | Information about phase timings, returned as a structure of type
|
CycleTime | Information about cycle timings, returned as a structure of type
A cycle comprises of all signal phases, taken together. |
ControllerStatus | Status of traffic signal controller, returned as an enumeration variable. Possible values of the variable are:
|
This table describes the fields of the SignalPhase
structure:
Field Name | Description |
---|---|
PhaseName | Name of the current phase, returned first as a To obtain a readable word, you must convert the
|
PhaseNumber | Number assigned to current signal phase based on its order, returned as
a |
This table describes the fields of the SignalInterval
structure:
Field Name | Description |
---|---|
IntervalName | Name of the current interval within a signal phase, returned first as a
To obtain a readable word,
you must convert the |
IntervalType | Interval type, informing about allowed turn types at a junction, returned as an enumeration variable. The value of the variable can be:
This field corresponds to the Interval Type of a phase interval, as seen in the RoadRunner application. |
This table describes the fields of the
PhaseTime
structure:
Field Name | Description |
---|---|
Duration | Total time spent in a signal phase, returned as a
|
TimeLeft | Time left in a signal phase, returned as a
|
This table describes the fields of the CycleTime
structure:
Field Name | Description |
---|---|
Duration | Total time spent in a cycle, returned as a |
TimeLeft | Time left in a cycle, returned as a
|
Version History
Introduced in R2022aR2024b: Retrieve run-time attributes of traffic signal and traffic signal controller
Get run-time attributes of traffic signals and the parent traffic signal controller at a junction during cosimulation with RoadRunner Scenario.
R2024b: Retrieve actor type
Retrieve the type of an actor, such as vehicle or traffic signal.
R2024a: Retrieve information about action phases for an actor
Get information, such as phase name, phase status and condition state about all action phases associated with a particular actor.
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 (한국어)