# getAttribute

Get runtime attribute of actor

Since R2022a

## Syntax

``runtimeAttr = getAttribute(actorSim,runtimeAttrName)``

## Description

example

````runtimeAttr = getAttribute(actorSim,runtimeAttrName)` returns the specified runtime attribute of the `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

collapse all

Create a `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 ```

`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(:,:,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,"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

collapse all

Actor from which to return runtime attribute, specified as an `ActorSimulation` object.

Name of runtime attribute to be retrieved, specified as one of these values.

• `"ID"`

• `"Pose"`

• `"Velocity"`

• `"AngularVelocity"`

• `"WheelPoses"`

• `"LaneLocation"`

• `"Children"`

• `"Parent"`

• `"PhaseStatus"`

Data Types: `string` | `char`

## Output Arguments

collapse all

Runtime attribute of actor, returned as a scalar, array, structure, or object, depending on the value of the input argument `runtimeAttrName`.

Value of `runtimeAttrName`Value of `runtimeAttr`
`"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"`

Runtime 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.

`WheelPoses` is returned for wheels starting on the leftmost side of the front axle, and moving to the right. After the first axle is complete, the leftmost wheel on the second axle is taken into consideration before moving to the right, and so on.

`"LaneLocation"`Location of actor with respect to the lane it is mapped to.
`"Children"`

Immediate children of specified actor, if any, returned as a cell array of `ActorSimulation` objects.

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 `ActorSimulation` object.

If the specified actor itself is a parent, then the `ActorSimulation` object corresponding to the world actor is returned.

`"PhaseStatus"`

Information about all phases of a particular actor, returned as a structure.

This table describes the fields of the `LaneLocation` structure.

Field NameDescription
`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 `struct`. If an actor straddles several lanes, the most aligned lane is returned.

The table describes the fields of the `LocationOnLane` structure of the `LaneLocation` structure.

Field NameDescription
`LaneID`UUID identifier 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.

This table describes the fields of the `PhaseStatus` structure.

Field NameDescription
`PhaseID`Identifier of the phase, returned as a string.
`PhaseName`Name of phase, returned as a string.
`ActorID`Actor identifier, returned as a scalar of data type `uint64`.
`StartConditionStatus`Status of the start condition, returned as a structure.
`EndConditionStatus`Status of the end condition, returned as a structure.
`ActionType`

Action type, returned as an enumeration variable of the `EnumActionType` enumeration class.

The value of `EnumActionType` variable can be:

• `LaneChange` — Lane change action

• `Path` — Path action

• `Speed` — Speed action

• `LateralOffset` — Lateral offset action

• `Position` — Position action

`PhaseState`

Run-time state of a phase, returned as an enumeration variable of the `EnumPhaseState` enumeration class.

The value of the `EnumPhaseState` variable can be:

• `Unspecified` — The phase has not yet been intialized.

• `Idle` — The phase is not running currently, and its start conditions are not being evaluated yet.

• `Start` — The start conditions of a phase are being evaluated, but are not yet satisfied.

• `Run` — The start conditions are satisfied, and the phase is running.

• `End` — Phase execution has ended, or was skipped.

`ActionEventStatus`

Action event dispatch status, returned as an enumeration variable of the `ActionEventStatus` enumeration class.

The value of the `ActionEventStatus` variable can be:

• `Unspecified` — Action event is not yet initialized.

• `Dispatched` — Action event has been dispatched.

• `Interrupted` — Action event has been interrupted or cancelled after dispatch.

• `Skipped` — Action event has been skipped or preempted by another conflicting action.

• `Done` — Action event is completed.

This table describes the fields of the `StartConditionStatus` and `EndConditionStatus` structures, which are fields of the `PhaseStatus` structure:

Field NameDescription
`ConditionStatusID`Start or end condition status identifier, returned as a string.
`ConditionState`

Run-time state of a start or end condition, returned as an enumeration variable of the `EnumConditionState` enumeration class.

The value of `EnumConditionState` variable can be:

• `Unspecified` — The condition is not initialized.

• ` Not_Yet_Evaluated` — The condition is initialized, but has not been evaluated.

• `Unsatisfied` — The condition is evaluated, but not satisfied.

• `Satisfied` — The condition is evaluated, and satisfied.

`ConditionType`

Type of condition, returned as an enumeration variable of the `EnumConditionType` enumeration class.

The value of `EnumConditionType` variable can be:

• `duration` — Run-time status of a duration condition

• `simulation_time` — Run-time status of a simulation time condition

• `distance` — Run-time status of a distance condition

• `actor_speed` — Run-time status of an actor speed condition

• `collisions` — Run-time status of a collision condition

• `actor_lane` — Run-time status of an actor lane condition

• `and_condition` — Run-time status of an `and` condition

• `or_condition` — Run-time status of an `or` condition

• `lateral_offset` — Runtime status of a lateral offset condition.

• `phase_state` — Runtime status of a phase state condition.

• `event_condition` — Runtime status of an event condition status.

`ConditionData`

Data associated with a specific condition type, returned as a structure.

## Version History

Introduced in R2022a

expand all