## 2 Reinforcement Learning and the Longitudinal Aircraft Model
### Aircraft Model
Automated control inputs were generated by a set of Python scripts, which also recorded load cell data. The pitch and yaw traverse, and the tunnel airspeed, were controlled by the wind tunnel's existing control system, which was manually provided with setpoints. With the airframe mounted, the overall range available for the traverse was \(-18^{\circ}\) to \(20^{\circ}\) in angle of attack, and \(\pm 30^{\circ}\) in sideslip. Data was gathered at indicated wind tunnel speeds of \(10\,\mathrm{m}\,\mathrm{s}^{-1}\) to \(22.5\,\mathrm{m}\,\mathrm{s}^{-1}\) in \(2.5\,\mathrm{m}\,\mathrm{s}^{-1}\) increments. The elevator, rudder and aileron were each deflected individually across a range of throttle settings at each tunnel speed  
Figure 1: Diagram showing definitions of pitch angle, \(\theta\), angle of attack, \(\alpha\), flight path angle, \(\gamma\), and elevator angle, \(\eta\). and vehicle attitude, yielding a large dataset covering almost all of the conventional flight envelope and initial stages of the post-stall regime. This data was then used to generate a set of parameterised curves to define the coefficients for the longitudinal model. These curves were extended with data from additional references to cover the full range of angle of attack from \(-180^{\circ}\) through to \(180^{\circ}\). The resulting curves for the lift and pitching moment coefficients are plotted in Figure 3.  
The longitudinal model has two control inputs available: elevator angle, \(\eta\) and throttle setting \(\tau\). Figure 1 shows the elevator angle, here defined as the angle to which the elevator is deflected upwards relative to its neutral position. Note that this definition of elevator angle is opposite in sense to convention, generating a positive pitching moment with a positive deflection. The wind tunnel data was used to generate a coefficient for the elevator that varied with throttle setting, airspeed and elevator angle. The throttle setting is mapped to the generated thrust, based on a two-dimensional polynomial incorporating the airspeed. Along with the forces and torques exerted on the body, the mass and inertial properties of the body are required. A second airframe was fitted with necessary hardware for autonomous flight and used to make measurements of these properties. The resulting measurements are presented in Table 1. In the work presented here, only a longitudinal model is used, so only the pitch inertia \(I_{yy}\) and overall mass are needed. Figure 3: Plots of the lift and pitching moment coefficient curves used in the MXS model across the full range of \(\alpha\). Figure 2: Images of the MXS2 airframe in the University of Bristol Wind Tunnel and in free flight at the University of Bristol Fenswood free flight facility. These coefficient curves, thrust modelling and inertial data were used to implement the model using pyaerso [18]. This is an accessible Python interface to a simple flight dynamics modelling library implemented in Rust [19]. It allows forces and moments to be calculated in Python, based on the current vehicle aerodynamic state, and to be transferred to dedicated, pre-compiled machine-code for the state propagation process. Wind and atmospheric density models can also be defined in Python, or a set of pre-built models can be selected from. This allows easy experimentation without the need to recompile software or manipulate aircraft model configuration files. It also means users are free to use arbitrary functions to define their models, rather than being limited to a set supported by the underlying dynamics code. The Python interface ([[https://github.com/rob-clarke/pyaerso](https://github.com/rob-clarke/pyaerso)]([https://github.com/rob-clarke/pyaerso](https://github.com/rob-clarke/pyaerso)), accessed on 14 July 2023) and the underlying Rust library ([[https://github.com/rob-clarke/aerso](https://github.com/rob-clarke/aerso)]([https://github.com/rob-clarke/aerso](https://github.com/rob-clarke/aerso)), accessed on 14 July 2023) are both available on GitHub under MIT licenses.