Although there are several interesting open-source simulation platforms in robotics and aviation such as ROS, V-REP, and MATLAB/Simulink, the JSBSim FDM has been used in this study due to its flexibility regarding the design of new aircraft and the dual mode of running the model.
3.1. JSBSim Open-Source Flight Dynamics Model
JSBSim is a 6-DoF FDM that has been used in aeronautics for over 20 years [
15]. It is an open-source platform with versatile aircraft models and a large online library that includes scenery and airports. The highlight of this FDM is that the scripting mode runs under most of the operating systems, making it easily reproducible. JSBSim has been used in projects with UAVs [
16,
17], but it was initially designed for general aircraft and, as a consequence, its reliability has been questioned. However, the Bernoulli’s equation is universal, and the basic principles are the same for large and small aircraft. Although the turbulent flight is more noticeable in smaller aircraft, the main differences are controllable by the way the aircraft is operated and it is, therefore, independent from the dynamics of the aircraft.
The software can be downloaded from its website [
18] and runs with FlightGear [
19] to provide a visual performance. The latter is an open-source flight simulator that is in constant development (its last version, FlightGear 2018.3.2, was released on 29 January 2019). It is usually run along with JSBSim, as their roles are complementary; JSBSim provides the dynamics of the system and FlightGear the visual performance.
In the simplest scenario, JSBSim can be run through scripts entirely implemented through the code with FlightGear as the visualization software. In the diagram below (
Figure 3), a simple simulation with JSBSim is shown formed by four main blocks: (1) JSBSim standalone program; (2) inputs, including script, initialization, and datalog files; (3) output, and (4) system files such as the aircraft configuration and propulsion files.
The versatility of JSBSim is one of its strongest attributes, since it is an open-source project. The MATLAB/Simulink with its AeroSim toolkit has also been commonly used to run simulations with UAVs [
20]. Even though this toolkit is no longer supported after MATLAB R2010a, it plays a relevant role in the validation process and design of the optimal FDM in the following sections.
3.2. FDM Mathematical Method
The mathematical model used in JSBSim is derived from the most widely used method, Newton’s second law, where the position, velocities, and accelerations are solved from the total forces and moments, assuming that the aircraft is a 6-DoF rigid body [
21]. Assuming the three principal position axes on an aircraft: longitudinal, lateral, and vertical, the orientation is given by the three angles: roll, pitch, and yaw. Thus, the FDM can be expressed by a series of non-differential equations. The aircraft motion is expressed by, first, the linear velocities [
], calculated from their derivatives
= [
], and, second, the angular velocities [
], calculated from their corresponding angular velocities
[
], as follows:
The state variables are calculated from the total forces along each axis with respect to the body frame. The body angular velocities are also calculated from the moments of inertia about their center of gravity and the aircraft’s mass. The change of the body angles in roll pitch and yaw is calculated using the velocities.
JSBSim obtains the aerodynamic forces and moments using the coefficient buildup method, meaning that all the contributions to the generation of a specific force or moment are calculated and summed in order to obtain that total force/moment. The coefficients are taken from flight tests, calculated by hand or using software. JSBSim, through its tool Aeromatic v2.0 found on its website [
18], also provides an approximate set of coefficients calculated from the aircraft dimensions.
The dynamic pressure expresses the approximate relationship between pressure and speed for low flow speeds (e.g., UAV case). By definition, the dynamic pressure represents the kinetic energy by a unit of volume of air used to calculate the force (e.g., side force (
Y)) by multiplying a surface area and the aerodynamic coefficient.
where
q is the dynamic pressure,
ρ is the air density,
V is the airspeed expressed in the wind frame,
S is the wing area, and
CY is the side force coefficient.
The other two forces (drag (
D) and lift (
L)) are calculated by following the same concept:
CD represents the drag coefficient, and CL is the lift coefficient. Note that all the aerodynamic coefficients are non-dimensional.
The expressions for the moments are similar, as follows:
where
l,
m, and
n are the rolling, pitching, and yawing moments;
b is the wingspan;
c is the wing chord; and
Cl, Cm, and
Cn are the coefficients for roll, pitch, and yaw coefficients, respectively.
As mentioned earlier, each coefficient is calculated from all the contributions to the force. As an example, the side force dependencies are the following:
where
β represents the sideslip angle,
p the roll rate,
r the yaw rate, and
δ the flight deflections given by the control surfaces. For the slow airspeed and low altitude of the UAV case, the Mach number and altitude elements are neglected because their dependencies in all the coefficients are not significant.
Therefore, the side force coefficient, including the dependencies and its coefficients, is as follows:
Each of the side force coefficients () is a consequence of the corresponding components (superscript).
Following the same approach as expressed for the side force coefficient, the drag coefficient
CD, the lift coefficient
CL, the roll coefficient
Cl, the pitch coefficient
Cm, and the yaw coefficient
Cn for a UAV case in JSBSim are expressed as follows:
where
α is the angle of attack,
is the rate of the angle of attack,
q is the pitch rate, and each of the corresponding coefficient dependencies is indicated by their subscript.
The drag coefficient includes a special term , which indicates the induced drag caused by the lift force. Equations (12)–(17) are general statements, but they must be modified according to the aircraft. JSBSim allows for modifications in the aircraft configuration file in case the design carries other dependencies.
JSBSim includes different types of propulsion systems, depending on the engines used to generate the thrust: a piston engine model, a jet turbine engine model, a turboprop engine model, a rocket engine model, and an electric engine model. In the case of the Giant Big Stik, the piston model will be used. The thrust generation presents the same setting, while among all the options found in JSBSim—direct, nozzle, propeller, and rotor—only the propeller is used in the fixed-wing UAV case.