10.8 Events and actions

Under Maneuver_1, we define two instances of Event: Turn left for left lane change and Turn right for right lane change. Here, left and right refer to directions relative to the current lane.

In the first Event to be executed — which is Turn left — one ConditionGroup and inside it one RelativeDistanceCondition is used. This condition verifies whether the current longitudinal distance between Vehicle 1 and Vehicle 2 is less than 20 m or not. Vehicle 1 is faster than Vehicle 2. Thus, their relative distance eventually drops below 20 m. When this happens, the StartTrigger for Turn left event is activated, prompting Vehicle 1 to initiate a LaneChange to the left.

The second Event named Turn right contains also one LaneChangeAction, but this one targets the same lane where Vehicle 2 is currently located. That means, the target is to get back to the same lane where Vehicle 1 was, but this time in front of Vehicle 2.

In this action, we specified the exact coordinates on the target lane, but we could have also used relative road coordinates relative to Vehicle 2. Using relative coordinates makes the scenario more portable to other road networks.

For triggering the event Turn right we use two conditions in one condition group, which means they both have to be true at the exact same time. We use RelativeDistanceCondition that checks whether the relative longitudinal distance between Vehicle 2 and Vehicle 1 is no longer greater than 10 m. However, we have to combine this condition with SimulationTimeCondition to disallow triggering RelativeDistanceCondition anytime before 5 seconds.

<Event priority="override" maximumExecutionCount="1" name="Turn left">
  <Action name="Lane Change">
    <PrivateAction>
      <LateralAction>
        <LaneChangeAction targetLaneOffset="0.0238800048828">
          <LaneChangeActionDynamics dynamicsDimension="distance" dynamicsShape="cubic" value="36.6430664063"/>
          <LaneChangeTarget>
            <AbsoluteTargetLane value="-3"/>
          </LaneChangeTarget>
        </LaneChangeAction>
      </LateralAction>
    </PrivateAction>
  </Action>
  <StartTrigger>
    <ConditionGroup>
      <Condition delay="0.0" conditionEdge="rising" name="Relative Distance">
        <ByEntityCondition>
          <TriggeringEntities triggeringEntitiesRule="any">
            <EntityRef entityRef="Vehicle 1"/>
          </TriggeringEntities>
          <EntityCondition>
            <RelativeDistanceCondition freespace="false" rule="lessThan" entityRef="Vehicle 2" value="20.0" relativeDistanceType="longitudinal"/>
          </EntityCondition>
        </ByEntityCondition>
      </Condition>
    </ConditionGroup>
  </StartTrigger>
</Event>


<Event priority="override" maximumExecutionCount="1" name="Turn right">
  <Action name="Lane Change">
    <PrivateAction>
      <LateralAction>
        <LaneChangeAction>
          <LaneChangeActionDynamics dynamicsDimension="distance" dynamicsShape="cubic" value="20.0"/>
          <LaneChangeTarget>
            <AbsoluteTargetLane value="-4"/>
          </LaneChangeTarget>
        </LaneChangeAction>
      </LateralAction>
    </PrivateAction>
  </Action>
  <StartTrigger>
    <ConditionGroup>
      <Condition delay="0.0" conditionEdge="rising" name="Relative Distance">
        <ByEntityCondition>
          <TriggeringEntities triggeringEntitiesRule="any">
            <EntityRef entityRef="Vehicle 2"/>
          </TriggeringEntities>
          <EntityCondition>
            <RelativeDistanceCondition freespace="false" rule="greaterThan" entityRef="Vehicle 1" value="10.0" relativeDistanceType="longitudinal"/>
          </EntityCondition>
        </ByEntityCondition>
      </Condition>
      <Condition delay="0.0" conditionEdge="none" name="Simulation Time">
        <ByValueCondition>
          <SimulationTimeCondition rule="greaterThan" value="5.0"/>
        </ByValueCondition>
      </Condition>
    </ConditionGroup>
  </StartTrigger>
</Event>