Autopilot configuration reference: Difference between revisions

(→‎pid-controller: Chang formatting to use a definition list.)
Line 52: Line 52:


=== Input Values ===
=== Input 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 is defined by just adding the value as text to the input element:
<reference>
  <value>3.5</value>
</reference>
The shortcut syntax is also valid:
<reference>3.5</reference>
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 ===
To evaluate the value of a property, place the name of the property into the text element:
<reference>
  <property>/my/property</property>
</reference>
The shortcut syntax is also valid:
<reference>/my/property</reference>
Note: the shortcut syntax is only valid, if no &lt;property&gt; '''and''' no &lt;value&gt; element exist.
=== 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>
To use a celsius temperature property in a controller which expects the temperature in fahrenheit you might use
<reference>
  <property>/environment/temperature-degc</property>
  <scale>1.8</scale>
  <offset>32</offset>
</reference>
=== 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.
The following code will keep the input to the controller in the range of 60 to 80 degrees Fahrenheit:
<reference>
  <property>/environment/temperature-degc</property>
  <scale>1.8</scale>
  <offset>32</offset>
  <min>60</min>
  <max>80</max>
</reference>
=== Absolute values ===
To use the absolute value of the input, add <tt>&lt;abs type="bool"&gt;true&lt;/abs&gt;</tt>.
<reference>
  <property>/autopilot/internal/course-error-deg</property>
  <abs type="bool">true</abs>
</reference>
=== 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.
<reference>
  <property>/autopilot/internal/course-error-deg</property>
  <scale>2.0</scale>
  <offset>
    <property>orientation/bank-angle-deg</property>
    <scale>
      <property>some/property
      <min>-1.5</min>
      <max>1.5</max>
    </scale>
  </offset>
</reference>


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