Main Content

ParallelPhase

Specify options for customizing logic phase that executes child phases concurrently

Since R2025a

    Description

    A ParallelPhase object represents a parallel logic phase in the RoadRunner scenario logic. Parallel phases execute their child phases concurrently during simulation.

    Creation

    You can create a ParallelPhase object in these ways:

    • The addPhaseInSerial function creates a logic phase with the specified phase type, and adds it before or after the specified existing phase in the RoadRunner scenario logic. Specify the phaseType argument as "ParallelPhase" to create a ParallelPhase object.

    • The addPhaseInParallel function creates a phase with the specified type and adds it in parallel to the specified existing phase or serial sequence of phases in the RoadRunner scenario logic. Specify the phaseType argument as "ParallelPhase" to create a ParallelPhase object.

    • The addPhase function creates a new phase of the specified type and adds it as the last child of the specified serial or parallel phase in the RoadRunner scenario logic. Specify the phaseType argument as "ParallelPhase" to create a ParallelPhase object.

    Properties

    expand all

    Name of the phase, specified as a string scalar or character vector.

    Child phases of the phase, specified as an array of one of these types of objects:

    • ActorActionPhase — Represents an actor action phase in the RoadRunner scenario logic.

    • SystemActionPhase — Represents a logic phase in the RoadRunner scenario logic that executes actions without an actor.

    • SerialPhase — Represents a serial logic phase in the RoadRunner scenario logic that executes child phases sequentially during simulation.

    • ParallelPhase — Represents a parallel logic phase in the RoadRunner scenario logic that executes child phases concurrently during simulation.

    Note

    You must specify a nonempty value for this property before you can run the simulation.

    This property is read-only.

    Parent phase, represented as a ParallelPhase object or SerialPhase object. RoadRunner Scenario returns an empty object if this phase has no parent phase.

    Condition to trigger phase completion, specified as one of these objects:

    • ActorSpeedCondition — Represents an Actor Speed condition in the RoadRunner scenario logic. Specifies for the associated phase to end when an actor reaches the specified speed.

    • DurationCondition — Represents a Duration condition in the RoadRunner scenario logic. Specifies for the associated phase to end after the specified amount of time elapses.

    • CollisionCondition — Represents a Collision condition in the RoadRunner scenario logic. Specifies for the associated phase to end when the actor specified by FirstActor collides with the actor specified by SecondActor.

    • PhaseStateCondition — Represents a Phase State condition in the RoadRunner scenario logic. Specifies for the associated phase to end when the referenced phase reaches the specified state.

    • DistanceToActorCondition — Represents a Distance To Actor condition in the RoadRunner scenario logic. Specifies for the associated phase to end when the actor is a certain distance away from the reference actor.

    • DistanceToPointCondition — Represents a Distance To Point condition in the RoadRunner scenario logic. Specifies for the associated phase to end when an actor is a certain distance away from a specified point.

    • LongitudinalDistanceToActorCondition — Represents a Longitudinal Distance To Actor condition in the RoadRunner scenario logic. Specifies for the associated phase to end when an actor reaches a certain longitudinal distance from another actor.

    If any actions are still executing when the condition triggers, RoadRunner Scenario ends those actions early.

    Condition to fail scenario if triggered during phase execution, specified as one of these objects:

    • ActorSpeedCondition — Represents an Actor Speed condition in the RoadRunner scenario logic. Specifies for the associated phase to end when an actor reaches the specified speed.

    • DurationCondition — Represents a Duration condition in the RoadRunner scenario logic. Specifies for the associated phase to end after the specified amount of time elapses.

    • CollisionCondition — Represents a Collision condition in the RoadRunner scenario logic. Specifies for the associated phase to end when the actor specified by FirstActor collides with the actor specified by SecondActor.

    • PhaseStateCondition — Represents a Phase State condition in the RoadRunner scenario logic. Specifies for the associated phase to end when the referenced phase reaches the specified state.

    • DistanceToActorCondition — Represents a Distance To Actor condition in the RoadRunner scenario logic. Specifies for the associated phase to end when the actor is a certain distance away from the reference actor.

    • DistanceToPointCondition — Represents a Distance To Point condition in the RoadRunner scenario logic. Specifies for the associated phase to end when an actor is a certain distance away from a specified point.

    • LongitudinalDistanceToActorCondition — Represents a Longitudinal Distance To Actor condition in the RoadRunner scenario logic. Specifies for the associated phase to end when an actor reaches a certain longitudinal distance from another actor.

    Examples

    collapse all

    Add a parallel phase to your scenario logic to specify for an actor, car, to change lanes and accelerate, at the same time during simulation.

    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.

    Design Scenario Using Parallel Phase

    Use addPhaseInSerial to add a parallel phase, pllPhase, in serial after the initial phase initPhase.

    pllPhase = addPhaseInSerial(rrLogic,initPhase,"ParallelPhase",Insertion="after");

    Use addPhase to add two actor action phases, chLnPhase and chSpdPhase, as children of the new parallel phase, and set the Actor properties of both phases to car. Then, use addAction to add ChangeLaneAction and ChangeSpeedAction actions to chLnPhase and chSpdPhase, respectively. The addAction function outputs objects you can use to reference the ChangeLaneAction and ChangeSpeedAction actions: chLn and chSpd, respectively.

    Set the Direction property of chLn to "ToRight" and the Speed property of chSpd to 30 m/s.

    chLnPhase = addPhase(pllPhase,"ActorActionPhase");
    chLnPhase.Actor = car
    chLn = addAction(chLnPhase,"ChangeLaneAction");
    chLn.Direction = "right"
    
    chSpdPhase = addPhase(pllPhase,"ActorActionPhase");
    chSpdPhase.Actor = car
    chSpd = addAction(chSpdPhase,"ChangeSpeedAction");
    chSpd.Speed = 30

    Run the simulation by using the simulateScenario function. Because the two action phases chLnPhase and chSpdPhase are within the parallel phase pllPhase, they execute concurrently during simulation.

    simulateScenario(rrApp)

    Version History

    Introduced in R2025a