Main Content

findActions

Extract actions from logic phase

Since R2025a

    Description

    rrActions = findActions(rrPhase,actionType) finds all actions of the specified action type in the specified logic phase. For example, rrActions = findActions(rrPhase,"ChangeSpeedAction") extracts an object, rrActions, that represents the Change Speed action type assigned to rrPhase.

    example

    Examples

    collapse all

    By default, RoadRunner Scenario creates an initial phase for every actor added to a scenario. The initial phase contains a Change Speed action that sets the initial speed value for the associated actor. Use the findActions function to extract a ChangeSpeedAction object that represents the Change Speed action from the initial phase of the actor car. Then, use the extracted ChangeSpeedAction object to modify the initial speed of the actor.

    This example assumes that you have prior knowledge of working with RoadRunner in MATLAB®. Before proceeding, follow the steps outlined in Set Up MATLAB Environment for RoadRunner Authoring Functions to set up your scenario using MATLAB functions for scenario authoring.

    Use findActions to Extract ChangeSpeedAction Object

    Use the initialPhaseForActor function to extract the object for the initial phase of the actor car. Then, use the findActions function to extract the ChangeSpeedAction object from the actor initial phase initPhase.

    initPhase = initialPhaseForActor(rrLogic,car);
    initSpeed = findActions(initPhase,"ChangeSpeedAction");

    Modify the initial speed value to specify for the actor to move at 50 m/s. Then, run the simulation by using the simulateScenario function.

    initSpeed.Speed = 50;
    simulateScenario(rrApp)

    Input Arguments

    collapse all

    Phase to search, specified as an ActorActionPhase object or SystemActionPhase object.

    Type of action to find, specified as one of these action types:

    • "ChangeLaneAction" — Specifies to search for a Change Lane action in the specified phase. A Change Lane action specifies for the actor to change lanes using the specified properties.

    • "ChangeSpeedAction" — Specifies to search for a Change Speed action in the specified phase. A Change Speed action specifies for the actor to change speed using the specified properties.

    • "ChangeLongitudinalDistanceAction" — Specifies to search for a Change Longitudinal Distance action in the specified phase. A Change Longitudinal Distance action specifies for the actor to change forward distance relative to another actor using the specified properties.

    • "ChangeLateralOffsetAction" — Specifies to search for a Change Lateral Offset action in the specified phase. A Change Lateral Offset action specifies for the actor to change lateral offset using the specified properties.

    • "WaitAction" — Specifies to search for a Wait action in the specified phase. A Wait action specifies for the simulation to wait in this phase until an associated condition ends the phase.

    Example: rrActions = findActions(initPhase,"ChangeSpeedAction") extracts the Change Speed action from the initial phase initPhase.

    Output Arguments

    collapse all

    Actions extracted from the phase, returned as an array of one of these types of objects:

    • ChangeLaneAction — Represents a Change Lane action in the RoadRunner scenario logic. Specifies for the actor to change lanes using the specified properties.

    • ChangeSpeedAction — Represents a Change Speed action in the RoadRunner scenario logic. Specifies for the actor to change speed using the specified properties.

    • ChangeLongitudinalDistanceAction — Represents a Change Longitudinal Distance action in the RoadRunner scenario logic. Specifies for the actor to change forward distance relative to another actor using the specified properties.

    • ChangeLateralOffsetAction — Represents a Change Lateral Offset action in the RoadRunner scenario logic. Specifies for the actor to change lateral offset using the specified properties.

    • WaitAction — Represents a Wait action in the RoadRunner scenario logic. Specifies for the simulation to wait in this phase until an associated condition ends the phase.

    Each object in rrActions represents the type and attributes of an action for the action phase rrPhase in RoadRunner Scenario.

    Version History

    Introduced in R2025a