View scenario simulation outcomes at any time step
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.
ScenarioLog object that represents a simulation log by
get function of a
object. You can get the log of a simulation only if it has logging enabled using the
set function of
ScenarioSimulation object. You can get the log of a simulation only
after it stops playing.
|Get logged scenario simulation data|
Get Simulation Log
rrApp = roadrunner('C:\RoadRunnerProject'); openScenario(rrApp,'TrajectoryCutIn'); Sim = createSimulation(rrApp);
Enable logging for the simulation.
Start the simulation.
Get the simulation log after the simulation stops playing.
simLog = get(Sim, 'SimulationLog');
Get Actor Pose at First and Last Time Step
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.
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.
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
Introduced in R2022a