addAction
Description
creates an action of the specified type and adds it as a child of the specified logic phase.
For example, rrAction = addAction(rrPhase,actionType)rrAction = addAction(rrPhase,"ChangeSpeedAction") creates an
object, rrAction, that represents the Change
Speed action type and its attributes in the RoadRunner scenario logic and assigns it to rrPhase.
Examples
Use addAction to specify the action type for a new 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 addAction to Add Action to New Phase
Use addPhaseInSerial to
add a new actor action phase, srPhase, in serial after the initial
phase. Then, use addAction to specify
"ChangeLaneAction" as the action of the new phase .
srPhase represents the newly created actor action phase in the
scenario logic, and chLn represents the Change
Lane action assigned to srPhase.
srPhase = addPhaseInSerial(rrLogic,initPhase,"ActorActionPhase",Insertion="after"); chLn = addAction(srPhase,"ChangeLaneAction");
Assign the actor to the new phase by specifying car as the
value of the Actor property of the phase. To instruct the actor to
change lanes to the right of its current lane during simulation, set the
Direction property of the action type chLn to
"right".
srPhase.Actor = car;
chLn.Direction = "right";
Run the simulation by using the simulateScenario
function.
simulateScenario(rrApp)
Input Arguments
Phase to which to assign the action type, specified as an ActorActionPhase object
or SystemActionPhase
object.
Example: rrAction = addAction(rrPhase,"ChangeLaneAction");
specifies for RoadRunner Scenario to add the Change Lane action type to the phase
rrPhase. This returns the object rrAction that
represents the action type and its properties.
Type of action to assign to the phase rrPhase, specified as one
of these action types:
"ChangeLaneAction"— Represents aChange Laneaction in the RoadRunner scenario logic. Specifies for the actor to change lanes using the specified properties."ChangeSpeedAction"— Represents aChange Speedaction in the RoadRunner scenario logic. Specifies for the actor to change speed using the specified properties."ChangeLongitudinalDistanceAction"— Represents aChange Longitudinal Distanceaction in the RoadRunner scenario logic. Specifies for the actor to change forward distance relative to another actor using the specified properties."ChangeLateralOffsetAction"— Represents aChange Lateral Offsetaction in the RoadRunner scenario logic. Specifies for the actor to change lateral offset using the specified properties."WaitAction"— Represents aWaitaction in the RoadRunner scenario logic. Specifies for the simulation to wait in this phase until an associated condition ends the phase."RemoveActorAction"— Represents aRemove Actoraction in the RoadRunner scenario logic. Specifies for RoadRunner Scenario to remove the associated actor from the scenario during simulation run time.
Output Arguments
Action type of the phase, returned as one of these objects:
ChangeLaneAction— Represents aChange Laneaction in the RoadRunner scenario logic. Specifies for the actor to change lanes using the specified properties.ChangeSpeedAction— Represents aChange Speedaction in the RoadRunner scenario logic. Specifies for the actor to change speed using the specified properties.ChangeLongitudinalDistanceAction— Represents aChange Longitudinal Distanceaction in the RoadRunner scenario logic. Specifies for the actor to change forward distance relative to another actor using the specified properties.ChangeLateralOffsetAction— Represents aChange Lateral Offsetaction in the RoadRunner scenario logic. Specifies for the actor to change lateral offset using the specified properties.WaitAction— Represents aWaitaction in the RoadRunner scenario logic. Specifies for the simulation to wait in this phase until an associated condition ends the phase.RemoveActorAction— Represents aRemove Actoraction in the RoadRunner scenario logic. Specifies for RoadRunner Scenario to remove the associated actor from the scenario during simulation run time.
The rrAction object represents the action type and its attributes
for the associated action phase in RoadRunner Scenario.
Version History
Introduced in R2025a
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)