Main Content

DurationCondition

Specify Duration condition

Since R2025a

    Description

    A DurationCondition object represents a Duration condition in the RoadRunner scenario logic. The Duration condition specifies for the associated phase to end after the specified amount of time elapses. Specifying DurationCondition as the condition type when creating an end or fail condition in your scenario adds a Duration condition to the specified phase in the scenario logic. You can use the DurationCondition object to programmatically modify the attributes of the corresponding Duration condition by changing the property values of the object.

    Creation

    You can create a DurationCondition object in these ways:

    • The setEndCondition function creates and assigns a condition of the specified type to the end of a specified phase. Specify the conditionType argument as "DurationCondition" to create a DurationCondition object associated with the specified phase.

    • The setFailCondition function assigns a condition of the specified type to the Fail Conditions of the scenario root phase. Specify the conditionType argument as "DurationCondition" to create a DurationCondition object associated with the scenario Fail Conditions.

    Properties

    expand all

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

    Note

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

    Amount of time, in seconds, that satisfies the condition, specified as a positive scalar. RoadRunner Scenario measures the time elapsed since the start of the phase associated with the DurationCondition object against the value of Duration.

    Data Types: double

    Examples

    collapse all

    Add a Duration condition to the scenario that specifies for the actor to drive forward for 3 seconds before changing lanes.

    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.

    Design Scenario Using Duration Condition

    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 type of the new phase. srPhase represents the newly added actor action phase in the RoadRunner 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. Specify for the actor to change lanes to the right over 1 second by setting the Direction property to "right", the DynamicsDimension property to "time", and the DynamicsValue property to 1.

    srPhase.Actor = car;
    chLn.Direction = "right";
    chLn.DynamicsDimension = "time";
    chLn.DynamicsValue = 1;

    Use setEndCondition to add a condition, rrCondition, to the initial phase initPhase, and specify the condition type as "DurationCondition". Then, set Duration to 3 seconds.

    This adds a Duration condition to initPhase that instructs the actor to perform the action specified by initPhase for 3 seconds before performing the next action in the sequence.

    rrCondition = setEndCondition(initPhase,"DurationCondition");
    rrCondition.Duration = 3;
    

    Run the simulation by using the simulateScenario function.

    simulateScenario(rrApp)

    Version History

    Introduced in R2025a