addPhase
Description
creates a new phase of the specified type and adds it as the last child of the specified
serial or parallel
phase.rrPhase
= addPhase(parentPhase
,phaseType
)
Examples
Use the addPhase
function to add new action phases as children of
a parallel 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.
Use addPhase
to Add New Phases to Scenario Logic
Use addPhaseInSerial
to
add a new parallel phase, pllPhase
, in serial to
initPhase
. Then, use the addPhase
function to
add two actor action phases, actPhase1
and
actPhase2
, as children of pllPhase
. Assign the
new phases to the actor car
by specifying the value of the
Actor
property of each phase as car
.
pllPhase = addPhaseInSerial(rrLogic,initPhase,"ParallelPhase",Insertion="after"); actPhase1 = addPhase(pllPhase,"ActorActionPhase"); actPhase1.Actor = car; actPhase2 = addPhase(pllPhase,"ActorActionPhase"); actPhase2.Actor = car;
Use addAction
to
specify the action type of actPhase1
as
"ChangeSpeedAction"
and actPhase2
as
"ChangeLaneAction"
. Modify the properties of
chSpd
and chLn
, which represent a
Change Speed
and a Change Lane
action
respectively, to specify for the actor car
to accelerate to 50 m/s
while changing lanes to the right over 1 second.
chSpd = addAction(actPhase1,"ChangeSpeedAction"); chLn = addAction(actPhase2,"ChangeLaneAction"); chSpd.Speed = 50; chSpd.DynamicsDimension = "time"; chSpd.DynamicsValue = 1; chLn.Direction = "right"; chLn.DynamicsDimension = "time"; chLn.DynamicsValue = 1;
Run the simulation by using the simulateScenario
function.
Because actPhase1
and actPhase2
are children of
the same parallel phase, car
performs the Change
Speed
and Change Lane
actions simultaneously during
simulation.
simulateScenario(rrApp)
Input Arguments
Parent phase to which to add the new phase, specified as a ParallelPhase
object or
SerialPhase
object.
Example: rrPhase = addPhase(pllPhase,"ActorActionPhase");
creates
a new ActorActionPhase
object, rrPhase
, and adds
it to the parallel phase pllPhase
.
Type of new phase to add, specified as one of these phase types:
"ActorActionPhase"
— Logic phase that executes an actor action."SystemActionPhase"
— Logic phase that executes a system action."ParallelPhase"
— Logic phase that executes child phases concurrently."SerialPhase"
— Logic phase that executes child phases sequentially.
Note
If parentPhase
is a SerialPhase
object,
you cannot specify phaseType
as
"SerialPhase"
.
Output Arguments
Logic phase, returned as one of these 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 logic phase in the RoadRunner scenario logic that executes child phases concurrently.SerialPhase
— Represents a logic phase in the RoadRunner scenario logic that executes child phases sequentially.
Version History
Introduced in R2025a
See Also
roadrunnerAPI
| addPhaseInParallel
| SerialPhase
| ParallelPhase
| addAction
Topics
- RoadRunner Scenario Fundamentals (RoadRunner Scenario)
- Simulate a RoadRunner Scenario Using MATLAB Functions
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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)