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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- 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)