Main Content

ScenarioLog

View RoadRunner Scenario simulation outcomes in MATLAB at any time step

Since R2022a

    Description

    A ScenarioLog object stores scenario simulation outcomes at all time steps of a simulation. Use a ScenarioLog object to:

    • View actor information, such as runtime attributes and actions, at any time step.

    • View simulation information at any time step.

    • View diagnostics reported during simulation.

    • View values of user-defined action or event parameters at any time step.

    Creation

    Retrieve the ScenarioLog object that represents a simulation log by using the get function of a ScenarioSimulation object. You can get the log of a simulation only if it has logging enabled using the set function of the ScenarioSimulation object. You can get the log of a simulation only after it stops playing.

    Object Functions

    getGet logged scenario simulation data

    Examples

    collapse all

    Create Sim, a ScenarioSimulation object.

    rrApp = roadrunner("C:\RoadRunnerProject");
    openScenario(rrApp,"TrajectoryCutIn");
    Sim = createSimulation(rrApp);

    Enable logging for the simulation.

    set(Sim,"Logging","On");

    Start the simulation.

    set(Sim,"SimulationCommand","Start");

    Get the simulation log after the simulation stops playing.

    simLog = get(Sim,"SimulationLog");

    Get IDs of all actors from the simulation log.

    actorIDs = get(simLog,"ActorIDs")
    actorIDs =
    
         0     1     2

    Get pose of actor with ID 1 at all time steps of the simulation run.

    poseActor1 = get(simLog,"Pose","ActorID",1)
    poseActor1 = 
    
      1×887 struct array with fields:
    
        Time
        Pose

    Get pose of Actor ID 1 at the first time step of the simulation run.

    poseActor1FirstTimeStep = poseActor1(1)
    poseActor1FirstTimeStep = 
    
      struct with fields:
    
        Time: 0
        Pose: [4×4 double]

    Extract the 4-by-4 array representing actor pose at the first step of the simulation run. See What Is a RoadRunner Pose Matrix? for more information about this array.

    poseActor1FirstTimeStep.Pose
    ans =
    
        0.9515    0.3077   -0.0008    7.8466
       -0.3077    0.9515   -0.0026 -133.5547
             0    0.0027    1.0000   -5.5290
             0         0         0    1.0000

    Get pose of actor with ID 1 at the last time step of the simulation run.

    poseActor1LastTimeStep = poseActor1(887)
    poseActor1LastTimeStep = 
    
      struct with fields:
    
        Time: 17.7200
        Pose: [4×4 double]

    Extract the 4-by-4 array representing actor pose at the last step of the simulation run.

    poseActor1LastTimeStep.Pose
    ans =
    
        0.9515    0.3077   -0.0008    7.8466
       -0.3077    0.9515   -0.0026  167.9377
             0    0.0027    1.0000   -5.5290
             0         0         0    1.0000

    Version History

    Introduced in R2022a