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)