Main Content

getAttribute

Get run-time attribute of actor

Since R2022a

    Description

    runtimeAttr = getAttribute(actorSim,runtimeAttrName) returns the specified run-time 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.

    example

    Examples

    collapse all

    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

    collapse all

    Actor to return run-time attributes from, specified as an ActorSimulation object.

    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

    collapse all

    Run-time attribute of actor, returned as a scalar, array, structure, or object, depending on the input argument runtimeAttrName.

    runtimeAttrNameDescription
    "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.

    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 its mapped lane, returned as a structure of type LaneLocation.
    "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 the phases of a particular actor, returned as a structure of type PhaseStatus.

    "ActorType"

    Type of actor in a scenario, returned as a uint8 row vector.

    Note

    To obtain a readable word, you must convert the uint8 row vector into a character array by using the char function.

    These are the possible outputs:

    • "World" — World actor

    • "Vehicle" — Vehicle actor

    • "Character" — Character actor, such as a pedestrian

    • "TrafficSignal" — Traffic signal actor

    • "TrafficSignalController" — Traffic signal controller

    • "Unspecified" — Unknown actor type

    "TrafficSignalRuntime"

    Run-time information about a traffic signal, returned as a structure of type TrafficSignalRuntime.

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

    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

    collapse all

    Version History

    Introduced in R2022a

    expand all