Main Content

ChangeLaneAction

Specify Change Lane action

Since R2025a

    Description

    The ChangeLaneAction object represents a Change Lane action in the RoadRunner scenario logic. The Change Lane action specifies for the actor to change lanes using the specified properties. Specifying ChangeLaneAction as the action type when adding an action to your scenario adds a Change Lane action to the specified phase in the scenario logic. You can use the ChangeLaneAction object to programmatically modify the attributes of the corresponding Change Lane 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 "ChangeLaneAction" to create a ChangeLaneAction 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 ChangeLaneAction in MATLAB®, but RoadRunner Scenario does not display the Name property of actions in the user interface.

    Phase containing the action, specified as an ActorActionPhase object.

    Reference point of lane change, specified as one of these options:

    • "lane" — The lane change is relative to the current lane of the actor.

    • "actor" — The lane change is relative to the current lane of ReferenceActor.

    Reference actor against which to compare the lane of the 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 specify the value of the LaneChangeReference property as "actor".

    Direction of the lane change, specified as one of these options:

    • "left" — The target lane is to the left of the current lane of the lane change reference point.

    • "right" — The target lane is to the right of the current lane of the lane change reference point.

    • "same-lane" — The target lane is the current lane of ReferenceActor.

    The option you specify for LaneChangeReference determines the lane change reference point.

    Number of lanes to change, specified as a positive integer.

    Dynamics dimension for the action transition, specified as "rate", "time", or "distance". The actor uses DynamicsDimension to determine how to achieve the action.

    • "rate" — Actor achieves the action with a specified velocity rate, in meters per second.

    • "time" — Actor achieves the action over a specified length of time, in seconds.

    • "distance" — Actor achieves the action over a specified distance, in meters.

    The option you specify determines what the value of the DynamicsValue property represents.

    Shape of the dynamics profile that the actor uses to achieve the action, specified as one of these options:

    • "cubic" — The actor action change follows a cubic polynomial.

    • "linear" — The actor action changes linearly.

    • "step" — The actor action changes step-wise.

    • "sinusoidal" — The actor action change follows a sine wave.

    Value for the dynamics dimension, specified as a positive scalar. This property sets the value for the dynamics dimension specified by the DynamicsDimension property.

    Data Types: double

    Examples

    collapse all

    Use a ChangeLaneAction object to specify for an actor to change lanes to the right of its current lane over 1 second 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 ChangeLaneAction to Scenario Logic

    Use addPhaseInSerial to add a new actor action phase, srPhase, in serial after the initial phase. Then, use addAction to specify the action of the new phase as "ChangeLaneAction". The srPhase object 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 car to the Actor property of the action phase srPhase. For the Change Lane action chLn, set the Direction property to "right", the DynamicsDimension property to "time", and the DynamicsValue property to 1. This instructs the assigned actor car to change lanes to the right of its current lane over 1 second during simulation.

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

    Run the simulation by using the simulateScenario function.

    simulateScenario(rrApp)

    Version History

    Introduced in R2025a