Main Content

ActorSpeedCondition

Specify Actor Speed condition

Since R2025a

    Description

    An ActorSpeedCondition object represents an Actor Speed condition in the RoadRunner scenario logic. The Actor Speed condition specifies for the associated phase to end when an actor reaches the specified speed. Specifying ActorSpeedCondition as the condition type when creating an end or fail condition in your scenario adds an Actor Speed condition to the specified phase in the scenario logic. You can use an ActorSpeedCondition object to programmatically modify the attributes of the corresponding Actor Speed condition by changing the property values of the object.

    Creation

    You can create an ActorSpeedCondition 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 "ActorSpeedCondition" to create an ActorSpeedCondition 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 "ActorSpeedCondition" to create an ActorSpeedCondition 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 ActorSpeedCondition in MATLAB®, but RoadRunner Scenario does not display the Name property of conditions in the user interface.

    Actor to compare against the condition, specified as one of these objects:

    • Vehicle — Represents a vehicle actor in the RoadRunner scenario.

    • Character — Represents a character actor in the RoadRunner scenario.

    • MovableObject — Represents a movable object actor in the RoadRunner scenario.

    RoadRunner Scenario compares the speed of Actor against the specified criteria.

    Note

    You must specify a nonempty value for this property before you can run the simulation.

    Speed comparison method, specified as one of these options:

    • "absolute" — Compare the speed of the actor against an absolute speed. RoadRunner Scenario uses the method specified by Rule to compare the actor speed to the specified value of Speed.

    • "actor" — Compare the speed of the actor against the speed of a reference actor. RoadRunner Scenario uses the method specified by Rule to compare the actor speed to the speed defined by the ReferenceActor and Direction properties.

    Rule for speed comparison, specified as one of these options:

    • "eq" — The actor satisfies the condition when it reaches the reference speed.

    • "gt" — The actor satisfies the condition when it reaches a speed greater than the reference speed.

    • "ge" — The actor satisfies the condition when it reaches a speed greater than or equal to the reference speed.

    • "lt" — The actor satisfies the condition when it reaches a speed less than the reference speed.

    • "le" — The actor satisfies the condition when it reaches a speed less than or equal to the reference speed.

    • "ne" — The actor satisfies the condition when it reaches a speed that is not equal to the reference speed.

    Rule specifies the method by which to compare the speed of the actor against the criteria specified by the value of SpeedReference.

    Speed value, in meters per second, to compare against actor speed, specified as a numeric scalar.

    If you set SpeedReference to "absolute", RoadRunner Scenario uses the value of Speed as an absolute value. If you set SpeedReference to "actor", RoadRunner Scenario uses the value of Speed as the speed offset value to compare against the reference actor speed.

    Data Types: double

    Reference actor against which to compare the speed of Actor, specified as one of these objects:

    • Vehicle — Represents a vehicle actor in the RoadRunner scenario.

    • Character — Represents a character actor in the RoadRunner scenario.

    • MovableObject — Represents a movable object actor in the RoadRunner scenario.

    To use this property, you must set the value of the SpeedReference property to "Actor".

    Speed of target actor relative to reference actor speed, specified as "faster", "slower", or "same". To use this property, you must set the value of the SpeedReference property to "actor". This property specifies that the condition is met if the actor speed meets one of these criteria:

    • "faster" — The actor travels faster than the reference actor.

    • "slower" — The actor travels slower than the reference actor.

    • "same" — The actor travels at the same speed as the reference actor.

    Speed sampling mode, specified as "action-start" or "continuous". This value indicates when RoadRunner Scenario samples the speed of the reference actor for comparison.

    • "action-start"RoadRunner Scenario compares the speed of the reference actor sampled at the start of the assigned action against the speed goal.

    • "continuous"RoadRunner Scenario compares the speed of the reference actor sampled over the course of the assigned action against the speed goal.

    To use this property, you must set the value of the SpeedReference property to "actor".

    Examples

    collapse all

    The Actor Speed condition enables you to modify simulation behavior when the specified actor satisfies speed criteria.

    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 Actor Speed Condition

    Use addPhaseInSerial to add a new actor action phase, srPhase, in serial after the initial phase. Then, use addAction to specify "ChangeSpeedAction" as the action of the new phase. srPhase represents the newly created actor action phase in the scenario logic, and chSpd represents the Change Speed action assigned to srPhase.

    srPhase = addPhaseInSerial(rrLogic,initPhase,"ActorActionPhase",Insertion="after");
    chSpd = addAction(srPhase,"ChangeSpeedAction");

    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 its speed to 30 m/s during simulation, set the Speed property of chSpd to 30.

    srPhase.Actor = car;
    chSpd.Speed = 30;
    chSpd.DynamicsDimension = "time";
    chSpd.DynamicsValue = 1;

    Using the same process, add a ChangeLaneAction phase after srPhase, and set the Direction property to "right", the DynamicsDimension property to "time", and the DynamicsValue property to 1.

    chLnPhase = addPhaseInSerial(rrLogic,srPhase,"ActorActionPhase",Insertion="after");
    chLn = addAction(chLnPhase,"ChangeLaneAction");
    chLnPhase.Actor = car;
    chLn.Direction = "right";
    chLn.DynamicsDimension = "time";
    chLn.DynamicsValue = 1;

    Use setEndCondition to add a condition, rrCondition, to the Change Speed action phase srPhase and specify the condition type as "ActorSpeedCondition". Set Rule to "eq", and Speed to 30.

    This adds an Actor Speed condition to srPhase that instructs the actor to perform the action specified by srPhase until it reaches a speed of 30 m/s.

    rrCondition = setEndCondition(srPhase,"ActorSpeedCondition");
    rrCondition.Actor = car;
    rrCondition.Rule = "eq";
    rrCondition.Speed = 30;

    Run the simulation by using the simulateScenario function. Once the actor reaches 30 m/s, satisfying the criteria specified by rrCondition, it changes lanes to the right as specified by chLnPhase.

    simulateScenario(rrApp)

    Version History

    Introduced in R2025a