Main Content

ChangeLateralOffsetAction

Specify Change Lateral Offset action

Since R2025a

    Description

    The ChangeLateralOffsetAction object represents a Change Lateral Offset action in the RoadRunner scenario logic. The Change Lateral Offset action specifies for the actor to change its lateral offset using the specified properties. Specifying ChangeLateralOffsetAction as the action type when adding an action to your scenario adds a Change Lateral Offset action to the specified phase in the scenario logic. You can use the ChangeLateralOffsetAction object to programmatically modify the attributes of the corresponding Change Lateral Offset 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 "ChangeLateralOffsetAction" to create a ChangeLateralOffsetAction 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 ChangeLateralOffsetAction 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.

    Direction of the lateral offset, specified as one of these options:

    • "left" — The actor changes its lateral offset to the left of its current lane or route.

    • "right" — The actor changes its lateral offset to the right of its current lane or route.

    • "center" — The actor changes its lateral offset to the center of its current lane or route.

    Distance, in meters, to offset the actor from its current lane or route, specified as a positive scalar.

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

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

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

    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 ChangeLateralOffsetAction object to specify for an actor to change its lateral offset by 2 meters to the right of its current lane, then change its lateral offset back to the center of its current lane 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 ChangeLateralOffsetAction 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 "ChangeLateralOffsetAction". The srPhase object represents the newly created actor action phase in the scenario logic, and chLat represents the Change Lateral Offset action assigned to srPhase.

    srPhase = addPhaseInSerial(rrLogic,initPhase,"ActorActionPhase",Insertion="after");
    chLat = addAction(srPhase,"ChangeLateralOffsetAction");

    Assign car to the Actor property of the action phase srPhase. For the Change Lateral Offset action chLat, set the Direction property to "right", the LateralOffset property to 2, the DynamicsDimension property to "time", and the DynamicsValue property to 1. This instructs the assigned actor car to change its lateral offset by 2 meters to the right of its current lane over 1 second during simulation.

    srPhase.Actor = car;
    chLat.Direction = "right";
    chLat.LateralOffset = 2;
    chLat.DynamicsDimension = "time";
    chLat.DynamicsValue = 1;

    Using the same process, add another phase, secondPhase, after srPhase. Add a "ChangeLateralOffsetAction" to secondPhase and modify the properties of the new action chLat2 to instruct the actor car to change its lateral offset back to the center of its current lane over 1 second.

    secondPhase = addPhaseInSerial(rrLogic,srPhase,"ActorActionPhase",Insertion="after");
    secondPhase.Actor = car;
    chLat2 = addAction(secondPhase,"ChangeLateralOffsetAction");
    chLat2.Direction = "center";
    chLat2.DynamicsDimension = "time";
    chLat2.DynamicsValue = 1;

    Run the simulation by using the simulateScenario function.

    simulateScenario(rrApp)

    Version History

    Introduced in R2025a