# DeltaGlider: Atmospheric Autopilot

The Delta-glider is equipped with an atmospheric autopilot to control flight parameters during atmospheric flight, including

- altitude
- airspeed.
- bank angle

The autopilot can be accessed via the ScriptMFD mode. This help file can be accessed from the script command line with
help(dg_aap)

## Loading the autopilot

The atmospheric autopilot is automatically loaded when activating the Script-MFD mode from one of the glider's multifunctional displays. If you want to run the autopilot from an external script console, it has to be loaded manually with
run('dg/aap')

## Function reference

aap.alt (tgtalt) | Engage altitude autopilot, or reset target altitude.
aap.alt () | Disengage altitude autopilot.
aap.spd (tgtspd) | Engage airspeed autopilot, or reset target speed.
aap.spd () | Disengage airspeed autopilot.
aap.bank (tgtbnk) | Engage bank angle autopilot, or reset target bank angle.
aap.bank () | Disengage bank angle autopilot.
aap.hdg (tgthdg) | Engage heading autopilot, or reset target heading.
aap.hdg () | Disengage heading autopilot.

## Autopilot functions

### Altitude autopilot mode

The altitude autopilot can be invoked with
aap.alt(tgtalt)
where tgtalt defines the target altitude [m]. If the altitude autopilot was active already, this command simply resets the target altitude.

The altitude autopilot can be disabled by

aap.alt()

### Airspeed autopilot mode

The airspeed autopilot can be invoked with
aap.spd(tgtspd)
where tgtspd defines the target airspeed [m/s]. If the airspeed autopilot was active already, this command simply resets the target airspeed.

The airspeed autopilot can be disabled by

aap.spd()

### Bank autopilot mode

The bank autopilot can be invoked with
aap.bank(tgtbank)
where tgtbank defines the target bank angle [deg]. tgtbank > 0 indicates left bank, tgtbank < 0 indicates right bank. If the bank autopilot was active already, this command simply resets the target bank angle.

The bank autopilot can be disabled with

aap.bank()

### Heading autopilot mode

The heading autopilot can be invoked with
aap.hdg(tgthdg)
where 0 ≤ tgthdg ≤ 360 defines the target heading angle [deg]. In the current implementation, the heading autopilot invokes both a bank and an altitude subfunction. Any existing bank and altitude modes will therefore be overridden. The function can be invoked again to modify the heading.

The heading autopilot can be disabled with

aap.hdg()

## Low-level access

The following parameters in the aap table may be re-defined to modify the behaviour of the autopilot.

aap.tgtalt | Target altitude [m]. The value of this parameter is set by aap.alt(tgtalt). Overriding it while the altitude autopilot is active will reset the target altitude.
aap.tgtspd | Target airspeed [m/s]. The value of this parameter is set by aap.spd(tgtspd). Overriding it while the airspeed autopilot is active will reset the target airspeed.
aap.tgtbnk | Target bank angle [deg]. The value of this parameter is set by aap.bank(tgtbnk). Overriding it while the bank autopilot is active will reset the target bank angle.
aap.maxasc | Max. ascent slope [deg] (> 0) used by the altitude autopilot during altitude transistions. Default value = +30
aap.maxdsc | Max. descent slope [deg] (< 0) used by the altitude autopilot during altitude transitions. Default value = -20