Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Changes

Jump to: navigation, search

Joystick autopilot bindings

209 bytes added, 21:31, 27 September 2014
m
Minor linguistic improvements
== Introduction ==
Before you start, read [[Input device]] and probably [[Writing Joystick Code: Part 1]].
Autopilots are generally often very useful featuresdevices, but unfortunately there are only standard key bindings for of Flightgear control the `magic autopilot'rather than the simulated real one, and the only way to control popular GA autopilots is by clicking the corresponding buttons in the 3D-cockpit. This is awkward if there is a need to change mode or turn off the autopilot quickly (at final stage of ILS landing, or if the autopilot does something silly). This page describes joystick bindings, which can be used to control the (simulated) autopilot with a set of joystick buttons.Every type of autopilot is operated quite differently, such that these keys only work for specific models. In the current implementation the Here, key bindings work are provided for the [[Bendix/King KAP140 Autopilot]] (in the [[Cessna 172]]) and the [http://www.centuryflight.com/manuals/CENTIII.pdf CENTURY III Autopilot POH] ([[Seneca II]]).Those were prioritised, as the more complex autopilots in jets usually have a dedicated GUI but and therefore maybe less in need of joystick binding. However, it is planned to provide bindings for at least basic functions like AUTOPILOT OFF for other autopilot types in the future.
== Implementation ==
The example code provides a nice setup for six buttons arranged like this (this happens to be suitable for the Thrustmaster T16000M but it can be adapted trivially to other button numbers by simply changing the button numbers in the snippets below. THis is the arrangement of buttons in the T16000M:
4 5 6<br />
9 8 7
(this happens to be suitable for the Thrustmaster T16000M but it can be adapted trivially to other button numbers by simply changing the button numbers in the snippets below).In the following snippets for each functionality are given provided - usually one with the actual binding and some corresponding initialisation code (put placed between nasal tags at the beginning of the script). You need to copy/paste both into your joystick bindings xml file. In the summary the code of all snippets is provided in one code box for convenience but you learn more if you consider each snippet in turn. Generally, it was attempted to have somewhat largely consistent bindings between for the different autopilot types, but because they are operated quite differently, this was not entirely possible, and it was attempted to stay close to the mode of operation of the actual instruments.
=== Generic initialisation code ===
On startup, we need to figure out whether we are dealing with a Bendix KAP 140 or CENTURY II III autopilot.
<syntaxhighlight lang="nasal" >
<nasal>
var horizontalmode=0;
if (getprop("sim/aircraft")=="c172p") {
print("FOUND JOYSTICK INIT: Found KAP140 autopilot");
autopilottype=1;
} elsif (getprop("autopilot/CENTURYIII/power")>-1) {
print("Using JOYSTICK INIT: Found CENTURYIII autopilot joystick binding");
autopilottype=2;
}
=== Horizontal mode selection ===
Button 5 controls the source of course selection in HDG mode(for the LOC and APR modes, the vertical mode is also affected, of course). It works quite differently in the two autopilots:* KAP140: (no modifier) NAV mode: track radial of VOR1 beacon. Press again to go back to follow set heading<br />
(SHIFT) APR mode: track ILS beacon (set radial to runway orientation). If glideslope is approached from below in ALT mode, lock on to localiser <br />
(CTRL) REV mode: track reverse ILS direction<br />
* CENTURYIII: Move mode selector button to the right (clockwise) <br />
(SHIFT) Move mode selector button to the left (anti-clockwise) <br />
Both direction are wrapped, i.e. you can keep pressing the button until you arrive at the selected mode. In turn , the modes selected are: NAV, OMNI, HDG, LOC NORM, LOC REV. Please refer to the CENTURYIII manual for further explanation.
Initialisation:
<syntaxhighlight lang="nasal">
* CENTURYIII: Button 6 smoothly lowers pitch (nose down), button 7 increases pitch (nose up)
The opposite way these buttons work for the two types of autopilot arises from the arrangement in the cockpit. For the CENTURYIII, the pitch is controlled by a wheel, which needs to be moved up to lower the nose (similar to elevator trim wheels), whereas for the KAP140 two buttons are arranged such that the top button increases target VS.
Initialisation:
</button></syntaxhighlight>
=== Horizontal mode direction selector ===
Adjust heading bug (button 8 clockwise and button 9 anti-clockwise).
With modifiers:<br />
(SHIFT) coarse heading bug adjustment<br />
(CTRL) adjust bank angle (CENTURY II III only!)<br />
(ALT) adjust radial of NAV1 (can also be used without autopilot)<br />
</syntaxhighlight>
=== Summary ===
For convenience all of the above bindings are summarised into one file accessible at [http://pastebin.com/2HM9S1df pastebin] (at the time of writing identical to the combination of the snippets above but of course the pastebin might not always keep up with the Wiki - beware)
31
edits

Navigation menu