Main Content

getAction

Get actions associated with actor

Since R2022a

    Description

    action = getAction(actorSim,actionName) gets the specified action actionName, if present, for the actor represented by actorSim at the current simulation time step. If no action is configured at the current time step, an empty array is returned.

    example

    action = getAction(actorSim,"UserDefinedAction",UserDefinedActionName) gets the user-defined action named UserDefinedActionName for the actor represented by actorSim.

    Examples

    collapse all

    Create sim, a 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 all actors from the simulation.

    actorsim = get(sim,"ActorSimulation"); 
    

    Get the first actor from the list.

    actorOne = actorsim{1};
    

    Get the lateral offset action of the first actor at the current time step.

    loAction = getAction(actorOne,"LateralOffsetAction")

    Input Arguments

    collapse all

    Actor from which to return action, specified as an ActorSimulation object.

    Actor action to be returned, specified as one of these values:

    • "PathAction"

    • "SpeedAction"

    • "LaneChangeAction"

    • "LateralOffsetAction"

    • "ChangeParameterAction"

    • "LongitudinalDistanceAction"

    • "UserDefinedAction"

    Data Types: string | char

    Name of the user-defined action to be returned, specified as a character vector or string scalar.

    Data Types: string | char

    Output Arguments

    collapse all

    Action of specified actor at current time step, returned as a struct. The type of structure depends on the input argument actionName.

    Value of actionNameValue of action
    "PathAction"PathAction structure
    "SpeedAction"SpeedAction structure
    "LaneChangeAction"LaneChangeAction structure
    "LateralOffsetAction"LateralOffsetAction structure
    "ChangeParameterAction"ChangeParameterAction structure
    "LongitudinalDistanceAction"LongitudinalDistanceAction structure
    "UserDefinedAction"UserDefinedAction structure

    More About

    collapse all

    Version History

    Introduced in R2022a