SerialPhase
Specify options for customizing logic phase that executes child phases sequentially
Since R2025a
Description
A SerialPhase object represents a serial logic phase in the
        RoadRunner scenario logic . Serial phases execute their child phases sequentially during
      simulation. 
Creation
You can create a SerialPhase object in these ways:
- The - addPhaseInParallelfunction 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- phaseTypeargument as- "SerialPhase"to create a- SerialPhaseobject.
- The - addPhasefunction creates a new phase of the specified type and adds it as the last child of the specified parallel phase in the RoadRunner scenario logic. Specify the- phaseTypeargument as- "SerialPhase"to create a- SerialPhaseobject.
Note
You cannot specify a serial phase as a child of another serial phase.
Properties
Name of the phase, specified as a string scalar or character vector.
Note
You can specify the Name property of
                  SerialPhase in MATLAB®, but RoadRunner Scenario does not display the Name property of serial phases
                in the user interface.
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.
- 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.
              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 Speedcondition in the RoadRunner scenario logic. Specifies for the associated phase to end when an actor reaches the specified speed.
- DurationCondition— Represents a- Durationcondition in the RoadRunner scenario logic. Specifies for the associated phase to end after the specified amount of time elapses.
- CollisionCondition— Represents a- Collisioncondition in the RoadRunner scenario logic. Specifies for the associated phase to end when the actor specified by- FirstActorcollides with the actor specified by- SecondActor.
- PhaseStateCondition— Represents a- Phase Statecondition 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 Actorcondition 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 Pointcondition 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 Actorcondition in the RoadRunner scenario logic. Specifies for the associated phase to end when an actor reaches a certain longitudinal distance from another actor.
- SimulationTimeCondition— Represents a- Simulation Timecondition in the RoadRunner scenario logic. Specifies for the associated phase to end after the specified amount of time has elapsed since the start of the simulation.
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 Speedcondition in the RoadRunner scenario logic. Specifies for the associated phase to end when an actor reaches the specified speed.
- DurationCondition— Represents a- Durationcondition in the RoadRunner scenario logic. Specifies for the associated phase to end after the specified amount of time elapses.
- CollisionCondition— Represents a- Collisioncondition in the RoadRunner scenario logic. Specifies for the associated phase to end when the actor specified by- FirstActorcollides with the actor specified by- SecondActor.
- PhaseStateCondition— Represents a- Phase Statecondition 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 Actorcondition 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 Pointcondition 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 Actorcondition in the RoadRunner scenario logic. Specifies for the associated phase to end when an actor reaches a certain longitudinal distance from another actor.
- SimulationTimeCondition— Represents a- Simulation Timecondition in the RoadRunner scenario logic. Specifies for the associated phase to end after the specified amount of time has elapsed since the start of the simulation.
Examples
Use addPhaseInParallel to create a serial phase object for your
            scenario.
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 Serial Phase to Scenario Logic
Use addPhaseInSerial to add a new actor action phase,
                newPhase, in serial after the initial phase of the actor, and
              specify the Actor property as car. Then, use
                addAction to specify the action type of the new phase as
                "ChangeSpeedAction".
              
newPhase = addPhaseInSerial(rrLogic,initPhase,"ActorActionPhase",Insertion="after"); newPhase.Actor = car; chSpd = addAction(newPhase,"ChangeSpeedAction"); chSpd.Speed = 30;
To create an object, srPhase, that represents a serial phase in
              your RoadRunner scenario, use addPhaseInParallel and specify the
                phaseType argument as "SerialPhase" to add a
              new serial phase in parallel to newPhase in the RoadRunner scenario logic. You must add the serial phase in parallel to the
              existing phase because serial phases cannot be children of serial phases.
srPhase = addPhaseInParallel(rrLogic,newPhase,"SerialPhase");
By default, serial phases do not contain any action phases. Use addPhase to add an
              actor action phase to the serial phase srPhase. Then, use addAction to
              specify an action type. 
By specifying a serial phase as the parent phase when using the
                addPhase function, you can quickly add new action phases
              sequentially to your scenario logic without specifying their positions relative to
              existing phases. By default, addPhase adds the new phase to the end
              of the specified serial phase sequence.
actionPhase = addPhase(srPhase,"ActorActionPhase"); actionPhase.Actor = car; chLn = addAction(actionPhase,"ChangeLaneAction"); chLn.Direction = "right";
Run the simulation by using the simulateScenario
              function.
simulateScenario(rrApp)
Version History
Introduced in R2025a
See Also
addPhaseInSerial | addPhaseInParallel | addPhase | PhaseLogic | ParallelPhase
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)