10.9 Sequential execution

The basic execution pattern for StoryboardElement instances is parallel execution of nested elements, for example, a Storyboard executes a Story concurrently, while a Story executes one or multiple instances of Act in parallel.

In many use cases, however, an Action is applied only when others have finished. That means sequentialization of multiple occurrences of Action is a major concept when writing and executing scenarios.

Two major concepts are provided:

  • Implicit synchronization of StoryboardElement instances: An action increases the speed of the Ego vehicle. Another event starts when the Ego vehicle reaches a specific speed.

  • Explicit synchronization of StoryboardElement instances: A start trigger of an event or of an act listens to the state of a storyboard element.

10.9.1 First example of sequential execution

The scenario comprises the following Event instances:

  1. The Ego vehicle increases speed from 0 to 100 km/h, starting at simulationTime = 0.

  2. The Ego vehicle brakes to a stop, starting when its speed reaches 100 km/h.

The following two examples show implicit and explicit synchronization.

10.9.1.1 Implicit sequentialization

Deterministic order can be ensured by using resulting states from one action as StartTrigger for another Action.

<Maneuver name="AccelerateAndBrakeManeuver">
  <Event name="AccelerateEvent"
         priority="override"
         maximumExecutionCount="1">
    <Action name="AccelerateAction">
      <PrivateAction>
        <LongitudinalAction>
          <SpeedAction>
            <SpeedActionDynamics dynamicsShape="linear"
                                 value="4.0"
                                 dynamicsDimension="rate" />
              <SpeedActionTarget>
                <AbsoluteTargetSpeed value="27.78" />
              </SpeedActionTarget>
          </SpeedAction>
        </LongitudinalAction>
      </PrivateAction>
    </Action>
    <StartTrigger>
      <ConditionGroup>
        <Condition name="AccelerateStartCondition"
                   delay="0"
                   conditionEdge="none">
          <ByValueCondition>
            <SimulationTimeCondition value="0"
                                     rule="greaterThan"/>
          </ByValueCondition>
        </Condition>
      </ConditionGroup>
    </StartTrigger>
  </Event>
  <Event name="BrakeEvent" priority="override" maximumExecutionCount="1">
    <Action name="BrakeAction">
      <PrivateAction>
        <LongitudinalAction>
          <SpeedAction>
            <SpeedActionDynamics dynamicsShape="linear"
                                 value="4.0"
                                 dynamicsDimension="rate" />
              <SpeedActionTarget>
                <AbsoluteTargetSpeed value="0" />
              </SpeedActionTarget>
          </SpeedAction>
        </LongitudinalAction>
      </PrivateAction>
    </Action>
    <StartTrigger>
      <ConditionGroup>
        <Condition name="BrakeStartCondition"
                   delay="0"
                   conditionEdge="rising">
          <ByEntityCondition>
            <TriggeringEntities triggeringEntitiesRule="any">
              <EntityRef entityRef="Ego"/>
            </TriggeringEntities>
            <EntityCondition>
              <SpeedCondition value="27.78"
                              rule="greaterOrEqual"/>
            </EntityCondition>
          </ByEntityCondition>
        </Condition>
      </ConditionGroup>
    </StartTrigger>
  </Event>
</Maneuver>

The fully executable scenario is provided in the examples folder as SequentialEvents_0-100-0kph_Implicit.xosc.

10.9.1.2 Explicit sequentialization

The sequence of events may also be enforced by using the elements of storyboard state or storyboard transitions between states as trigger.

  1. The Ego vehicle increases speed from 0 to 100 km/h, starting at simulationTime = 0.

  2. The Ego vehicle brakes to a stop, starting when first event moves into completeState.

The StartTrigger of the brake changes to:

<StartTrigger>
  <ConditionGroup>
    <Condition name="BrakeCondition" delay="0" conditionEdge="rising">
      <ByValueCondition>
        <StoryboardElementStateCondition storyboardElementType="event"
                                         storyboardElementRef="AccelerateEvent"
                                         state="completeState"/>
      </ByValueCondition>
    </Condition>
  </ConditionGroup>
</StartTrigger>

The fully executable scenario is provided in the examples folder as SequentialEvents_0-100-0kph_Explicit.xosc.

10.9.2 Second example

The example shows an Ego vehicle that is speeding up to 20 m/s. At the time it reaches the speed, the red_vehicle should start to catch up with a speed of 30 m/s.

The example shows two instances of Act, each with a ManeuverGroup where Actor are Ego and red_vehicle.

10.9.2.1 Ego setup

The first act starts at the beginning of the simulation. Its ManeuverGroup defines the Ego vehicle as the Actor. An Event starts by increasing the speed with a linear value of 2 m/s. After 10 seconds, Ego vehicle reaches the speed of 20 m/s.

<Act name ="EgoSpeedUpAct">
  <ManeuverGroup maximumExecutionCount="1" name="EgoSpeedUpManeuverGroup">
    <Actors selectTriggeringEntities="false">
      <EntityRef entityRef="Ego"/>
    </Actors>
    <Maneuver name="EgoSpeedUp">
      <Event name="EgoSpeedUpEvent" priority="override">
        <Action name="EgoSpeedUpAction">
          <PrivateAction>
            <LongitudinalAction>
              <SpeedAction>
                <SpeedActionDynamics dynamicsShape="linear"
                                     value="2"
                                     dynamicsDimension="time"/>
                <SpeedActionTarget>
                  <AbsoluteTargetSpeed value="20"/>
                </SpeedActionTarget>
              </SpeedAction>
            </LongitudinalAction>
          </PrivateAction>
        </Action>
        <StartTrigger>
          <ConditionGroup>
            <Condition name="AtSimulationStarts"
                     delay="0"
                     conditionEdge="none">
              <ByValueCondition>
                <SimulationTimeCondition value="0" rule="greaterThan"/>
              </ByValueCondition>
            </Condition>
          </ConditionGroup>
        </StartTrigger>
      </Event>
    </Maneuver>
  </ManeuverGroup>
  <StartTrigger>
    <ConditionGroup>
	  <Condition name="AtSimulationStarts"
			 delay="0"
			 conditionEdge="none">
	    <ByValueCondition>
		  <SimulationTimeCondition value="0" rule="greaterThan"/>
	    </ByValueCondition>
	  </Condition>
    </ConditionGroup>
  </StartTrigger>
</Act>

10.9.2.2 Implicit sequentialization

When synchronizing implicitly, the red_vehicle SpeedAction is applied when Ego is reaching the 20 m/s, as stated in StartTrigger.

<Act name="RedVehicleSpeedUpAct">
  <ManeuverGroup maximumExecutionCount="1"
                 name="RedVehicleSpeedUpManeuverGroup">
    <Actors selectTriggeringEntities="false">
      <EntityRef entityRef="red_vehicle"/>
    </Actors>
    <Maneuver name="RedVehicleSpeedUp">
      <Event name="RedVehicleSpeedUpEvent" priority="override">
        <Action name="RedVehicleSpeedUpAction">
          <PrivateAction>
            <LongitudinalAction>
              <SpeedAction>
                <SpeedActionDynamics dynamicsShape="step"
                                     value="0"
                                     dynamicsDimension="time"/>
                <SpeedActionTarget>
                  <AbsoluteTargetSpeed value="30"/>
                </SpeedActionTarget>
              </SpeedAction>
            </LongitudinalAction>
          </PrivateAction>
        </Action>
        <StartTrigger>
          <ConditionGroup>
            <Condition name="StartOnEgoReachingSpeed"
                       delay="0"
                       conditionEdge="rising">
              <ByEntityCondition>
                <TriggeringEntities triggeringEntitiesRule="any">
                  <EntityRef entityRef="ego"/>
                </TriggeringEntities>
                <EntityCondition>
                  <SpeedCondition value="20"
                                  rule="greaterOrEqual"/>
                </EntityCondition>
              </ByEntityCondition>
            </Condition>
          </ConditionGroup>
        </StartTrigger>
      </Event>
    </Maneuver>
  </ManeuverGroup>
  <StartTrigger>
    <ConditionGroup>
      <Condition name="StartOnEgoReachingSpeed"
                 delay="0"
                 conditionEdge="rising">
        <ByEntityCondition>
	      <TriggeringEntities triggeringEntitiesRule="any">
	        <EntityRef entityRef="ego"/>
	      </TriggeringEntities>
	      <EntityCondition>
	        <SpeedCondition value="20"
                          rule="greaterOrEqual"/>
	      </EntityCondition>
        </ByEntityCondition>
      </Condition>
    </ConditionGroup>
  </StartTrigger>
</Act>

10.9.2.3 Explicit sequentialization

When synchronizing the red_vehicle explicitly, SpeedAction is applied when RedVehicleSpeedUpAction successfully ends, as stated in StartTrigger.

The StartTrigger element now includes a StoryboardElementStateCondition.

<StartTrigger>
  <ConditionGroup>
    <Condition name="StartOnEgoActionEnd"
			 delay="0"
			 conditionEdge="rising">
	  <ByValueCondition>
	    <StoryboardElementStateCondition storyboardElementType="action"
                                         storyboardElementRef="RedVehicleSpeedUpAction"
                                         state="endTransition"
                                         />
	  </ByValueCondition>
    </Condition>
  </ConditionGroup>
</StartTrigger>