Main Content


Convert actor to MATLAB structure

Since R2022a



    actorStruct = convertToStruct(actorSim) converts the ActorSimulation actor specified by actorSim to its equivalent MATLAB® structure.


    collapse all

    Create sim, a ScenarioSimulation object.

    rrApp = roadrunner("C:\Project\TestHighwayRoute"); 
    sim = createSimulation(rrApp);

    Start the simulation.


    Pause the simulation.


    Retrieve one actor from the simulation.

    actorsim = get(sim,"ActorSimulation"); 
    actorOne = actorsim(1);

    Convert the actor to a MATLAB structure.

    actorStruct = convertToStruct(actorOne)
    actorStruct = 
      struct with fields:
                ActorID: 1
                   Pose: [4×4 double]
               Velocity: [0 0 0]
        AngularVelocity: [0 0 0]

    Input Arguments

    collapse all

    Actor, specified as an ActorSimulation object.

    Output Arguments

    collapse all

    MATLAB structure equivalent to actor, returned as a struct. This MATLAB structure contains the runtime attributes of the specified actor.

    The returned structure contains these fields.

    ActorIDActor identifier, returned as a positive integer.
    PosePosition and orientation of actor in the RoadRunner Scenario coordinate system, returned as a 4-by-4 array.
    VelocityVelocity of actor in the x-, y-and z- directions, returned as a 1-by-3 vector. Units are in meters per second.
    AngularVelocityAngular velocity of actor in the x-, y-and z- directions, returned as a 1-by-3 real-valued vector. Units are in radians per second.

    Version History

    Introduced in R2022a