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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)