| 1 |
NOTE: |
| 2 |
This manual may contain outdated information. For documentation of the most recent features |
| 3 |
refer to |
| 4 |
http://wiki.flightgear.org/index.php/Howto:_Design_an_autopilot |
| 5 |
http://wiki.flightgear.org/index.php/Autopilot_Configuration_Reference |
| 6 |
|
| 7 |
COMMON SETTINGS |
| 8 |
============================================================================== |
| 9 |
|
| 10 |
Currently four types of digital filter implementations are supported. They all serve an |
| 11 |
individual purpose or are individual implementations of a specific filter type. |
| 12 |
Each filter implementation uses the same set of basic configuration tags and individual |
| 13 |
configuration elements. These individual elements are described in the section of the |
| 14 |
filter. |
| 15 |
|
| 16 |
The InputValue |
| 17 |
============================================================================== |
| 18 |
Each filter has several driving values, like the input value itself, sometimes a reference |
| 19 |
value, a gain value and others. Most of these input values can bei either a constant value |
| 20 |
or the value of a property. They all use the same syntax and will be referred to as InputValue |
| 21 |
in the remaining document. |
| 22 |
|
| 23 |
The complete XML syntax for a InputValue is |
| 24 |
|
| 25 |
<some-element> |
| 26 |
<condition> |
| 27 |
<!-- any condition as defined in README.conditions --> |
| 28 |
</condition> |
| 29 |
<property>/some/property/name</property> |
| 30 |
<value>0.0</value> |
| 31 |
<scale>1.0</value> |
| 32 |
<offset>0.0</offset> |
| 33 |
<max>infinity</max> |
| 34 |
<min>-infinity<min> |
| 35 |
<abs>false</abs> |
| 36 |
<period> |
| 37 |
<min>-180.0</min> |
| 38 |
<max>-180.0</max> |
| 39 |
</period> |
| 40 |
</some-element> |
| 41 |
|
| 42 |
The enclosing element <some-element> is the element defined in each filter, like <input>, <u_min>, |
| 43 |
<reference> etc. These elements will be described later. |
| 44 |
The value of the input is calculated based on the given value, scale and offset as |
| 45 |
value * scale + offset |
| 46 |
and the result is clipped to min/max, if given. |
| 47 |
With the full set of given elements, the InputValue will initialize the named property to the value |
| 48 |
given, reduced by the given offset and reverse scaled by the given scale. |
| 49 |
|
| 50 |
Example: |
| 51 |
<input> |
| 52 |
<property>/controls/flight/rudder</property> |
| 53 |
<value>0.0</value> |
| 54 |
<scale>0.5</scale> |
| 55 |
<offset>0.5</offset> |
| 56 |
</input> |
| 57 |
|
| 58 |
Will use the property /controls/flight/rudder as the input of the filter. The property will be initialized |
| 59 |
at a value of zero and since the property usually is in the range [-1..+1], the the value of <input> will |
| 60 |
be in the range (-1)*0.5+0.5 to (+1)*0.5+0.5 which is [0..1]. |
| 61 |
|
| 62 |
The default values for elements not given are: |
| 63 |
<value/> : 0.0 |
| 64 |
<scale/> : 1.0 |
| 65 |
<offset/>: 0.0 |
| 66 |
<property/> : none |
| 67 |
<min/> : unclipped |
| 68 |
<max/> : unclipped |
| 69 |
<abs/> : false |
| 70 |
|
| 71 |
Some examples: |
| 72 |
<input> |
| 73 |
<property>/position/altitude-ft</property> |
| 74 |
<scale>0.3048</scale> |
| 75 |
</input> |
| 76 |
Gives the altitude in meters. No initialization of the property is performed, no offset applied. |
| 77 |
|
| 78 |
<reference> |
| 79 |
<value>0.0</value> |
| 80 |
</reference> |
| 81 |
A constant reference of zero. |
| 82 |
|
| 83 |
A abbreviated method of defining values exist for using a just constant or a property. The above |
| 84 |
example may be written as |
| 85 |
<reference>0.0</reference> |
| 86 |
Or if the reference is defined in a property |
| 87 |
<reference>/some/property/name</reference> |
| 88 |
No initialization, scaling or offsetting is performed here. |
| 89 |
The logic behind this is: If the text node in the element (the text between the opening and closing tag) |
| 90 |
can be converted to a double value, it will be interpreted as a double value. Otherwise the text will |
| 91 |
be interpreted as a property name. |
| 92 |
Examples: |
| 93 |
<reference>3.1415927</reference> - The constant of PI (roughly) |
| 94 |
<reference>/position/altitude-ft</reference> - The property /position/altitude-ft |
| 95 |
<reference>3kings</reference> - The constant 3. The word kings is ignored |
| 96 |
<reference>food4less</reference> - The property food4less |
| 97 |
|
| 98 |
The <property> element may also be written as <prop> for backward compatibility. |
| 99 |
|
| 100 |
There may be one or more InputValues for the same input of a filter which may be bound to conditions. |
| 101 |
Each InputValue will have its condition checked in the order of InputValues given in the configuration |
| 102 |
file. The first InputValue that returns true for its condition will be evaluated. Chaining a number |
| 103 |
of InputValues with conditions and an unconditioned InputValue works like the C language equivalent |
| 104 |
if( condition ) { |
| 105 |
// compute value of first element |
| 106 |
} else if( condition2 ) { |
| 107 |
// compute value of second element |
| 108 |
} else if( condition3 ) { |
| 109 |
// compute value of third element |
| 110 |
} else { |
| 111 |
// compute value of last element |
| 112 |
} |
| 113 |
|
| 114 |
Example: Set the gain to 3.0 if /autopilot/locks/heading equals dg-heading-hold or 2.0 otherwise. |
| 115 |
<digital-filter> |
| 116 |
<gain> |
| 117 |
<condition> |
| 118 |
<equals> |
| 119 |
<property>/autopilot/locks/heading</property> |
| 120 |
<value>dg-heading-hold</value> |
| 121 |
</equals> |
| 122 |
</condition> |
| 123 |
<value>3.0</value> |
| 124 |
<gain> |
| 125 |
<!-- Hint: omit a condition here as a fallthru else condition --> |
| 126 |
</gain> |
| 127 |
<value>2.0</value> |
| 128 |
<gain> |
| 129 |
<digital-filter> |
| 130 |
|
| 131 |
If the element <abs> is used and set to the value "true", only the absolute value of the input |
| 132 |
(the positive part) is used for further computations. The abs function is applied after all |
| 133 |
other computations are completed. |
| 134 |
|
| 135 |
OutputValue |
| 136 |
============================================================================== |
| 137 |
Each filter drives one to many output properties. No scaling or offsetting is implemented |
| 138 |
for the output value, these should be done in the filter itself. |
| 139 |
The output properties are defined in the <output/> element by adding <property/> elements |
| 140 |
within the <output/> element. For just a single output property, the <property/> element |
| 141 |
may be omitted. For backward compatibility, <property/> may be replaced by <prop/>. |
| 142 |
Nonexisting properties will be created with type double. |
| 143 |
|
| 144 |
Example: (Multiple output properties) |
| 145 |
<output> |
| 146 |
<property>/some/output/property</property> |
| 147 |
<property>/some/other/output/property</property> |
| 148 |
<property>/and/another/output/property</property> |
| 149 |
</output> |
| 150 |
|
| 151 |
Example: a single output property |
| 152 |
<output>/just/a/single/property</output> |
| 153 |
|
| 154 |
Other Common Settings |
| 155 |
============================================================================== |
| 156 |
<name> String The name of the filter. Used for debug purpose. |
| 157 |
Example: |
| 158 |
<name>pressure rate filter</name> |
| 159 |
|
| 160 |
<debug> Boolean If true, this filter puts out debug information when updated. |
| 161 |
Example: |
| 162 |
<debug>false</debug> |
| 163 |
|
| 164 |
<input> InputValue The input property driving the filter. |
| 165 |
Refer to InputValue for details. |
| 166 |
|
| 167 |
<reference> InputValue The reference property for filter that need one. |
| 168 |
Refer to InputValue for details. |
| 169 |
|
| 170 |
<output> Complex Each filter can drive one to many output properties. |
| 171 |
Refer to OutputValue for details. |
| 172 |
|
| 173 |
<u_min> InputValue This defines the optional minimum and maximum value the output |
| 174 |
<u_max> is clamped to. If neither <u_min> nor <u_max> exists, the output |
| 175 |
is only limited by the internal limit of double precision float computation. |
| 176 |
If either <u_min> or <u_max> is given, clamping is activated. A missing |
| 177 |
min or max value defaults to 0 (zero). |
| 178 |
Note: <u_min> and <u_max> may also occur within a <config> element. |
| 179 |
<min> and <max> may be used as a substitute for the corresponding u_xxx element. |
| 180 |
<period> Complex Define a periodical input or output value. The phase width is defined by the |
| 181 |
child elements <min> and <max> which are of type InputValue |
| 182 |
|
| 183 |
Example: Limit the pilot's body temperature to a constant minimum of 36 and a maximum defined in |
| 184 |
/pilots/max-body-temperature-degc, initialized to 40.0 |
| 185 |
<u_max> |
| 186 |
<prop>/pilots/max-body-temperature-degc</prop> |
| 187 |
<value>40.0</ |
| 188 |
</u_max> |
| 189 |
<min> |
| 190 |
<value>36.0</value> |
| 191 |
</min |
| 192 |
|
| 193 |
Implicit definition of the minimum value of 0 (zero) and defining a maximum of 100.0 |
| 194 |
<config> |
| 195 |
<u_max>100.0</u_max> |
| 196 |
</config> |
| 197 |
|
| 198 |
This defines the input or output as a periodic value with a phase width of 360, like |
| 199 |
the compass rose. Any value reaching the filter's input or leaving the filter at the |
| 200 |
output will be transformed to fit into the given range by adding or subtracting one phase |
| 201 |
width of 360. Values of -270, 90 or 450 applied to this periodical element will always |
| 202 |
result in +90. A value of 630, 270 or -90 will be normalized to -90 in the given example. |
| 203 |
<period> |
| 204 |
<min>-180.0</min> |
| 205 |
<max>180.0</max> |
| 206 |
</period> |
| 207 |
|
| 208 |
|
| 209 |
<enable> Complex Define a condition to enable or disable the filter. For disabled |
| 210 |
filters, no output computations are performed. Only enabled |
| 211 |
filters fill the output properties. The default for undefined |
| 212 |
conditions is enabled. |
| 213 |
Several way exist to define a condition. The most simple case |
| 214 |
is checking a boolean property. For this, just a <prop> element |
| 215 |
naming this boolean property is needed. The boolean value of the |
| 216 |
named property defines the enabled state of the filter. |
| 217 |
To compare the value of a property with a constant, a <prop> and |
| 218 |
a <value> element define the property name and the value to be |
| 219 |
compared. The filter is enabled, if the value of the property |
| 220 |
equals the given value. A case sensitive string compare is |
| 221 |
performed here. |
| 222 |
To define more complex conditions, a <condition> element may be |
| 223 |
used to define any condition described in README.conditions. |
| 224 |
If a <condition> element is present and if it contains a valid |
| 225 |
condition, this conditions has precedence over a given <prop>/ |
| 226 |
<value> condition. |
| 227 |
The child element <honor-passive>, a boolean flag, may be present |
| 228 |
within the <enable> element. If this element is true, the property |
| 229 |
/autopilot/locks/passive-mode is checked and if it is true, the |
| 230 |
filter output is computed, but the output properties are not set. |
| 231 |
The default for honor-passive is false |
| 232 |
Example: Check a boolean property, only compute this filter if gear-down is true and |
| 233 |
/autopilot/locks/passive-mode is false |
| 234 |
<enable> |
| 235 |
<prop>/gear/gear-down</prop> |
| 236 |
<honor-passive>true</honor-passive> |
| 237 |
</enable> |
| 238 |
|
| 239 |
Check a property for equality, only compute this filter if the autopilot is locked in heading mode. |
| 240 |
<enable> |
| 241 |
<prop>/autopilot/locks/heading</prop> |
| 242 |
<value>dg-heading-hold</value> |
| 243 |
</enable> |
| 244 |
|
| 245 |
Use a complex condition, only compute this filter if the autopilot is serviceable and the lock |
| 246 |
is either dg-heading-hold or nav1-heading-hold |
| 247 |
<enable> |
| 248 |
<condition> |
| 249 |
<property>/autopilot/serviceable</property> |
| 250 |
<or> |
| 251 |
<equals> |
| 252 |
<property>/autopilot/locks/heading</property> |
| 253 |
<value>dg-heading-hold</value> |
| 254 |
</equals> |
| 255 |
<equals> |
| 256 |
<property>/autopilot/locks/heading</property> |
| 257 |
<value>nav1-heading-hold</value> |
| 258 |
</equals> |
| 259 |
</or> |
| 260 |
</condition> |
| 261 |
</enable> |
| 262 |
|
| 263 |
INDIVIDUAL FILTER CONFIGURATION |
| 264 |
============================================================================== |
| 265 |
|
| 266 |
Digital Filter |
| 267 |
|
| 268 |
Six different types of digital filter can be configured inside the autopilot |
| 269 |
configuration file. There are four low-pass filter types and two gain filter |
| 270 |
types. |
| 271 |
|
| 272 |
The low-pass filter types are: |
| 273 |
|
| 274 |
* Exponential |
| 275 |
* Double exponential |
| 276 |
* Moving average |
| 277 |
* Noise spike filter |
| 278 |
|
| 279 |
The gain filter types are: |
| 280 |
|
| 281 |
* gain |
| 282 |
* reciprocal |
| 283 |
|
| 284 |
To add a digital filter, place a <filter> element under the root element. Next to |
| 285 |
the global configuration elements described above, the following elements configure |
| 286 |
the digital filter: |
| 287 |
<filter-time> InputValue This tag is only applicable for the exponential and |
| 288 |
double-exponential filter types. It controls the bandwidth |
| 289 |
of the filter. The bandwidth in Hz of the filter is: |
| 290 |
1/filter-time. So a low-pass filter with a bandwidth of |
| 291 |
10Hz would have a filter time of 1/10 = 0.1 |
| 292 |
|
| 293 |
<samples> InputValue This tag only makes sense for the moving-average filter. |
| 294 |
It says how many past samples to average. |
| 295 |
|
| 296 |
<max-rate-of-change> |
| 297 |
InputValue This tag is applicable for the noise-spike filter. |
| 298 |
It says how much the value is allowed to change per second. |
| 299 |
|
| 300 |
<gain> InputValue This is only applicable to the gain and reciprocal filter types. |
| 301 |
The output for gain filter is computed as input*gain while |
| 302 |
the reciprocal filter computes output as gain/input for input |
| 303 |
values != 0 (zero). Gain may be a constant, a property name |
| 304 |
defined by a <prop> element within the <gain> element or a |
| 305 |
property name initialized to a value by using a <prop> and |
| 306 |
<value> element. |
| 307 |
|
| 308 |
Example: a pressure-rate-filter implemented as a double exponential low pass filter |
| 309 |
with a bandwidth of 10Hz |
| 310 |
|
| 311 |
<filter> |
| 312 |
<name>pressure-rate-filter</name> |
| 313 |
<debug>false</debug> |
| 314 |
<type>double-exponential</type> |
| 315 |
<enable> |
| 316 |
<prop>/autopilot/locks/pressure-rate-filter</prop> |
| 317 |
<value>true</value> |
| 318 |
</enable> |
| 319 |
<input>/autopilot/internal/pressure-rate</input> |
| 320 |
<output>/autopilot/internal/filtered-pressure-rate</output> |
| 321 |
<filter-time>0.1</filter-time> |
| 322 |
</filter> |
| 323 |
|
| 324 |
This will filter the pressure-rate property. The output will be to a new |
| 325 |
property called filtered-pressure-rate. You can select any numerical property |
| 326 |
from the property tree. The input property will not be affected by the filter, |
| 327 |
it will stay the same as it would if no filter was configured. |
| 328 |
|
| 329 |
Example 2: |
| 330 |
|
| 331 |
<filter> |
| 332 |
<name>airspeed elevator-trim gain reciprocal filter</name> |
| 333 |
<debug>false</debug> |
| 334 |
<enable> |
| 335 |
<prop>/autopilot/locks/airspeed-elevator-trim-gain</prop> |
| 336 |
<value>true</value> |
| 337 |
</enable> |
| 338 |
<type>reciprocal</type> |
| 339 |
<gain> |
| 340 |
<prop>/autopilot/settings/elevator-trim-airspeed-reciprocal-gain</prop> |
| 341 |
<value>7</value> |
| 342 |
</gain> |
| 343 |
<input>/velocities/airspeed-kt</input> |
| 344 |
<output>/autopilot/internal/elevator-trim-gain</output> |
| 345 |
<u_min>0.005</u_min> |
| 346 |
<u_max>0.02</u_max> |
| 347 |
</filter> |
| 348 |
|
| 349 |
This will use the /velocities/airspeed-kt property to produce a gain factor |
| 350 |
that reduces as airspeed increases. At airspeeds up to 350kt the gain will |
| 351 |
be clamped to 0.02, at 700kt the gain will be 0.01 and at 1400kt the gain will |
| 352 |
be 0.005. The gain will be clamped to 0.005 for airspeeds > 1400kt. |
| 353 |
|
| 354 |
The output from this filter could then be used to control the gain in a PID |
| 355 |
controller: |
| 356 |
|
| 357 |
<pid-controller> |
| 358 |
<name>Pitch hold</name> |
| 359 |
<debug>false</debug> |
| 360 |
<enable> |
| 361 |
<prop>/autopilot/locks/pitch</prop> |
| 362 |
<value>true</value> |
| 363 |
</enable> |
| 364 |
<input> |
| 365 |
<prop>/orientation/pitch-deg</prop> |
| 366 |
</input> |
| 367 |
<reference> |
| 368 |
<prop>/autopilot/settings/target-pitch-deg</prop> |
| 369 |
</reference> |
| 370 |
<output> |
| 371 |
<prop>/autopilot/internal/target-elevator-trim-norm</prop> |
| 372 |
</output> |
| 373 |
<config> |
| 374 |
<Ts>0.05</Ts> |
| 375 |
<Kp> |
| 376 |
<prop>/autopilot/internal/elevator-trim-gain</prop> |
| 377 |
<value>0.02</value> |
| 378 |
</Kp> |
| 379 |
<beta>1.0</beta> |
| 380 |
<alpha>0.1</alpha> |
| 381 |
<gamma>0.0</gamma> |
| 382 |
<Ti>2.0</Ti> |
| 383 |
<Td>0.2</Td> |
| 384 |
<u_min>-1.0</u_min> |
| 385 |
<u_max>1.0</u_max> |
| 386 |
</config> |
| 387 |
</pid-controller> |
| 388 |
|
| 389 |
IMPORTANT NOTE: The <Kp> tag in PID controllers has been revised to operate in |
| 390 |
the same way as the <gain> elements in filters. However, the original format |
| 391 |
of <Kp> will continue to function as before i.e. <Kp>0.02</Kp> will specify a |
| 392 |
fixed and unalterable gain factor, but a warning message will be output. |
| 393 |
|
| 394 |
The gain type filter is similar to the reciprocal filter except that the gain |
| 395 |
is applied as a simple factor to the input. |
| 396 |
------------------------------------------------------------------------------- |
| 397 |
Parameters |
| 398 |
|
| 399 |
<name> The name of the filter. Give it a sensible name! |
| 400 |
|
| 401 |
<debug> If this tag is set to true debugging info will be printed on the |
| 402 |
console. |
| 403 |
|
| 404 |
<enable> Encloses the <prop> and <value> tags which are used to enable or |
| 405 |
disable the filter. Instead of the <prop> and <value> tags, a <condition> |
| 406 |
tag may be used to define a condition. Check README.conditions for more |
| 407 |
details about conditions. Defaults to enabled if unspecified. |
| 408 |
|
| 409 |
<type> The type of filter. This can be exponential, double-exponential, |
| 410 |
moving-average, noise-spike, gain or reciprocal. |
| 411 |
|
| 412 |
<input> The input property to be filtered. This should of course be a |
| 413 |
numerical property, filtering a text string or a boolean value does not make |
| 414 |
sense. |
| 415 |
|
| 416 |
<output> The filtered value. You can make up any new property. |
| 417 |
|
| 418 |
<u_min> The minimum output value from the filter. Defaults to -infinity. |
| 419 |
|
| 420 |
<u_max> The maximum output value from the filter. Defaults to +infinity. |
| 421 |
|
| 422 |
These are the tags that are applicable to all filter types. The following tags |
| 423 |
are filter specific. |
| 424 |
|
| 425 |
<filter-time> This tag is only applicable for the exponential and |
| 426 |
double-exponential filter types. It controls the bandwidth of the filter. The |
| 427 |
bandwidth in Hz of the filter is: 1/filter-time. So a low-pass filter with a |
| 428 |
bandwidth of 10Hz would have a filter time of 1/10 = 0.1 |
| 429 |
|
| 430 |
<samples> This tag only makes sense for the moving-average filter. It says how |
| 431 |
many past samples to average. |
| 432 |
|
| 433 |
<max-rate-of-change> This tag is applicable for the noise-spike filter. Is |
| 434 |
says how much the value is allowed to change per second. |
| 435 |
|
| 436 |
<gain> This, and it's enclosed <prop> and <value> tags, are only applicable to |
| 437 |
the gain and reciprocal filter types. The <prop> tag specifies a property node |
| 438 |
to hold the gain value and the <value> tag specifies an initial default value. |
| 439 |
The gain defaults to 1.0 if unspecified. |
| 440 |
|
| 441 |
The output from the gain filter type is: input * gain. |
| 442 |
The output from the reciprocal filter type is: gain / input. |
| 443 |
|
| 444 |
The gain can be changed during run-time by updating the value in the property |
| 445 |
node. |
| 446 |
|
| 447 |
<startup-current> If true, internal state is initialized with the current error |
| 448 |
value, which can reduce startup oscillations. Otherwise if false (the default), |
| 449 |
internal state is initialized to zero. |