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.
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.
The rrAction object represents the action type and its attributes
for the associated action phase in RoadRunner Scenario.
Version History
Introduced in R2025a
See Also
roadrunnerAPI | addPhaseInSerial | addPhaseInParallel | SerialPhase | ParallelPhase
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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)