Clarify start time of simulation
Describe the problem
OpenSCENARIO defines no explicit rules whether simulation must start at t=0 or may start at t>0. However most of the official examples only seem to work when the conditions are first checked in t=0.
Describe your research
Most OSC 1.x examples use a SimulationTimeCondition
with rising
edge and time > 0
:
<StartTrigger>
<ConditionGroup>
<Condition name="C1" delay="0" conditionEdge="rising">
<ByValueCondition>
<SimulationTimeCondition value="0" rule="greaterThan"/>
</ByValueCondition>
</Condition>
</ConditionGroup>
</StartTrigger>
The user guide explains:
The first time a condition defined with edge is checked, there is no information about previous evaluations of its logical expression. At runtime, a condition defined with edge shall always evaluate to false, the first time it is checked
This works well if the implementation starts evaluating the condition at t=0
. The condition will trigger exactly once in the second simulation step (e.g. t=1ms):
t=0:
- Condition C1 is checked
- The internal logical condition `t>0` evaluates to false. The result is stored internally for the next timestep
- Since C1 has a rising edge defined and this is the first iteration, the overall condition evaluates to false regardless of the previous line
t=1ms:
- Condition C1 is checked
- The internal logical condition `t>0` evaluates to true. The result is stored internally for the next timestep
- The internally stored result from last time was false, now the result is true. A rising edge is detected
- Since C1 has a rising edge defined, the overall condition evaluates to true
t=2ms:
- Condition C1 is checked
- The internal logical condition `t>0` evaluates to true. The result is stored internally for the next timestep
- The internally stored result from last time was true and now the result is also true, there is no edge detected
- Since C1 has a rising edge defined and no edge was detected, the overall condition evaluates to false
If the implementation however starts evaluating conditions at t>0
, the condition will never trigger:
t=1ms:
- Condition C1 is checked
- The internal logical condition `t>0` evaluates to true. The result is stored internally for the next timestep
- Since C1 has a rising edge defined and this is the first iteration, the overall condition evaluates to false regardless of the previous line
t=2ms:
- Condition C1 is checked
- The internal logical condition `t>0` evaluates to true. The result is stored internally for the next timestep
- The internally stored result from last time was true and now the result is also true, there is no edge detected
- Since C1 has a rising edge defined and no edge was detected, the overall condition evaluates to false
t=3ms:
- Condition C1 is checked
- The internal logical condition `t>0` evaluates to true. The result is stored internally for the next timestep
- The internally stored result from last time was true and now the result is also true, there is no edge detected
- Since C1 has a rising edge defined and no edge was detected, the overall condition evaluates to false
Ask your question
- Is my interpretation of the edge-checking behavior correct?
- Are implementations required to check conditions in
t=0
?- If yes: Please state this explicitly in the user guide
- If no: Please adjust the examples so that they are compatible with implementations that start at
t>0