Main Content

convertToStruct

Convert actor to MATLAB structure

    Description

    example

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

    Examples

    collapse all

    Create sim, a Simulink.ScenarioSimulation object.

    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');

    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 a Simulink.ActorSimulation object.

    Example: actorStruct = convertToStruct(actorSim)

    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.

    FieldDescription
    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