Autopilot configuration reference: Difference between revisions

conditional input values
m (table)
(conditional input values)
Line 54: Line 54:
Input values for controllers may be specified in several notations. Values may be supplied as constants, from properties or by means of simple linear transformations. Conditions allow the selection of one of multiple input sources. The following text will use the <tt>reference</tt> element as an example but it may be substituted by any other input element like <tt>Kp</tt>, <tt>gain</tt> etc. Input values will be interpreted as double values.
Input values for controllers may be specified in several notations. Values may be supplied as constants, from properties or by means of simple linear transformations. Conditions allow the selection of one of multiple input sources. The following text will use the <tt>reference</tt> element as an example but it may be substituted by any other input element like <tt>Kp</tt>, <tt>gain</tt> etc. Input values will be interpreted as double values.


=== A constant value ===
==== A constant value ====
A constant value is defined by just adding the value as text to the input element:  
A constant value is defined by just adding the value as text to the input element:  
  <reference>
  <reference>
Line 63: Line 63:
If the text can be parsed by <tt>strtod()</tt> to a double value, it will be used as a constant value, otherwise it will be interpreted as a property value (see next paragraph)
If the text can be parsed by <tt>strtod()</tt> to a double value, it will be used as a constant value, otherwise it will be interpreted as a property value (see next paragraph)


=== A properties value ===
==== A properties value ====
To evaluate the value of a property, place the name of the property into the text element:
To evaluate the value of a property, place the name of the property into the text element:
  <reference>
  <reference>
Line 74: Line 74:
Properties don't have to exist, the will be created as needed.
Properties don't have to exist, the will be created as needed.


=== Linear transformation of the input value ===
==== Linear transformation of the input value ====
Input values may be scaled and shifted before they are processed by the controller using the formula <tt>y = value * scale + offset</tt>
Input values may be scaled and shifted before they are processed by the controller using the formula <tt>y = value * scale + offset</tt>
To use a celsius temperature property in a controller which expects the temperature in fahrenheit you might use
To use a celsius temperature property in a controller which expects the temperature in fahrenheit you might use
Line 83: Line 83:
  </reference>
  </reference>


=== Input clamping ===
==== Input clamping ====
To clamp the input to a minimum value, maximum value or both, the tags <tt>&lt;min&gt;</tt> and <tt>&lt;max&gt;</tt> can be used. Clamping will occur after the linear transformation has been applied. Note the difference of input clamping to output clamping. While input clamping is applied '''before''' the signal reaches the controller, output clamping will be applied to the output signal '''after''' it has been processed.
To clamp the input to a minimum value, maximum value or both, the tags <tt>&lt;min&gt;</tt> and <tt>&lt;max&gt;</tt> can be used. Clamping will occur after the linear transformation has been applied. Note the difference of input clamping to output clamping. While input clamping is applied '''before''' the signal reaches the controller, output clamping will be applied to the output signal '''after''' it has been processed.
The following code will keep the input to the controller in the range of 60 to 80 degrees Fahrenheit:
The following code will keep the input to the controller in the range of 60 to 80 degrees Fahrenheit:
Line 94: Line 94:
  </reference>
  </reference>


=== Absolute values ===
==== Absolute values ====
To use the absolute value of the input, add <tt>&lt;abs type="bool"&gt;true&lt;/abs&gt;</tt>.
To use the absolute value of the input, add <tt>&lt;abs type="bool"&gt;true&lt;/abs&gt;</tt>.
  <reference>
  <reference>
Line 101: Line 101:
  </reference>
  </reference>


=== Recursive definition ===
==== Recursive definition ====
The elements <tt>&lt;scale&gt;</tt>, <tt>&lt;offset&gt;</tt>, <tt>&lt;min&gt;</tt> and <tt>&lt;max&gt;</tt> itself can be defined as input values. This code uses as reference the value of course-error-deg, scaled by two and an offset applied which is calculated as the product of the bank-angle-de and the property some/property which itself is limited within the range of -1.5 .. +1.5.
The elements <tt>&lt;scale&gt;</tt>, <tt>&lt;offset&gt;</tt>, <tt>&lt;min&gt;</tt> and <tt>&lt;max&gt;</tt> itself can be defined as input values. This code uses as reference the value of course-error-deg, scaled by two and an offset applied which is calculated as the product of the bank-angle-de and the property some/property which itself is limited within the range of -1.5 .. +1.5.
  <reference>
  <reference>
Line 115: Line 115:
   </offset>
   </offset>
  </reference>
  </reference>
==== Conditional Input Values ====
The direct inputs of controller and filter elements support so called input value lists. This is useful, if the input should be connected to one of many separate inputs like autopilots connected to NAV1, NAV2 or the GPS. The well known <tt>&lt;condition&gt;</tt> element is allowed within an input value element. The input value list will be traversed until the first input value with a successful condition is found. The behavior is much like the switch statement in programming languages.
<reference>
  <condition>
    <property>/autopilot/coupled-to-gps</property>
  </condition>
  <property>instrumentation/gps/desired-track-deg</property>
</reference>
<reference>
  <condition>
    <property>/autopilot/coupled-to-nav2</property>
  </condition>
  <property>instrumentation/nav[1]/radials/selected-deg</property>
</reference>
<reference>instrumentation/nav[0]/radials/selected-deg</reference>
Note the unconditional last <tt>&lt;reference<&gt;</tt> element which acts as an "if all others fail, use NAV1" anchor. If no input value return with a successful condition, the input value is undefined.<br />
The <tt>&lt;scale&gt;</tt>, <tt>&lt;offset&gt;</tt>, <tt>&lt;min&gt;</tt> and <tt>&lt;max&gt;</tt> elements of input values itself currently don't support input value lists.


=== Output Values ===
=== Output Values ===