# An A Quadcopter Autopilot Based on an Adaptive Digital PID Controller

Joonghyun Lee, John Spencer, Siyuan Shao, Juan Augusto Paredes, Dennis S.
Bernstein, Ankit Goel This research was supported in part by the Office of
Naval Research under grant N00014-19-1-2273.Joonghyun Lee, John Spencer,
Siyuan Shao, Juan Augusto Paredes, and Dennis S. Bernstein are with the
Department of Aerospace Engineering, University of Michigan, Ann Arbor, MI
48109. joonghle, spjohn, shaosy<EMAIL_ADDRESS>Goel is with
the Department of Mechanical Engineering, University of Maryland, Baltimore
County, MD 21250<EMAIL_ADDRESS>
# Adaptive Digital PID Control of a Quadcopter

Joonghyun Lee, John Spencer, Siyuan Shao, Juan Augusto Paredes, Dennis S.
Bernstein, Ankit Goel This research was supported in part by the Office of
Naval Research under grant N00014-19-1-2273.Joonghyun Lee, John Spencer,
Siyuan Shao, Juan Augusto Paredes, and Dennis S. Bernstein are with the
Department of Aerospace Engineering, University of Michigan, Ann Arbor, MI
48109. joonghle, spjohn, shaosy<EMAIL_ADDRESS>Goel is with
the Department of Mechanical Engineering, University of Maryland, Baltimore
County, MD 21250<EMAIL_ADDRESS>
# Retrospective-Cost-Based Adaptive Digital PID Control of a Quadcopter

Joonghyun Lee, John Spencer, Siyuan Shao, Juan Augusto Paredes, Dennis S.
Bernstein, Ankit Goel This research was supported in part by the Office of
Naval Research under grant N00014-19-1-2273.Joonghyun Lee, John Spencer,
Siyuan Shao, Juan Augusto Paredes, and Dennis S. Bernstein are with the
Department of Aerospace Engineering, University of Michigan, Ann Arbor, MI
48109. joonghle, spjohn, shaosy<EMAIL_ADDRESS>Goel is with
the Department of Mechanical Engineering, University of Maryland, Baltimore
County, MD 21250<EMAIL_ADDRESS>
# A Retrospective-Cost-Based Adaptive Digital PID Quadcopter Autopilot

Joonghyun Lee, John Spencer, Siyuan Shao, Juan Augusto Paredes, Dennis S.
Bernstein, Ankit Goel This research was supported in part by the Office of
Naval Research under grant N00014-19-1-2273.Joonghyun Lee, John Spencer,
Siyuan Shao, Juan Augusto Paredes, and Dennis S. Bernstein are with the
Department of Aerospace Engineering, University of Michigan, Ann Arbor, MI
48109. joonghle, spjohn, shaosy<EMAIL_ADDRESS>Goel is with
the Department of Mechanical Engineering, University of Maryland, Baltimore
County, MD 21250<EMAIL_ADDRESS>
# Adaptive Digital PID Control of a Quadcopter with Unknown Dynamics

Joonghyun Lee, John Spencer, Siyuan Shao, Juan Augusto Paredes, Dennis S.
Bernstein, Ankit Goel This research was supported in part by the Office of
Naval Research under grant N00014-19-1-2273.Joonghyun Lee, John Spencer,
Siyuan Shao, Juan Augusto Paredes, and Dennis S. Bernstein are with the
Department of Aerospace Engineering, University of Michigan, Ann Arbor, MI
48109. joonghle, spjohn, shaosy<EMAIL_ADDRESS>Goel is with
the Department of Mechanical Engineering, University of Maryland, Baltimore
County, MD 21250<EMAIL_ADDRESS>
# One-Shot Learning for a Quadcopter Autopilot

Joonghyun Lee, John Spencer, Siyuan Shao, Juan Augusto Paredes, Dennis S.
Bernstein, Ankit Goel This research was supported in part by the Office of
Naval Research under grant N00014-19-1-2273.Joonghyun Lee, John Spencer,
Siyuan Shao, Juan Augusto Paredes, and Dennis S. Bernstein are with the
Department of Aerospace Engineering, University of Michigan, Ann Arbor, MI
48109. joonghle, spjohn, shaosy<EMAIL_ADDRESS>Goel is with
the Department of Mechanical Engineering, University of Maryland, Baltimore
County, MD 21250<EMAIL_ADDRESS>
# An adaptive digital autopilot for Multicopters

Joonghyun Lee, John Spencer, Siyuan Shao, Juan Augusto Paredes, Dennis S.
Bernstein, Ankit Goel This research was supported in part by the Office of
Naval Research under grant N00014-19-1-2273.Joonghyun Lee, John Spencer,
Siyuan Shao, Juan Augusto Paredes, and Dennis S. Bernstein are with the
Department of Aerospace Engineering, University of Michigan, Ann Arbor, MI
48109. joonghle, spjohn, shaosy<EMAIL_ADDRESS>Goel is with
the Department of Mechanical Engineering, University of Maryland, Baltimore
County, MD 21250<EMAIL_ADDRESS>
# Experimental Implementation of an Adaptive Digital Autopilot with
Applications

Joonghyun Lee, John Spencer, Siyuan Shao, Juan Augusto Paredes, Dennis S.
Bernstein, Ankit Goel This research was supported in part by the Office of
Naval Research under grant N00014-19-1-2273.Joonghyun Lee, John Spencer,
Siyuan Shao, Juan Augusto Paredes, and Dennis S. Bernstein are with the
Department of Aerospace Engineering, University of Michigan, Ann Arbor, MI
48109. joonghle, spjohn, shaosy<EMAIL_ADDRESS>Goel is with
the Department of Mechanical Engineering, University of Maryland, Baltimore
County, MD 21250<EMAIL_ADDRESS>
# An Adaptive Digital Autopilot with Applications
for Fixed-wing Aircraft Control

Joonghyun Lee, John Spencer, Siyuan Shao, Juan Augusto Paredes, Dennis S.
Bernstein, Ankit Goel This research was supported in part by the Office of
Naval Research under grant N00014-19-1-2273.Joonghyun Lee, John Spencer,
Siyuan Shao, Juan Augusto Paredes, and Dennis S. Bernstein are with the
Department of Aerospace Engineering, University of Michigan, Ann Arbor, MI
48109. joonghle, spjohn, shaosy<EMAIL_ADDRESS>Goel is with
the Department of Mechanical Engineering, University of Maryland, Baltimore
County, MD 21250<EMAIL_ADDRESS>
# An Adaptive Digital Autopilot
for Fixed-Wing Aircraft with Actuator Faults

Joonghyun Lee, John Spencer, Siyuan Shao, Juan Augusto Paredes, Dennis S.
Bernstein, Ankit Goel This research was supported in part by the Office of
Naval Research under grant N00014-19-1-2273.Joonghyun Lee, John Spencer,
Siyuan Shao, Juan Augusto Paredes, and Dennis S. Bernstein are with the
Department of Aerospace Engineering, University of Michigan, Ann Arbor, MI
48109. joonghle, spjohn, shaosy<EMAIL_ADDRESS>Goel is with
the Department of Mechanical Engineering, University of Maryland, Baltimore
County, MD 21250<EMAIL_ADDRESS>
# Experimental Flight Testing of a
Fault-Tolerant Adaptive Autopilot for Fixed-Wing Aircraft

Joonghyun Lee, John Spencer, Siyuan Shao, Juan Augusto Paredes, Dennis S.
Bernstein, Ankit Goel This research was supported in part by the Office of
Naval Research under grant N00014-19-1-2273.Joonghyun Lee, John Spencer,
Siyuan Shao, Juan Augusto Paredes, and Dennis S. Bernstein are with the
Department of Aerospace Engineering, University of Michigan, Ann Arbor, MI
48109. joonghle, spjohn, shaosy<EMAIL_ADDRESS>Goel is with
the Department of Mechanical Engineering, University of Maryland, Baltimore
County, MD 21250<EMAIL_ADDRESS>
###### Abstract

This paper presents an adaptive autopilot for fixed-wing aircraft and compares
its performance with a fixed-gain autopilot. The adaptive autopilot is
constructed by augmenting the autopilot architecture with adaptive control
laws that are updated using retrospective cost adaptive control. In order to
investigate the performance of the adaptive autopilot, the default gains of
the fixed-gain autopilot are scaled to degrade its performance. This scenario
provides a venue for determining the ability of the adaptive autopilot to
compensate for the degraded fixed-gain autopilot. Next, the performance of the
adaptive autopilot is examined under failure conditions by simulating a
scenario where one of the control surfaces is assumed to be stuck at an
unknown angle. The adaptive autopilot is also tested in physical flight
experiments under degraded-nominal conditions, and the resulting performance
improvement is examined.

##  I Introduction

Autonomous flight control of an aircraft under rapidly changing conditions
requires an autopilot that can control the aircraft in uncertain environments
and without detailed models. An autopilot for a fixed-wing aircraft typically
consists of a set of trim commands along with low-level controllers to follow
intermediate commands. The trim conditions for an aircraft can be computed by
solving nonlinear algebraic equations for trim equilibria [1], but a detailed
model of the aircraft aerodynamics is required. Moreover, for low-cost
aircraft that are usually repaired or modified onsite, the true aerodynamic
properties may be different from nominal aerodynamics. Consequently, a fixed-
gain autopilot may not be able to maintain performance in a rapidly changing
environment or under failure conditions such as damaged wings or faulty
actuators. In this scenario, an adaptive autopilot may be able to compensate
for the lost performance by updating the autopilot gains accordingly. With
these motivations in mind, this paper explores the use of an in situ learning
technique to modify the autopilot during the flight.

Various adaptive control techniques have been investigated for fixed-wing
aircraft control [2]. A sliding mode fault-tolerant tracking control scheme
was used for control of a fixed-wing UAV under actuator saturation and state
constraints in [3, 4]. A backstepping algorithm was used in [5] to design a
nonlinear flight controller for a fixed-wing UAV with thrust vectoring. An
MRAC-based technique was used to augment the control system to improve the
dynamic performance of a fixed-wing aircraft in [6]. However, these techniques
rely on the availability of a sufficiently detailed model for the control
system synthesis.

In contrast, the present paper uses the retrospective cost adaptive control
(RCAC) algorithm to learn the autopilot gains from the measured data in situ.
RCAC is a digital adaptive control technique that is applicable to
stabilization, command following, and disturbance rejection. Instead of
relying on a model of the system, RCAC uses the past measured data and past
applied input to recursively optimize the controller gains. RCAC is described
in [7], and its extension to digital PID control is given in [8]. The
application of RCAC for a multicopter autopilot are described in [9, 10].

The contribution of this paper is the development of an adaptive autopilot for
fixed-wing aircraft, and a comparison of its performance with a well-tuned
fixed-gain autopilot under nominal conditions, performance recovery of a
degraded-nominal autopilot, and performance improvement under actuator
failure. In particular, this paper presents the potential advantages of an
adaptive autopilot by investigating two scenarios. In the first scenario, a
well-tuned fixed-gain controller is degraded by scaling all of the gains by a
small factor, and it is shown that the adaptive autopilot is able to
compensate for the degraded gains by learning the necessary gains. This
scenario is investigated both in simulation and in physical flight
experiments. In the second scenario, the aircraft is simulated with a faulty
aileron, thus emulating an actuator failure condition, and it is shown, in
simulation experiments, that the adaptive autopilot improves the trajectory-
tracking performance.

The paper is organized as follows: Section II defines the notation used in
this paper, Section III reviews the autopilot architecture implemented in the
PX4 flight stack, Section IV presents the adaptive augmentation of autopilot,
Section V presents the simulation flight tests, and Section V presents the
outdoor flight tests. Finally, Section VII concludes the paper with a summary
and future research directions.

##  II Notation

Let $\rm F_{E}$ denote an Earth-fixed frame such that ${\hat{k}}_{\rm E}$ is
aligned with the acceleration due to gravity $\overset{\rightharpoonup}{g}.$
Let $\rm F_{AC}$ denote an aircraft-fixed frame such that ${\hat{\imath}}_{\rm
AC}$ is aligned with the fuselage, ${\hat{\jmath}}_{\rm AC}$ is along the
wing, and ${\hat{k}}_{\rm AC}$ is chosen to complete the right-handed frame.
Note that ${\hat{k}}_{\rm AC}$ points vertically down. Next, let ${\rm c}$
denote the center of mass of the aircraft, and let $w$ be an point fixed on
Earth. The coordinates of the aircraft relative to $w$ in the Earth frame are
denoted by
$r\stackrel{{\scriptstyle\triangle}}{{=}}\overset{\rightharpoonup}{r}_{{\rm
c}/w}{\big{|}_{\rm E}}\in{\mathbb{R}}^{3}.$ The velocity of the aircraft
relative to $w$ in the Earth frame is
$v\stackrel{{\scriptstyle\triangle}}{{=}}\overset{\rightharpoonup}{v}_{{\rm
c}/w/{\rm E}}{\big{|}_{\rm E}}\in{\mathbb{R}}^{3}.$ Let $\Psi$, $\Theta,$ and
$\Phi$ denote the 3-2-1 azimuthal, elevation, and bank Euler angles of the
aircraft. The angular velocity of $\rm F_{AC}$ relative to $\rm F_{E}$ in the
aircraft-fixed frame is given by
$\omega\stackrel{{\scriptstyle\triangle}}{{=}}\overset{\rightharpoonup}{\omega}_{{\rm
AC}/{\rm E}}{\big{|}_{\rm\rm AC}}\in{\mathbb{R}}^{3}.$ The angular
acceleration of $\rm F_{AC}$ relative to $\rm F_{E}$ in the aircraft-fixed
frame is given by
$\alpha\stackrel{{\scriptstyle\triangle}}{{=}}\overset{\rightharpoonup}{\alpha}_{{\rm
AC}/{\rm E}}{\big{|}_{\rm\rm AC}}\in{\mathbb{R}}^{3}.$ The measurement of the
variable $x$ is denoted by $x_{\rm m}$, and the setpoint for the variable $x$
is denoted by $x_{\rm s}.$ Finally, let
$e_{3}\stackrel{{\scriptstyle\triangle}}{{=}}\left[\begin{array}[]{c c
c}0&0&1\end{array}\right]^{{\rm T}}.$

The angles $\Psi,$ $\Theta,$ and $\Phi$ comprise a 3-2-1 sequence of Euler
angles that parameterize the orientation of $\rm F_{AC}$ relative to $\rm
F_{E}.$ The components of $\omega$ are the yaw rate, pitch rate, and roll
rate, which are different from the azimuth rate, elevation rate, and bank
rate. Hence, integrating the components of $\omega$ does not yield the
azimuthal, elevation, and bank Euler angles. In fact, the relation between the
Euler-angle rates and the components of $\omega$ is given by (4) in the
following section.

##  III Flight Control Architecture

In this work, we consider the flight control architecture implemented in the
PX4 flight stack. The control system consists of a mission planner and two
cascaded controllers in nested loops as shown in Figure 1. The mission planner
generates position setpoints based on user-defined waypoints.

Mission Planner Position Controller Attitude Controller Fixed-Wing Aircraft
$r_{\rm s},V_{{\rm T},{\rm s}}$$\begin{array}[]{c}\Phi_{{\rm s}},\\\
\Theta_{{\rm s}}\end{array}$$T_{\rm s}$$\alpha_{{\rm s}}$$r_{{\rm m}},V_{{\rm
T}},V_{{\rm G}}$$\Phi_{{\rm m}},\Theta_{{\rm m}},V_{{\rm T}},V_{{\rm
I}},\omega_{{\rm m}}$$V_{{\rm G}}$

Figure 1: Autopilot architecture.

The outer loop, also called the position controller, consists of two decoupled
controllers for the longitudinal and lateral motion of the aircraft, as shown
in Figure 2. The longitudinal controller is based on the total energy control
system (TECS) described in [11, 12, 13, 14], and the lateral controller is
based on the guidance law described in [15]. The inputs to the position
controller are the true airspeed setpoint $V_{{\rm T},{\rm s}},$ the position
setpoint $r_{\rm s},$ the true airspeed $V_{{\rm T}},$ the position
measurement $r_{\rm m},$ and the ground velocity $V_{{\rm G}}.$ The TECS input
includes the altitude setpoint $h_{\rm
s}\stackrel{{\scriptstyle\triangle}}{{=}}e_{3}^{\rm T}r_{\rm s}$ and the
altitude measurement $h_{\rm
m}\stackrel{{\scriptstyle\triangle}}{{=}}e_{3}^{\rm T}r_{\rm m}.$ The
longitudinal controller generates the thrust and the elevation setpoint, and
the lateral controller generates the bank setpoint. The output of the position
controller is thus the thrust setpoint $T_{\rm s}$ and the attitude setpoint
$\Psi_{\rm s},\Theta_{\rm s},\Phi_{\rm s}.$

$\begin{array}[]{c}{\rm Longitudinal}\\\ {\rm Controller}\\\
{\rm(TECS)}\end{array}$$\begin{array}[]{c}{\rm Lateral}\\\ {\rm
Controller}\end{array}$$e_{3}^{\rm T}$$e_{3}^{\rm T}$$h_{{\rm s}}$$h_{{\rm
m}}$$r_{\rm s}$$r_{\rm m}$$V_{{\rm T},{\rm s}}$$V_{{\rm T}}$$V_{{\rm
G}}$$T_{{\rm s}}$$\Theta_{{\rm s}}$$\Phi_{{\rm s}}$

Figure 2: Position controller architecture.

The inner loop, also called the attitude controller, consists of two cascaded
controllers, as shown in Figure 3. The first controller uses the elevation and
bank errors and a proportional control law to generate the elevation-rate and
bank-rate setpoints. In particular, the elevation-rate setpoint
$\dot{\Theta}_{{\rm s}}$ and the bank-rate setpoint $\dot{\Phi}_{{\rm s}}$ are
given by

$\displaystyle\dot{\Theta}_{{\rm s}}$ $\displaystyle=k_{\theta}(\Theta_{{\rm
s}}-\Theta_{{\rm m}}),$ (1) $\displaystyle\dot{\Phi}_{{\rm s}}$
$\displaystyle=k_{\phi}(\Phi_{{\rm s}}-\Phi_{{\rm m}}),$ (2)

where $k_{\theta},k_{\phi}$ are the scalar gains. The azimuthal-rate is
algebraically given by

$\displaystyle\dot{\Psi}_{{\rm s}}=\frac{g\tan\Phi_{{\rm s}}\cos\Theta_{{\rm
s}}}{V_{{\rm T}}}$ (3)

to ensure coordinated turn. Finally, the body-fixed angular-velocity setpoint
$\omega_{\rm s}$ is given by

$\displaystyle\omega_{\rm s}$ $\displaystyle=S(\Theta_{{\rm m}},\Phi_{{\rm
m}})\begin{bmatrix}\dot{\Phi}_{{\rm s}}\\\ \dot{\Theta}_{{\rm s}}\\\
\dot{\Psi}_{{\rm s}}\end{bmatrix},$ (4)

where

$\displaystyle S(\Theta_{{\rm m}},\Phi_{{\rm
m}})\stackrel{{\scriptstyle\triangle}}{{=}}\begin{bmatrix}1&0&\sin\Theta_{{\rm
m}}\\\ 0&\cos\Phi_{{\rm m}}&\sin\Phi_{{\rm m}}\cos\Theta_{{\rm m}}\\\
0&-\sin\Phi_{{\rm m}}&\cos\Phi_{{\rm m}}\cos\Theta_{{\rm m}}\end{bmatrix}.$
(5)

Next, a feedforward and a PI control law generates the angular-acceleration
setpoint $\alpha_{s}$. In particular, $\alpha_{s}$ is given by

$\displaystyle\alpha_{s}$ $\displaystyle=\frac{V_{{\rm T},0}}{V_{{\rm
T}}}G_{\omega,{\rm ff}}\omega_{\rm s}+\left(\frac{V_{{\rm I},0}}{V_{{\rm
I}}}\right)^{2}G_{\omega,{\rm PI}}({\textbf{{q}}})\left(\omega_{\rm
s}-\omega_{\rm m}\right),$ (6)

where $G_{\omega,{\rm ff}}=k_{\omega,\rm ff}$ is a proportional control law,
$G_{\omega,{\rm PI}}({\textbf{{q}}})=k_{\omega,{\rm P}}+\dfrac{k_{\omega,{\rm
I}}}{\textbf{q}-1}$ is a PI control law, $V_{{\rm I}}$ is the indicated
airspeed, and $V_{{\rm T},0}$ and $V_{{\rm I},0}$ are the true airspeed and
the indicated airspeed at trim conditions respectively, which are aircraft
parameters. Note that q is the forward-shift operator, $k_{\omega,\rm ff},$
$k_{\omega,\rm P},$ and $k_{\omega,\rm I}$ are $3\times 3$ diagonal matrices,
and are thus parameterized by 9 scalar gains. Finally, using the angular-
acceleration setpoint, the actuator deflections are computed using control
allocation methods.

(4)(1), (2)(3)$+$$+$$G_{\omega,{\rm PI}}$$G_{\omega,{\rm
FF}}$(6)$\alpha_{s}$$\begin{bmatrix}\dot{\Phi}_{{\rm s}}\\\ \dot{\Theta}_{{\rm
s}}\end{bmatrix}$$\dot{\Psi}_{{\rm s}}$$V_{{\rm m}}$$\begin{bmatrix}\Phi_{{\rm
s}}\\\ \Theta_{{\rm s}}\end{bmatrix}$$\begin{bmatrix}\Phi_{{\rm m}}\\\
\Theta_{{\rm m}}\end{bmatrix}$$-$$\omega_{{\rm s}}$$\omega_{{\rm
m}}$$-$$V_{{\rm T}},V_{{\rm I}}$

Figure 3: Attitude controller architecture.

The fixed-wing autopilot thus consists of 11 gains. In practice, these 11
gains are tuned manually, which requires considerable expertise. We assume
that the default gains implemented in PX4 are well tuned, and thus we refer to
the autopilot with the default PX4 gains as the nominal autopilot.

To investigate potential improvements and demonstrate the ability of the
adaptive autopilot to recover performance, the gains in the nominal autopilot
are multiplied by a scalar $\alpha_{\rm d}$ in order to degrade its
performance. A fixed-gain autopilot with the degradation factor $\alpha_{\rm
d}\neq 1$ is referred to as the degraded-nominal autopilot. Note that
$\alpha_{\rm d}\neq 1$ is equivalent to the case of a poor choice of
controller gains in the fixed-gain autopilot.

##  IV Adaptive Autopilot

This section describes the adaptive autopilot, which is constructed by
augmenting the nominal autopilot. The nominal autopilot is the autopilot
described in Section III with fixed gains. In the adaptive autopilot, the
fixed-gain control laws of the nominal autopilot are augmented with adaptive
control laws, whose coefficients are updated by the retrospective cost
adaptive control (RCAC) algorithm described in [7, 8]. RCAC is used to augment
the fixed-gain controllers of a multicopter autopilot in [9, 16]. The output
of a modified controller in the adaptive autopilot is thus given by the sum of
the fixed-gain and the adaptive control law, as shown in Figure 4.

(4)(1), (2)(3)$+$$+$$+$$\begin{array}[]{c}{\rm Adaptive}\\\
\eqref{eq:adaptive_elevation_rate_P},\eqref{eq:adaptive_roll_rate_P}\end{array}$$G_{\omega,{\rm
PI}}$$\begin{array}[]{c}{\rm Adaptive}\\\
\eqref{eq:alpha_s_adaptive}\end{array}$$G_{\omega,{\rm
FF}}$(6)$+$$\alpha_{s}$$\begin{bmatrix}\dot{\Phi}_{{\rm s}}\\\
\dot{\Theta}_{{\rm s}}\end{bmatrix}$$\dot{\Psi}_{{\rm s}}$$V_{{\rm
m}}$$\begin{bmatrix}\Phi_{{\rm s}}\\\ \Theta_{{\rm
s}}\end{bmatrix}$$\begin{bmatrix}\Phi_{{\rm m}}\\\ \Theta_{{\rm
m}}\end{bmatrix}$$-$$\omega_{{\rm s}}$$\omega_{{\rm m}}$$-$$V_{{\rm
T}},V_{{\rm I}}$

Figure 4: Adaptive augmentation in the attitude controller.

The bank and elevation rate setpoints $\dot{\Phi}_{{\rm s}},\dot{\Theta}_{{\rm
s}}$ in the adaptive autopilot are given by

$\displaystyle\dot{\Theta}_{{\rm s}}$ $\displaystyle=k_{\theta}(\Theta_{{\rm
s}}-\Theta_{{\rm m}})+u_{\Theta},$ (7) $\displaystyle\dot{\Phi}_{{\rm s}}$
$\displaystyle=k_{\phi}(\Phi_{{\rm s}}-\Phi_{{\rm m}})+u_{\Phi},$ (8)

where the scalar adaptive control signals $u_{\Theta}$ and $u_{\Phi}$ are
computed by RCAC. Similarly, the angular acceleration setpoint in the adaptive
autopilot is given by

$\displaystyle\alpha_{s}$ $\displaystyle=\frac{V_{{\rm T},0}}{V_{{\rm
T}}}G_{\omega,{\rm ff}}\omega_{\rm s}$ $\displaystyle\quad+\left(\frac{V_{{\rm
I},0}}{V_{{\rm I}}}\right)^{2}G_{\omega,{\rm
PI}}({\textbf{{q}}})\left(\omega_{\rm s}-\omega_{\rm m}\right)+u_{\omega,\rm
PI},$ (9)

where $u_{\omega,\rm PI}$ is computed by RCAC. Note that $u_{\omega,\rm
PI}\in{\mathbb{R}}^{3},$ and each component of $u_{\omega,\rm PI}$ is updated
by RCAC, where the error variable is the corresponding error term.

##  V Simulation Results

In this section, we investigate the performance of the adaptive autopilot and
compare it to the performance of the nominal autopilot, implemented in PX4, in
the Gazebo simulation environment. The aircraft dynamics simulated in Gazebo
are based on the standard catapult-launched plane
model111https://docs.px4.io/main/en/simulation/gazebo_vehicles.html and are
integrated in the PX4 version
V1.13.0dev222https://github.com/JAParedes/PX4-Autopilot/tree/RCAC_FW_UM. We
also consider the case of a faulty actuator. To simulate a fault scenario, we
assume that one of the ailerons is frozen at an unknown angle.

Numerical simulations show that the aircraft performance is robust to TECS and
the lateral controller gains. Therefore, in this work, we focus on augmenting
only the attitude controller with the adaptive control law, and thus
$\alpha_{\rm d}$ degrades only the attitude controller in the nominal
autopilot. The hyperparameters $P_{0},$ $R_{u},$ and $\sigma$ used in RCAC are
shown in Table I. Furthermore, we set $R_{z}=1$ in all adaptive controllers
and all tests. Note that once the RCAC hyperparameters are tuned, they are
fixed and thus they are not changed as $\alpha_{\rm d}$ is varied across the
simulation tests.

TABLE I: RCAC hyperparameters used by the adaptive autopilot for all simulations.  Controller | ${P_{0}}$ | ${R_{u}}$ | $\sigma$
---|---|---|---
(7), $\theta_{\Theta}$ | $1$ | $0.001$ | $-0.1$
(8), $\theta_{\Phi}$ | $1$ | $0.001$ | $-0.1$

The mission waypoints are shown in Figure 5. The aircraft is assumed to be
launched by a catapult from the launch point, and is commanded to fly toward
the point ${\rm T}$ while climbing to an altitude of 20 m. The aircraft is
then commanded to fly around point 2 in a steady-state circular flight with a
radius of 30 m for one minute. Finally, the aircraft is commanded to land
along the green strip.

Figure 5:  Waypoints used to construct the flight trajectory in simulation
experiments.

In order to quantify and compare the performance of the autopilot, bank,
elevation, and trajectory-tracking error metrics are defined as

$\displaystyle J_{\Phi}$
$\displaystyle\stackrel{{\scriptstyle\triangle}}{{=}}\sqrt{\frac{1}{N}\sum_{i=1}^{N}(\Phi_{{{\rm
s}},i}-\Phi_{{{\rm m}},i})^{2}},$ (10) $\displaystyle J_{\Theta}$
$\displaystyle\stackrel{{\scriptstyle\triangle}}{{=}}\sqrt{\frac{1}{N}\sum_{i=1}^{N}(\Theta_{{{\rm
s}},i}-\Theta_{{{\rm m}},i})^{2}},$ (11) $\displaystyle J_{\rm traj}$
$\displaystyle\stackrel{{\scriptstyle\triangle}}{{=}}\sqrt{\frac{1}{N}\sum_{i=1}^{N}e_{{\rm
x-track},i}^{2}},$ (12)

where $N$ is the number of measurements during the flight, $e_{{\rm x-track}}$
is the cross-track error, which is defined as the minimum distance between the
current position and desired trajectory. These error metrics are computed
offline.

Figure 6 shows the ground trace, Figure 7 shows the bank-angle response, and
Figure 8 shows the elevation-angle response of the aircraft with the nominal
autopilot and the adaptive autopilot for several values of the degradation
factor $\alpha_{\rm d}.$ Figure 9 shows the adaptive bank and elevation
controller gains optimized by RCAC in the adaptive autopilot for several
values of the degradation factor $\alpha_{\rm d}.$ Figure 10 shows normalized
error metrics for several values of $\alpha_{\rm d}$ with the nominal,
degraded-nominal, and adaptive autopilots. The error metrics are normalized by
the error metrics obtained with the nominal autopilot.

As shown in Figure 10, the adaptive autopilot improves the performance over
the nominal performance. For $\alpha_{\rm d}=0.5,$ the trajectory following
response degrades substantially with the degraded-nominal autopilot. In this
case, the adaptive autopilot recovers the baseline performance. In fact, as
the nominal controller is degraded, RCAC compensates by providing larger
values of the corresponding gains. Finally, the adaptive autopilot is also
able to learn the gains from a cold start, that is, the case where the nominal
autopilot is completely switched off, that is, $\alpha_{\rm d}=0.$

Figure 6:  Flight simulation. Ground trace of the aircraft with the nominal,
degraded-nominal, and the adaptive autopilot for several values of the
degradation factor $\alpha_{\rm d}.$ Figure 7:  Flight simulation. Bank-angle
response of the aircraft with the nominal, degraded-nominal, and the adaptive
autopilot for several values of the degradation factor $\alpha_{\rm d}.$ The
bank angle setpoints are displayed in black dashes.  Figure 8:  Flight
simulation. Elevation-angle response of the aircraft with the nominal,
degraded-nominal, and the adaptive autopilot for several values of the
degradation factor $\alpha_{\rm d}.$ The elevation angle setpoints are
indicated by black dashes.  Figure 9:  Flight simulation. Adaptive bank and
elevation controller gains optimized by RCAC in the adaptive autopilot for
several values of the degradation factor $\alpha_{\rm d}.$ In each case, the
fixed gains are degraded by $\alpha_{\rm d}$ and RCAC updates the adaptive
control laws. The fixed gains are shown in dashes, and the adaptive gains are
shown in solid for both the bank and elevator controller.  Figure 10:  Flight
simulation. Bank, elevation, and trajectory-tracking error metrics obtained
with the nominal, degraded-nominal, and adaptive autopilots for several values
of $\alpha_{\rm d}$. Note that all metrics are normalized by the corresponding
error metric obtained with the nominal fixed-gain autopilot.

Next, we investigate the performance of the adaptive autopilot in the case of
faulty actuators. In particular, we consider the case where an aileron is
stuck at an unknown angle as shown in Figure 11. With the aileron stuck at an
unknown position, we command the aircraft to follow the mission waypoints
shown in Figure 5. This test is performed with both the nominal and adaptive
controller. In both cases, note that $\alpha_{\rm d}=1.$ Figures 12 and 13
show the trajectory-following response in the case where the left aileron is
stuck with the nominal and the adaptive autopilot. Furthermore, Figure 14
shows the error metrics in the case of the faulty actuator. Note that the
adaptive autopilot improves the trajectory-tracking error in the case of the
faulty actuator and recovers the benchmark performance.

Figure 11:  Faulty actuator. The left aileron is stuck at an unknown angle.
Figure 12:  Faulty actuator. Ground trace, bank, and elevation response of the
aircraft with a faulty actuator. The plots on the left and right are obtained
with the nominaland adaptive autopilot, respectively. Note that, in both
autopilots, $\alpha_{\rm d}=1.$

Figure 13:  Faulty actuator. Adaptive bank and elevation controller gains
optimized by RCAC in the adaptive autopilot for the faulty actuator case. The
fixed gains are shown in dashes, and the adaptive gains are shown in solid for
both the bank and elevator controller.  Figure 14:  Faulty actuator. Bank,
elevation, and trajectory-tracking error metrics in the case of a faulty
actuator with the nominaland adaptive autopilots. Note that the error metrics
are normalized by the corresponding error metric obtained with the nominal
autopilot and healthy actuator.

##  VI Flight Test Results

This section presents the experimental flight results obtained with the
adaptive autopilot. In this work, the flight tests are conducted with a
Volantex Ranger 1600 fixed-wing aircraft, shown in Figure 15, at the Scio
Flyers RC model aircraft club located at $(42.298{\rm N},83.843{\rm W})$. To
demonstrate the performance improvements due to the adaptive autopilot, the
performance of the nominal autopilot is degraded by scaling its fixed gains by
the degradation factor $\alpha_{\rm d}.$ In this work, we focus only on the
attitude controller, thus the gains of only the attitunde controller in the
nominal autopilot are scaled. The hyperparameters $P_{0},$ $R_{u},$ and
$\sigma$ used in RCAC are shown in Table II. Furthermore, we set $R_{z}=1$ in
all adaptive controllers and all tests. Note that once the RCAC
hyperparameters are tuned, they are not changed as $\alpha_{\rm d}$ is varied
across the flight tests.

TABLE II: RCAC hyperparameters in the adaptive autopilot for physical flight experiments.  Controller | ${P_{0}}$ | ${R_{u}}$ | ${\sigma}$
---|---|---|---
(7), $\theta_{\Theta}$ | $0.1$ | $0.001$ | $0.1$
(8), $\theta_{\Phi}$ | $0.1$ | $0.001$ | $-0.1$

The mission waypoints are shown in Figure 16. The aircraft is launched by hand
from the launch point and is commanded to fly towards point ${\rm T}$ while
climbing to an altitude of 20 m. The aircraft is then commanded to fly around
point 2 in a steady-state circular flight with a radius of 20 m for around 1
to 2 minutes. Finally, the aircraft is commanded to land along the green
strip. During the takeoff and landing phases, the autopilot is in stabilized
mode, in which the bank and elevation commands are issued by a pilot. During
the rest of the flight, the autopilot is in mission mode, in which the bank
and elevation commands are issued by the outer loop of the autopilot.

Figure 15: Volantex Ranger 1600 fixed-wing RC aircraft used in flight
experiments.  Figure 16: Waypoints used to construct the flight trajectory in
physical flight experiments.

Figures 17, 18, and 19 show the ground trace, bank-angle response, and
elevation-angle response, respectively, of the aircraft with the nominal and
the adaptive autopilot for several values of the degradation factor
$\alpha_{\rm d}.$ Figure 20 shows the adaptive bank and elevation controller
gains optimized by RCAC in the adaptive autopilot for several values of the
degradation factor $\alpha_{\rm d}.$ Figure 21 shows the normalized error
metrics for several values of $\alpha_{\rm d}$ with the nominal, degraded-
nominal, and adaptive autopilot. The error metrics are normalized by the
corresponding metrics obtained with the nominal autopilot, that is, without
RCAC and $\alpha_{\rm d}=1.$ As shown in Figure 21, the augmented adaptive
autopilot improves the performance over the nominal performance. For
$\alpha_{\rm d}=0.5,$ the trajectory following response degrades substantially
with the degraded-nominal autopilot, and in this case, the adaptive autopilot
recovers the baseline performance. In fact, as the fixed-gain controller is
degraded, RCAC compensates by providing larger values of the corresponding
gains. Finally, the adaptive autopilot is also able to learn the gains from a
cold start, that is, the case where the nominal autopilot is completely
switched off, that is, $\alpha_{\rm d}=0.$

Figure 17: Physical flight experiments. Ground trace of the aircraft with the
nominaland adaptive autopilot for several values of the degradation factor
$\alpha_{\rm d}.$ Figure 18: Physical flight experiments. Bank-angle response
of the aircraft with the nominaland adaptive autopilot for several values of
the degradation factor $\alpha_{\rm d}.$ The bank angle setpoints are
displayed in black dashes. Note that the autopilot is in mission mode and
stabilized mode in the blue and orange regions, respectively.  Figure 19:
Physical flight experiments. Elevation-angle response of the aircraft with the
nominaland adaptive autopilot for several values of the degradation factor
$\alpha_{\rm d}.$ The bank angle setpoints are displayed in black dashes. Note
that the autopilot is in mission mode and stabilized mode in the blue and
orange regions, respectively.  Figure 20:  Physical flight experiments.
Adaptive bank and elevation controller gains optimized by RCAC in the adaptive
autopilot for several values of the degradation factor $\alpha_{\rm d}.$ The
nominal gains are shown in dashes, and the adaptive gains are shown in solid
for both the bank and elevator controller. Note that the autopilot is in
mission mode and stabilized mode in the blue and orange regions, respectively.
Figure 21:  Physical flight experiments. Bank, elevation, and trajectory-
tracking error metrics obtained with the adaptive autopilots for several
values of $\alpha_{\rm d}$ and normalized by the corresponding error metric
obtained with the nominal autopilot.

##  VII Conclusions

This paper presented an adaptive autopilot that can improve an initial poor
choice of controller gains in a fixed-gain autopilot, and learn the autopilot
gains without any prior knowledge of the dynamics. The adaptive autopilot is
constructed by augmenting the fixed-gain controllers in an autopilot with
adaptive controllers. The adaptive autopilot was used to fly a fixed-wing
aircraft model in the Gazebo simulator. The adaptive autopilot recovered the
performance in the case where the fixed-gain autopilot was degraded and
learned a set of gains in the case where the fixed-gain autopilot was
completely switched off. Furthermore, the adaptive autopilot improved the
trajectory-tracking performance in the case where the aileron was stuck at an
unknown angle in simulation. The adaptive autopilot was also used to fly
fixed-wing aircraft in flight experiments conducted outdoors. Like the
simulation results, the adaptive autopilot improved the flight performance in
physical flight experiments.

## References

  * [1] N Harris McClamroch  “Steady aircraft flight and performance”  Princeton University Press, 2011
  * [2] Nhan Nguyen, Kalmanje Krishnakumar, John Kaneshige and Pascal Nespeca  “Dynamics and adaptive control for stability recovery of damaged asymmetric aircraft”  In _AIAA Guidance, navigation, and control Conference and Exhibit_ , 2006, pp. 6049
  * [3] Ziquan Yu, Hamed Badihi, Youmin Zhang, Yajie Ma, Bin Jiang and Chun-Yi Su  “Fractional-Order Sliding-Mode Fault-Tolerant Neural Adaptive Control of Fixed-Wing UAV With Prescribed Tracking Performance”  In _2020 2nd International Conference on Industrial Artificial Intelligence (IAI)_ , 2020, pp. 1–6  DOI: 10.1109/IAI50351.2020.9262225
  * [4] Minrui Fu, Ziquan Yu and Youmin Zhang  “Adaptive Fault-Tolerant Control of Fixed-wing UAV Under Actuator Saturation and State Constraints”  In _2021 International Conference on Unmanned Aircraft Systems (ICUAS)_ , 2021, pp. 47–52  DOI: 10.1109/ICUAS51884.2021.9476716
  * [5] Shogo Hirano, Kenji Uchiyama and Kai Masuda  “Controller Design Using Backstepping Algorithm for Fixed-Wing UAV with Thrust Vectoring System”  In _2019 International Conference on Unmanned Aircraft Systems (ICUAS)_ , 2019, pp. 1084–1088  IEEE
  * [6] Jizhang Xiong, Ye Yang, Zhongtao Cheng, Lei Liu, Yongji Wang and Huijin Fan  “Observer-like Model Reference Adaptive Augmenting based fixed-wing UAV Control”  In _2020 39th Chinese Control Conference (CCC)_ , 2020, pp. 6804–6809  DOI: 10.23919/CCC50068.2020.9189264
  * [7] Yousaf Rahman, Antai Xie and Dennis S. Bernstein  “Retrospective Cost Adaptive Control: Pole Placement, Frequency Response, and Connections with LQG Control”  In _IEEE Control System Magazine_ 37, 2017, pp. 28–69  DOI: 10.1109/MCS.2017.2718825
  * [8] Mohammadreza Kamaldar, Syed Aseem U. Islam, Sneha Sanjeevini, Ankit Goel, Jesse B. Hoagg and Dennis S. Bernstein  “Adaptive digital PID control of first-order-lag-plus-dead-time dynamics with sensor, actuator, and feedback nonlinearities”  In _Advanced Control for Applications_ 1.1, 2019, pp. e20  DOI: 10.1002/adc2.20
  * [9] Ankit Goel, Juan Augusto Paredes, Harshil Dadhaniya, Syed Aseem Ul Islam, Abdulazeez Mohammed Salim, Sai Ravela and Dennis Bernstein  “Experimental Implementation of an Adaptive Digital Autopilot”  In _2021 American Control Conference (ACC)_ , 2021, pp. 3737–3742  DOI: 10.23919/ACC50511.2021.9483005
  * [10] John Spencer, Joonghyun Lee, Juan Augusto Paredes, Ankit Goel and Dennis Bernstein  “An Adaptive PID Autotuner for Multicopters with Experimental Results”  In _arXiv:2109.12797_ , 2021
  * [11] Kevin Bruce, J Kelly and J Person  “NASA B737 flight test results of the total energy control system”  In _Astrodynamics Conference_ , 1986, pp. 2143
  * [12] LF Faleiro and AA Lambregts  “Analysis and tuning of a Total Energy Control System control law using eigenstructure assignment”  In _Aerospace science and technology_ 3.3 Elsevier, 1999, pp. 127–140
  * [13] Antonius A Lambregts  “TECS generalized airplane control system design–an update”  In _Advances in Aerospace Guidance, Navigation and Control_ Springer, 2013, pp. 503–534
  * [14] Matthew E. Argyle and Randal W. Beard  “Nonlinear Total Energy Control for the Longitudinal dynamics of an aircraft”  In _2016 American Control Conference (ACC)_ , 2016, pp. 6741–6746  DOI: 10.1109/ACC.2016.7526733
  * [15] Sanghyuk Park, John Deyst and Jonathan How  “A new nonlinear guidance logic for trajectory tracking”  In _AIAA guidance, navigation, and control conference and exhibit_ , 2004, pp. 4900
  * [16] John Spencer, Joonghyun Lee, Juan Augusto Paredes, Ankit Goel and Dennis Bernstein  “An adaptive pid autotuner for multicopters with experimental results”  In _2022 International Conference on Robotics and Automation (ICRA)_ , 2022, pp. 7846–7853  IEEE