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