Skip to content

Execution

Arguments and outputs

A mission or aggregate can declare variables in an arguments block and in an output block:

mission Example {
  arguments {
    SampleDepth = 20 meter
  }
  output {
    PeakDepth = NaN meter
  }
  ...
}

On the vehicle, both kinds are handled the same way at runtime: DefineArg and DefineOutput are both processed by Aggregate::defineArg (lrauv-application/Source/missionScript/Aggregate.cpp), creating the same kind of data element (<aggregate>.<name>), which can be assigned and read. A behavior setting reads either kind the same way.

The distinction is one of role:

  • Arguments are the mission's parameters. They are what the mission description (used by TethysDash) exposes, so they are what an operator sees and may set for a mission.

  • Outputs are the mission's internal state. They are not exposed as parameters. The mission can freely assign and read them (in expressions, conditions, behavior settings, etc.), and a behavior can write to them via outputArg:

    behavior Trigger:PeakDetectVsDepth {
      run in parallel
      ...
      outputArg PeakDepth = peakDepth
    }
    

TethysL requires the target of an outputArg to be a declared output, and its source to be an output (OutputURI) of the enclosing behavior.

Reading an output (e.g., as a behavior setting value) is fine and is common in existing missions. See #19 for the related discussion.


Note

  • Feel free to skip the rest of this page if you have not written or dealt with XML mission scripts.
  • The following is about aspects that required some focused investigation toward the correct translation from TethysL to XML according to the LRAUV execution semantics.

Operator precedence in expressions

Consider the 'While' condition expression in the following fragment from the original Insert/Science.xml mission file:

<ReadData Strategy="MinError">
    <While>
        <Arg Name="EnabledNeilBrown"/>
        <Or><Arg Name="EnabledSeabird"/></Or>
        <And><Arg Name="UpwardDerivativeOfTemperatureActive"/></And>
    </While>
    <Universal:upward_derivative_of_sea_water_temperature/>
</ReadData>

Syntactically, this expression looks rather atypical: each of the occurring <Or> and <And> elements only contains a single argument. So, what are the actual operands in each case?

In pseudo-code, the expression above can be directly transliterated as:

EnabledNeilBrown or EnabledSeabird and UpwardDerivativeOfTemperatureActive

Does LRAUV follow the general programming language convention of and having higher precedence than or for evaluation purposes?

According to the following comment in ValueClause.cpp's ValueClause::Instance method, it looks like LRAUV basically performs a left-to-right evaluation without specific attention to operator precedence:

// Order of nodes is LHS [operator RHS0 [operator RHS1 [operator RHS2 ...
// Deal with this as (((LHS operator RHS0) operator RHS1 ) operator RHS2 )

The ValueClause::toString() method also suggests this left-to-right scheme.1

TethysL is currently capturing operator precedence in expressions, including support for any desired parenthesization. So, we need to verify and possibly adjust the conversion to XML so as to preserve the intended evaluation semantics.


  1. Possible revision. In general, to accommodate for unambiguous evaluation order and operator arguments, the XML Schema (along with corresponding LRAUV execution logic) should have probably captured expressions in a more standard way. For example, the case above would be expressed as follows, which, in particular, gives a clear indication of the operands for each operator:

    <While>
      <Or>
        <Arg Name="EnabledNeilBrown"/>
        <And>
          <Arg Name="EnabledSeabird"/>
          <Arg Name="UpwardDerivativeOfTemperatureActive"/>
        </And>
      </Or>
    </While>
    
     ↩