Main Content

addPhaseInSerial

Create logic phase that executes sequentially during simulation

Since R2025a

    Description

    rrPhase = addPhaseInSerial(rrLogic,existingPhase,phaseType) creates a logic phase with the specified phase type and adds it in serial after the specified existing phase in the RoadRunner scenario logic. If the existing phase is not already a child of a serial phase, RoadRunner Scenario creates a new parent serial phase.

    example

    rrPhase = addPhaseInSerial(rrLogic,existingPhase,phaseType,Insertion=insertionPosition) also specifies the position in the logic sequence at which to insert the new phase relative to the specified existing phase.

    Examples

    collapse all

    Build a scenario in RoadRunner Scenario in which the actor changes lanes to the right of its current lane. To do this, add a Change Lane action phase in serial after the initial phase in the RoadRunner scenario logic.

    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.

    Add ChangeLaneAction Phase in Serial to Scenario Logic

    Use addPhaseInSerial to add a new actor action phase, srPhase, in serial after the initial phase. Then, use addAction to specify "ChangeLaneAction" as the action type of the new phase. srPhase represents the newly added actor action phase in the scenario logic, and chLn represents the Change Lane action assigned to srPhase.

    srPhase = addPhaseInSerial(rrLogic,initPhase,"ActorActionPhase",Insertion="after");
    chLn = addAction(srPhase,"ChangeLaneAction");

    Assign the new phase to the actor car by specifying the value of the Actor property of the phase as car. To instruct the actor to change lanes to the right of its current lane during simulation, set the Direction property of the action chLn to "ToRight".

    srPhase.Actor = car;
    chLn.Direction = "right";

    Run the simulation by using the simulateScenario function.

    simulateScenario(rrApp)

    Input Arguments

    collapse all

    Scenario logic object, specified as a PhaseLogic object. The PhaseLogic object represents the root phase for the scenario in the RoadRunner scenario logic and contains all logic components for the scenario.

    Example: rrPhase = addPhaseInSerial(rrLogic,initPhase,"ActorActionPhase"); adds a new ActorActionPhase phase to the scenario logic rrLogic after the existing phase initPhase.

    Existing phase, specified as one of these objects:

    The function places the new phase before or after this phase in the scenario logic. RoadRunner Scenario uses the value of insertionPosition to determine the phase order.

    Type of phase to create, specified as one of these values:

    • "ActorActionPhase" — Logic phase that executes an actor action.

    • "SystemActionPhase" — Logic phase that executes a system action.

    • "ParallelPhase" — Logic phase that executes child phases concurrently.

    Position of the new phase in the logic sequence, specified as one of these options:

    • "before" — Add the new phase before existingPhase in the scenario logic.

    • "after" — Add the new phase after existingPhase in the scenario logic.

    Output Arguments

    collapse all

    Logic phase, returned as one of these objects:

    • ActorActionPhase — Represents a logic phase that executes an actor action.

    • SystemActionPhase — Represents a logic phase that executes a system action.

    • ParallelPhase — Represents a logic phase that executes child phases concurrently.

    The value of the phaseType argument determines the type of the returned object.

    Version History

    Introduced in R2025a