Main Content

WaitAction

Specify Wait action

Since R2025a

    Description

    The WaitAction object represents a Wait action in the RoadRunner scenario logic. The Wait action specifies for the simulation to wait in this phase until an associated condition ends the phase. Specifying WaitAction as the action type when adding an action to your scenario adds a Wait action to the specified phase in the scenario logic. You can use the WaitAction object to programmatically modify the attributes of the corresponding Wait action by changing the property values of the object.

    Creation

    The addAction function adds an action of the specified type as a child to the specified phase. Specify the actionType argument as "WaitAction" to create a WaitAction object associated with the specified phase.

    Properties

    expand all

    Name of the action, specified as a string scalar or character vector.

    Note

    You can specify the Name property of WaitAction in MATLAB®, but RoadRunner Scenario does not display the Name property of actions in the user interface.

    Phase containing the action, specified as a SystemActionPhase object.

    Examples

    collapse all

    Specify for RoadRunner to wait 3 seconds before initializing the actor car during simulation.

    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.

    Add WaitAction to Scenario Logic

    Use addPhaseInSerial to add a new system action phase, waitPhase, in serial before the initial phase. Then, use addAction to specify the action of the new phase as "WaitAction". The waitPhase object represents the newly created system action phase in the scenario logic, and waitAct represents the Wait action assigned to waitPhase.

    waitPhase = addPhaseInSerial(rrLogic,initPhase,"SystemActionPhase",Insertion="before");
    waitAct = addAction(waitPhase,"WaitAction");

    To specify the duration of the wait action, use setEndCondition to add a Duration condition to waitPhase. Then, set the Duration property of the condition waitTime to 3 seconds. Because the wait action executes before the initial phase of car, RoadRunner Scenario waits 3 seconds before spawning car and initializing the remaining phases during simulation.

    waitTime = setEndCondition(waitPhase,"DurationCondition");
    waitTime.Duration = 3;
    

    Run the simulation by using the simulateScenario function.

    simulateScenario(rrApp)

    Version History

    Introduced in R2025a