HIGGINS DANIEL FORREST (US)
US20120095621A1 | 2012-04-19 | |||
US20110143319A1 | 2011-06-16 |
LEONARD BAUERSFELD ET AL: "NeuroBEM: Hybrid Aerodynamic Quadrotor Model", ARXIV.ORG, CORNELL UNIVERSITY LIBRARY, 201 OLIN LIBRARY CORNELL UNIVERSITY ITHACA, NY 14853, 15 June 2021 (2021-06-15), XP081989942
CLAIMS 1. A system comprising: a processor; and a memory storing instructions that, when executed by the processor, cause the system for simulating motion of an object to execute a method comprising: generating, based on object data of the object, a rigid body model associated with the object; receiving a set of input commands over time, wherein an input commands in the set of input commands is associated with a time-tick, the time-tick increments over time; generating, based on the set of input commands, a set of moment commands over time; determining, based on a combination of the rigid body model and the set of moment commands, a body state of the object at the time-tick; and causing an iterative display of the body state of the object at the time-tick incrementing over time. 2. The system according to claim 1, wherein the set of input commands further comprises: a velocity of the object at the time-tick; an altitude of the object at the time-tick; and a heading of the object at the time-tick. 3. The system according to claim 1, wherein the rigid body model further comprises: rigid body data based on six degrees of freedom; and rotation formulation data based on 312-intrinsic Euler. 4. The system according to claim 1, wherein the determined body state further comprises: a position of the object at the time-tick; a velocity of the object at the time-tick; and an acceleration of the object at the time-tick. 5. The system according to claim 1, wherein the determining the set of moment commands uses a combination of a first order Euler based on 4th-order Runge-Kutta on linear state data and an exponential integration based on the 4th-order Runge-Kutta Munthe-Kaas for rotational state data, the linear state data includes at least a global position, a local body linear velocity, and a local body angular velocity of the object, and the rotational state data indicates a quaternion orientation of the object. 6. The system according to claim 1 , the processor further causes the system to execute a method comprising: determining, based on the received set of input commands including the incremented time- tick, a set of attitude commands; determining, based on the set of attitude commands, a set of angular rate commands; and determining, based on the set of angular rate commands, the set of moment commands. 7. The system according to claim 1, wherein the object data includes at least: a type of the object, a mass of the object, an inertia tensor of the object, or a moment co-efficient associated with the type of the object. 8. The system according to claim 1, the processor further causes the system to execute a method comprising: iteratively updating, based on the determined body state, a parameter associated with the rigid body model. 9. The system according to claim 1, the processor further causes the system to execute a method comprising: transmitting the body state of the object at the incremented time-tick. 10. A computer-implemented method for simulating motion of an object, the method comprising: receiving a set of input commands over time, wherein an input commands in the set of input commands is associated with a time-tick, the time-tick increments over time; generating, based on the set of input commands, a set of moment commands over time; determining, based on a combination of a rigid body model and the set of moment commands, a body state of the object at the time-tick; and causing an iterative display of the body state of the object at the time-tick incrementing over time. 11. The computer-implemented method of claim 10, wherein the set of input commands further comprises: a velocity of the object at the time-tick; an altitude of the object at the time-tick; and a heading of the object at the time-tick. 12. The computer-implemented method of claim 10, the method further comprising: generating, based on object data of the object, the rigid body model associated with the object, wherein the rigid body model includes: rigid body data based on six degrees of freedom, and rotation formulation data based on 312-intrinsic Euler, and the object data includes at least: a type of the object, a mass of the object, an inertia tensor of the object, or a moment co-efficient associated with the type of the object. 13. A device for simulating motion of an object, the device comprises a processor configured to execute a method comprising: generating, based on object data of the object, a rigid body model associated with the object, wherein the object includes an aircraft; receiving a set of input commands over time, wherein an input commands in the set of input commands is associated with a time-tick, the time-tick increments over time; determining, based on the received set of input commands including the incremented time- tick, a set of attitude commands; determining, based on the set of attitude commands, a set of angular rate commands; determining, based on the set of angular rate commands, a set of moment commands; determining, based on a combination of the rigid body model and the set of moment commands, a body state of the object at the time-tick; and causing an iterative display of the body state of the object at the time-tick incrementing over time. 14. The device according to claim 13, wherein the set of input commands further comprises: a velocity of the object at the time-tick; an altitude of the object at the time-tick; and a heading of the object at the time-tick. 15. The device according to claim 13, wherein the rigid body model further comprises: rigid body data based on six degrees of freedom; and rotation formulation data based on 312-intrinsic Euler. |
APPENDIX
“Mathematics of the Physics Engine.”
Mathematics of the Physics Engine
Fabio Croce, PhD Microsoft Corporation
January 2022
Abstract
This paper describes the mathematical derivation used in the physics engine, producing the novel formulation of a six- degrees- of- freedom (6DOFs) rigid body in the real-time strategy (RTS) reference system. The body receives input forces from a nonlinear inverse dynamics (NDI) controller to follow a trajectory imposed by an external user, either artificial intelligence (Al) or a real user. The set of ordinary differential equations (ODE) produced by the rigid body (Aircraft) and controller (Autopilot) are integrated with a mixed explicit algorithm aiming to preserve the consistency of states during the simulation. The rigid body has been parameterized using the commercial aircraft Airbus A320. The input trajectory to follow is designed with a climb from 5,000 m to 10,000 m, a coordinate turn of 120° heading direction, and a subsequent descent back to 5,000 m. Finally, Simulink® Aerospace Blockset™ with MATLAB® Functions™ are used to numerically validate the dynamics of this system by carrying out a comparative simulation between the physics engine and Simulink. This results in a confirmed optimal accuracy of the Aircraft/ Autopilot modeling for provided inertial, geometric, and aerodynamics properties of military and commercial aircraft.
Introduction
The material in this paper is organized into five sections which describe the areas of development of the engine. For each section, the current base technology is described and the novelties/non obviousness of the new formulation are derived in detail. The five areas are referenced as paper sections:
1. RTS Dynamic Simulation Formulation
2. Nonlinear Inversion Dynamics Controller
3. Mixed Euler /Exponential Numerical Integration
4. Airbus A320 Aircraft Input Data
5. Accuracy Validation of Dynamic Response 1 RTS Dynamic Simulation Formulation
This section first describes how the 3D rotation library is implemented in this engine and what parameters are used to describe the orientation of the body in space. Second, the governing equations for the six-degrees-of-freedom (6DOFs) rigid body are established within the reference systems developed in the rotation library. Finally, the externally driven time step synchronization will be discussed from an architectural point of view, while the numerical solution technique adopted to solve the ordinary differential equations (ODE) generated by the rigid body will be discussed.
1.1 Rotation Library
In this derivation, we will be using a right-handed Cartesian reference system defined as follows: x to the right side of the body, y to the forward direction of the body, and z to the upward direction of the body. This choice is consistent with the standard real-time strategy (RTS) reference system used in gaming. Two main Cartesian reference systems will be used during this derivation, that is, a global reference system with capital X, Y, and Z and a local reference system with lower case x, y, and z. Figure 1 depicts those two basic reference systems:
Figure 1: Global and local reference systems.
In the same figure 1, three basic vectors are shown representing the typical reference kinematics of multibody dynamics bodies in space - see [1] “Reference Kinematics” and the references therein. In this derivation, the orientation of the body is composed using three sequential rotations for transforming a vector expressed in global reference to local reference. This sequence, named as 3-1-2 Intrinsic Euler, is formed by a first rotation about the z-axis of the yaw angle ψ , followed by a second rotation about the instantaneous x-axis of the pitch angle 0, followed by a third rotation about the instantaneous y-axis of the roll angle Φ . Thus, the rotation matrix representing the orientation of the body in the global reference system is the following equation (1.1):
(1-1)
Having defined the orientation of the body with respect to the global reference system, one can characterize each point of the body using the translation/rotation formulation of multibody systems (see figure 1), that is in formula:
(1-2)
Formula (1.2) will be used to translate local states into global states within the solver solution process. Note that the nomenclature indicates an over bar for vector/matrix quantities expressed in the local reference system, e.g. u indicates the position of a point P of the body in local coordinates. Thus, equation (1.2) combines the translation and rotation of the rigid body, providing the coordinates of the point P depicted in figure 1 in global coordinates.
Other important relations which need to be derived in the RTS reference system are the so- called G matrices expressed in terms of the Euler angles. These matrices depend upon the sequence that has been chosen for representing the global-to-local body orientation, thus existing [1] cannot be applied. Since infinitesimal rotations are vector quantities, we can reconstruct the angular velocity vector by using the three infinitesimal yaw, pitch, and roll rotations to compute the relationship between Euler angles time derivatives and the global/local angular velocity vector. These equations will be used in the nonlinear dynamics inversion controller formulation:
Once the G matrix is defined, one can easily derive its inverse, the Those are key relationships between the global angular velocity vector ω, the local angular velocity vector and the time derivatives of the Euler angles θ, that is:
Note that the nomenclature of the global angular velocity vector is as a>i while the one for the local angular velocity vector is as p, q, r, which is the traditional solver states notation for this vector.
The rigid body solver utilizes the traditional Euler parameters, known as quaternion, as orientation states, while, as mentioned before, the aircraft controller utilizes Euler angles to describe the body orientation. Note that there is a subtle nomenclature difference between three Euler angles and four Euler parameters - the two sets are mathematically very different quantities, thus refer to [1] to clarify the relationship between them. The reason for this different choice in body orientation description will be evident after reading the controller and numerical integration sections of this paper.
When Euler parameters are used as orientation states, we can formally write analogous relation- ships to (1.3), (1.4), (1.5), (1.6), by substituting the expressions for G matrices and θ accordingly. The advantage of using Euler parameters versus a particular Euler angles sequence is that the rotation matrix A is unique and can be expressed as follows:
By using equations (1.7), (1.8), and (1.9), one can derive the following relationships between angular velocity and Euler parameters time derivatives - this can be helpful to implement a first order Euler-based update in the quanternion states:
Note that the relationship between equations (1.10) - (1.11) and equations (1.12) - (1.13) is not a trivial matrix inversion, but instead requires using E T E = E T E = I4 — 00 T and noticing that
= 0 because the dot product of a constant length vector and its derivative is zero since the two vectors must be perpendicular - the proof is left to the reader for exercise.
It is possible to move from one formulation, i.e. rotation matrix expressed in terms of Euler angles (1.1), to the other, i.e. rotation matrix expressed in terms of Euler parameters (1.7), by using the relationships defined in [2] (Appendix A, 9). Note that we are using a Jet Propulsion Laboratory (JPL) quaternion convention for unit rotations, as defined in [3],
Another important part of this derivation is the interface with standard aerospace conventions to represent the orientation of an airplane. Traditionally, the aerospace industry adopts Euler angles sequence defined as 3-2-1 Intrinsic Euler - see [2] (Appendix A, 10), hence the yaw, pitch, roll angles as well as the rotation matrices or inertia tensor properties defined in the two reference systems are not directly translatable without proper transformations. This second reference system is usually named as North, East, Down (NED) or Tait-Bryan angles (TB), and it is defined as follows: x to the forward direction of the body, y to the right side of the body, and z to the downward direction of the body. As can be seen, this is also a right-handed reference system, since there exists x X y = z.
Figure 2 provides the relative orientation between the two reference systems TB and RTS. It also shows how Euler angles map to different axes depending on which sequence we are adopting.
Figure 2: Real-time strategy (RTS) and Tait-Bryan (TB) reference systems.
Thus, the vector, matrix and orientation need to be properly translated from one reference system to the other.
We begin the derivation noticing that one can find a transformation from a vector expressed in TB to the corresponding in RTS and vice-versa by simply using the relative rotation matrix of one system versus the other, e.g.: where the columns of A TB→RTS are the direction cosines of TB axis expressed in RT reference system. We should also note that matrix A TB→RTS is symmetric and orthonormal, hence the following properties exist:
Now we consider a generic vector transformation in TB from local to global, e.g.: which can be expressed in RTS by means of (1.14), that is: and thus:
Hence, starting from a rotation matrix expressed in TB, e.g. RT B , the corresponding rotation matrix in RTS is expressed as:
In the particular case of TB/RTS transformation, this quadratic form shows symmetric matrices pre and post multiplying. Nonetheless, given the generality of the derivation, this can be applied for non- symmetric, yet orthonormal matrices. We recall that a rotation matrix is by definition orthonormal, e.g. its inverse is equal to its transpose Q T Q = QQ T = I.
Equation (1.21) has a very important application to the inertia tensor. Because customer data are usually provided in TB reference system, we will be using this same transformation to retrieve the RTS inertia tensor which is necessary for the equations of motion (EOM). Hence, we can generalize the above as follows:
Now we have all the pieces for computing Euler angles RTS from Euler angles TB, as follows:
• create the rotation matrix R BE from Euler angles TB, by using [2] (Appendix A, 10)
• convert to the corresponding rotation matrix R RTS using equation (1-21)
• extract Euler angles RTS from R RTS using [2] (Appendix A, 9)
The same approach can be used to go from RTS to TB. Again, we leave it to the reader to prove this derivation as an exercise.
1.2 Rigid Body Library
This section describes how the equations of motion for the rigid body have been written using the RTS rotation formulation developed. We will develop the 6DOFs equations of motion expressed in the local body reference frame previously described. The details of the numerical integration will be covered in the section describing the mixed Euler /Exponential approach, while in this section we will formally derive the equations to be integrated.
Since Euler parameters, e.g. quaternion, will be used as orientation parameters for the body, one could argue that the correct nomenclature for this rigid body is 7DOFs, three linear states plus four angular states. For consistency with literature and historic nomenclature, we will be using the 6DOFs naming convention. It should be noted that the extra state for the quaternion orientation allows for resolving singularities such as Gimbal lock for pitch angles of 90° positive or negative, by exploiting the fact that: where 0 is the angle of rotation of the rigid body along the unit vector Hence, while the numerical integration of the rotation states will exploit the more robust quaternion implementation, at converged step the graphical client may require to extract the Euler angles for rendering the orientation of the body. If that is the case, again [2] (Appendix A, 9) can be used for this purpose.
In case the graphical client uses left-handed reference systems with sequences different from RTS, an approach similar to the one described for converting Euler angles between RTS and TB can be exploited. Thus, the procedure previously described is general as long as one properly defines the transformation matrix (1.14).
We will be writing the equations of motion (EOM) according to the Newton- Euler approach, which provides three equations for the linear DOFs and three equations for the rotational DOFs. Those equations will be written in compact matrix form to allow the integration with the RTS rotation library for position and orientation of the body.
The second aspect of this derivation is the choice of writing the equations in the global or local reference system. We chose the latter for multiple reasons. First, the expression of forces (especially in the case of the aerodynamics thrust, lift, drag and rotation moments of an aircraft) have a more natural formulation in the body reference system. This aspect will be described at length in the controller portion of this paper. Second, the inertial tensor has a constant expression within the body reference system, equal to the value provided by customers. If the equations were to be written in the global reference system, a re-evaluation of the inertia tensor (and therefore its inverse) should be carried out at each time step integration, according to the following where A is the rotation matrix representing the instantaneous orientation of the body. Finally, the effect of fictitious inertia forces F» due to the fact we are using a rotating frame, can be taken into account as follows - see [1] “Analytic Techniques” and the references therein:
The dynamic equations of motion produce second order ordinary differential equations (ODEs) which need to be integrated numerically. Traditionally, the state vector is defined using a statebased approach, where we lower a degree of differentiation by duplicating the number of states, that is, we introduce the global position x (t) as integration of body linear velocity and the quaternion orientation θ (t) as integration of body angular velocity - note the mixed approach global/local states, where we differentiate the vectors expressed in local reference system by using the over bar. The “3 4 3 3” state vector is therefore defined as follows: and the derivatives with respect to time of equation (1.24) provide the following first order differential equations, whose expression is based on the linear momentum (for linear states) and angular momentum (for angular states):
The equation of linear momentum in body reference coordinate system can be written as follows:
The equation of angular momentum L (t) J co (t) in body reference coordinate system can be written as follows:
At this point, we have all the information for carrying over four numerical integrations over the four vector expressions in equation (1.25). The reader will note that the four expressions are mathematically linked together, therefore we have to compute these numerical integrations sequentially; that is, in a multistage solver approach, within each step the values of the current stage is dependent on the result from the previous stage.
The first equation provides the derivatives with respect to time of the global position:
The second equation provides the derivatives with respect to time of the quaternion orientation: The third equation provides the derivatives with respect to time of the local linear velocity:
The fourth equation provides the derivatives with respect to time of the local angular velocity:
The F/ oea / and T/,,,,,,/ are also functions of time, and depending on the scenario simulated may have simple or complex expressions. For example, the constant expression of gravity force in global RTS frame needs to be transposed to the local body coordinate system by using the instantaneous body orientation, e.g.:
Other forces such as drag depend on the local body velocity of the aircraft via proper aerodynam- ics coefficients, thus they do not require a transformation via the rotation matrix, but only the knowledge of the body velocity:
A third most important application is the one where the rigid body needs to follow a prescribed trajectory. In such case, a controller needs to compute the forces needed to properly drive the body in the desired trajectory and most likely will work with a co-simulation approach with the rigid body, since the computation of such forces depends upon the current state of the body. This is the use case addressed later on in this paper by implementing an NDI controller trajectory tracking.
However, the derivation developed in this section is modular enough that if forces are known a priori or prescribed according a predefined law, the rigid body solver can be simulated in a standalone fashion. Most importantly, this derivation can be applied to a variety of rigid bodies of physics. For example, by properly customizing the expressions of Fi ocai and Ti OC ai , effects of weather conditions, fluid interaction, and electromagnetism can be taken into account in the rigid body solution process.
For more detailed applications to the aerospace industry, two sources can be reviewed. [4] provides Tait-Bryan formulations of aircraft dynamics. [5] overviews simulation techniques used in Microsoft Flight Simulator.
1.3 Externally Driven Time Step Synchronization
The above developed solver provides the dynamic conditions of a body, e.g. its position, velocity and acceleration, which undergoes applied external forces at a certain time. The update state routine receives as input a time step increment to compute the dynamic evolution of states starting from the values at current time. At the very beginning, the process of numerical integration requires initial conditions (ICs). Mathematically speaking, ODE requires a number of initial conditions equal to the number of states which need to be integrated. Therefore, the following set of ICs are provided at the beginning of the simulation:
• global initial position x 0 (t)
• quaternion initial orientation θ 0 (t)
• body initial linear velocity
• body initial angular velocit
At this point, assuming that the forces are known at time to, the system is able to compute the dynamic conditions of the body at time ti = t 0 + dt. This time step could be internally generated for a standalone simulation from the time t initial to t final . Traditional computer aided design
(CAE) packages provide the user with simulation results within those extremes of integration. This is usuall v known as offline standalone simulation.
Two main problems arise with this type of approach. First, the simulation can be very lengthy depending on the complexity of the model and most importantly cannot be modified while it is running. A prescribed system of forces interacting with the rigid body will determine the timetrace of the states values. This type of simulation is useful for design study or validation for virtual prototyping.
Within the real-time strategy (RTS) requirements, the simulation needs to satisfy two conditions:
1. Real-time execution: ability of compute the t-th state update for the time step dt before the simulation time = t 0 + dt occurs;
2. Environment interaction: ability to modify the evolution of states at time t > ti following the occurring event at time f;.
In order to achieve both requirements, the code computing the i-th state update needs to run faster than the wall-clock time ti = to + dt. Thus, very complex physics modeling needs to be carefully evaluated and benchmarked against the maximum frame rate engine tick. Second, the forces acting on the body need to update according to the event. Both conditions require therefore a time step synchronization between the game engine tick and the physics engine time step integration process.
Some approaches execute offline simulation and then import data which will be interpolated between two known and already solved simulation times. This approach requires knowledge of the system before an event occurs, hence it loses the flexibility of real-timeness. Moreover, interpolation techniques introduce numerical approximation because they do not solve the dynamics at the required t i , but compute an interpolated value for t i between the prior and next solved step.
The architectural design of this solver instead allows for satisfying the above requirements. A current 10 frame-per-second simulation has been conducted with an externally driven time step. This means that the physics engine works on demand with a provided time step from the game engine tick. At a 10 frame per second tick rate, the solver was able to run faster than real time, avoiding any lagging in the simulation output. Moreover, the NDI controller computed the forces per tick in co-simulation with the current state of the rigid body, by evaluating the forces necessary for trajectory tracking with respect to the previous time step state values.
Figure 3: Externally driven time step synchronization.
Figure 3 depicts a schematic of the physics engine interaction with external tick. Based on this schematic, the flow of operations and time step synchronization work as follows:
1. A rigid body is created based on the .ISON file configuration which specifies the geometric, inert ial and physical properties of the body, e.g. aerodynamics coefficients for a known aircraft type.
2. The game engine provides initialization for the four set of states previously specified, e.g. global position, body orientation, local linear velocity, and local angular velocity.
3. The game engine requests a step update providing the delta time step (function of its tick rate).
4. The rigid body integrates the internal states based on the previous converged step (or ICs if first step).
5. The rigid body sets the relevant dynamic states to the owning body, e.g. position, velocity. both linear and angular.
It should be noted that the numerical integration scheme will be chosen according to this time step synchronization. Among implicit, and explicit schemes, an explicit is preferred for several reasons. First, the time execution of an update has a constant wall-time execution because it is not based on a Newton-Raphson integration scheme, but more traditional Euler schemes, where the first derivatives are used to compute the next step.
Without going into detail about the two schemes (the reader can further research the differ- ences) , it is clear that an implicit scheme provides an unpredictable performance execution update depending on the smoothness of the external forces. It also does not guarantee (at least in its original design) a constant time step execution because it is designed to accelerate and slow down depending on the numerical stability of the simulation. Rather, the explicit schemes fit very well in a requirement for real-timeness driven by an external time step, which is exactly the design of figure 3.
The disadvantages of explicit methods - such as divergence of integration error - are greatly mitigated by smaller time step execution dictated by the game engine, which typically runs at 30 frames per second. Moreover, the mixed Euler /Exponential approach discussed later on as integration technique preserves the quaternion unit norm, a basic requirement for it to represent an accurate body rotation.
2 Nonlinear Inversion Dynamics Controller
In this section, we will derive the nonlinear dynamics inversion (NDI) formulation for a trajectory tracking of an aircraft under input commands from an artificial intelligence (Al) module or user inputs. This derivation has as background the work listed in [6], [7], [8]. However, there are some key differentiators from prior literature:
• Existing formulation has been developed in typical aerospace industry Tait-Bryan reference systems. As such, it is not applicable to the rigid body solver derived in the previous section.
• One could potentially use transformations similar to the ones developed in the rotation library to re-use existing derivations. However, this would lead to highly unoptimized algorithms which would miss the real-timeness requirement for this engine. Moreover, the amount of floating point conversions at each solver time step would provide numerical noise in the simulation results.
• The system has been developed to fulfill a data-driven approach for this engine. To fulfill this requirement, we decided to not implement “control mixer/surface deflection” as stated in the abov^mentioned literature, since that approach leads to a non-generic type of algorithm and requires customization per aircraft model. It would also add computation cost, which is again a key differentiator for the real-timeness of this engine.
• The dynamics response provided by surface deflections has been mathematically implemented via lag response filters which are easy tunable to achieve a characterization of the dynamic response of the real aircraft.
• Finally, the goal is to obtain a controller which does not require gain optimization before running, since again this would fight against the real-timeness of the engine requirements. Thus, a set of fixed bandwidth factors between fast, medium and slow dynamics have been used for the controller.
2.1 Derived Formulation in RTS
We begin the derivation by considering the body reference system attached to the aircraft from figure 1. We separate the longitudinal dynamics to the rotational dynamics as follows: the longi- tudinal dynamics is computed in steady-state dynamic equilibrium of forces for a point mass at the center of gravity of the aircraft; the rotation dynamics is computed as rigid body rotation for the single body composing the aircraft. Since the generic motion of a body in space is defined as translation plus rotation, this approximation fulfills the computation of forces necessary to follow a trajectory with translation plus rotation of the aircraft. It must be emphasized that this reduced order modeling (ROM) is only used for providing steady-state controller forces to the rigid body differential equations. The output dynamics of the aircraft remains fully computed as 6DOFs with- out approximation. The following section will provide a detailed description of the co-simulation between controller forces and rigid body solver.
Following [11] and [12], the free body diagram of the point mass system in RTS reference system is depicted in figure 4, with the relevant longitudinal dynamics forces acting on it.
Figure 4: RTS point mass aircraft model with linear dynamics.
The relevant forces responsible for the longitudinal dynamics of the aircraft are:
• Thrust T in the direction of the body linear velocity
• Drag D opposite to the body linear velocity
• Lift L perpendicular to the body linear veloc on a plane rotated of roll angle 0
• Weight W
One can write the longitudinal and vertical equilibrium equation in the RTS y-z plane of the aircraft as follows:
Additionally, we can exploit the constant radius turn equation for planar motion - see [11] (3.1) for the derivation - for a simplified relationship between the yaw angle and roll angle Φ of an aircraft executing a coordinate turn with a climb angle 7:
Within the NDI formulation we need to define the control variables CV (see [12]) which will be the input of our controller. This is an arbitrary choice of the controller designer, and since typically an external Al module or user would want to control an aircraft in terms of speed, an altitude and a heading angle, we will select the following control variables:
(2-3)
We will then select the following state variables from the 6DOFs body which affect the longitudinal dynamics:
(2-4)
The next step is writing a Jacobian matrix able to transform time derivative of the state variables (2.4) into time derivative of the control variables (2.3). By doing so, we will be able to express equations (2.1) and (2.2) in terms of the control variables, which is our ultimate goal. The order of derivation of this Jacobian matrix needs to be sufficient to show an order of derivation equal to desired control variable derivatives
Hence, we will write the following: The reader can verify the above expression, noticing that:
Now we can carry out the following multiplication:
By substituting the equations (2.1) and (2.2), we can derive the expressions of the body reference system forces which need to be applied to the 6DOFs system for input commands as a function of the control variable derivatives.
The first equation for lift L can be is as follows, where W = mg:
The drag D can now be computed as function of lift L, using customer provided polar aerody- namics coefficients (for their expression, refer to the next section of this paper):
Finally, the thrust T can now be computed as follows:
At this point, we can compose the full body force vector expressed in RTS reference system which are the input to the rigid body without any control mixer or surface deflection:
The remaining quantities from this first controller will then be passed in the rotation dynamics section comprised of other two controllers, whose output will provide the three remaining moments in body local RTS reference system.
Following [8] and [10] nomenclature, we can now provide inputs to the slow and fast rotation dynamics. The difference here is that the control derivatives herein derived are meaningless within RTS formulation, hence we need to rc-dcrivc them according to the 6DOF developed prior. Also, as for the forces computed in (2.10), we will use provided moments in the body local reference system which can be directly applied to the rigid body rather than to a control mixer or surface deflection system. Please refer to the previous paragraphs for an explanation of this reasoning. Second, the dynamic response of the aircraft regarding rotation dynamics will be taken into account with a fast lag filtering as explained in [9] . This has been proven sufficient to capture the response dynamics of the aircraft within this modeling technique.
For the second controller, we select the control variables angle of attack α, slip angle β and roll angle 0, which are outputs or computable from the first controller: while the body states selected are the three Euler angles representing the orientation of the body and the three components of the linear body velocity v (t):
The first, step is mapping the output from first controller to equation 12,111, We notice that a kinematic coordinate turn requires maintaining a slip angle null. Second, the angle of attack can be obtained again from the customer data characteristic airfoil as in figure 5 - this can be obtained by either linear interpolation or look up table of the linear region from this plot (m and n coefficients), limiting its validity from —2° to 18°:
Different aircraft may have steeper characteristics or different stall limits. Finally, the roll angle is directly computed as output from the coordinate turn inversion equation (2.2):
Figure 5: Relationship between lift coeflicieut and angle of attack.
Given the provided by the RTS rigid body, the angle of attack α and the side-slip angle β are defined as follows: a = tan" 1 (~^)
Hence the Jacobian matrix here is expresses] as follows:
We can define the transfer function matrix. G x from the desired output from this controller, which is the body angular velocity to the derivative of states (2.12). We will recognize here the matrix (1.6) which provides the derivative of Euler angles if applied to the body angular velocity vector, and the equation (1.26) with zero input force
Now we have all the pieces to compose the NDI law of the second controller: which can be inverted to provide the following final transfer function for second controller: where the transfer function T has the following three column vectors: The output from equation (2.19) is then fed into a third controller for fast rotation dynamics. The Jacobian of this final NDI controller is the Identity matrix 3x3, since the control variables are the body angular velocity (computed by second controller) and the output are the moments in body reference frame. Such a relationship is the Euler equation of motion for the RTS rigid body, equation (1.27), in which we use the derivative of control variables as angular accelerations:
2.2 Co-simulation with Rigid Body
The following figure 6 summarizes the series of operations in cascades on the 3 NDI controllers working in co-simulation with the RTS rigid body.
Figure 6: Schematic of the three NDI controllers in cascade.
It is clear from equation (2.6), (2.19), and (2.20) that the three NDI blocks take as input the derivatives of the control variables and not the control variables (CV) themselves. Thus, it is necessary to provide a relationship between the commands CV1 (desired trajectory provided as input to 1 st controller), CV2 (1 st controller output provided as input to 2 nd controller), CV3 (2 nd controller output provided as input to 3 rd controller), and their respective derivatives, as required by equations (2.6), (2.19), and (2.20).
As we can see from the diagram, the controller receives feedback from the previous iteration states of the rigid body (global position, linear global and local velocity, orientation, angular veloc- ity), to compute current iteration step forces which allow the integration of current iteration state within the rigid body. This is known as co-simulation approach, because of the tight interaction between the history of the two components. Suffice it to say that the time histories of rigid body and controller need to be carefully tied together as described in this paragraph.
Additionally, as in every control strategy, we will add a feedback loop control responsible for closing any error between the current rigid body state iteration and the desired input value at that particular time. This will be part of the input to each NDI controller, and its function is correcting any discrepancy that the model has with the desired input. We will not use any gain optimization technique, but a simple unit proportion gain, since for NDI controllers the dynamic inversion provides a sufficiently accurate guidance to the system, and therefore we need to rely less on proportional- integral-derivative (PID) strategies - see [10], [11] , [12] for comparative results and differentiators from the gain selection choices therein. Following the figure 6 from left, the three inputs are provided as step commands from an external entity, such as Al or user module. A step command is not realistically achievable by any mechanical devices since inertia plays a fundamental role in the dynamic evolution of the system. Thus, the CV1 needs to be translated into smooth and continuous control laws to the controller. Moreover, the derivation of NDI shows that at least a second order differentiation needs to be achieved by the altitude. Hence, we develop an analytical polynomial piecewise expression which should at least support C2 requirements (continuous and derivable up to the second order). This will guarantee one can obtain from a given command the first and second derivative over time. The time execution of the whole command is a characteristic of the aircraft and therefore must be provided as input data, e.g. a commercial aircraft has a turning and climb rate much lower than that of a fighter jet. The knowledge of this rate allows us to compute the maneuver time, e.g. the time from the initial state when the external command started and the final time needed to reach the external command.
We will consider an example of input climb command to show how to create signal command, first derivative of the command and second derivative of the command. Velocity and heading inputs can be mathematically obtained in the same way, although the second derivative is not strictly needed in equation (2.6). The time to execute the total maneuver is computable as:
Knowing the total time of maneuver, we are going to divide it into three segments (they could be equally or differently spaced depending on the style of the autopilot). As mentioned, we need to make sure that a piece-wise definition of the control law still produces continuous derivatives for the signals up to the second order. This will avoid discontinuity on forces definition which would produce spikes in the acceleration of the rigid body integrated states. In order to obtain that, we define the piecewise function as follows:
1. A first smoothing phase between signal initial and the linear value provided by signal rate at the end of the first sector. The first and second derivative will be both smooth polynomial during this phase.
2. A second linear phase in which the command is expressed by the linear function with slope equal to signal rate . The first derivative will be constant, and the second derivative will be null.
3. A third smoothing phase from the linear value provided by signal rate at the end of the second sector and the value signal final .he first and second derivative will be both smooth polynomial during this phase.
To guarantee continuity at the connection phase, we define a Hermitian polynomial for the first derivative of the command during phase 1 and 3. In this way, the signal command will be the integral of this function and the second derivative of the command will be the derivative of this polynomial.
We leave to the reader to derive the expression of the linear function during phase 2 - it is a simple linear equation based on simulation time of type y = m * x + n. The analytical expression of the smooth signals used during phase 1 and 3 are expressed below.
For the below example, we assume we want to reach a rate of climb of mi = 15.24 m/s from mo = 0, in an amount of time equal to 1/3 of the total maneuver time. The actual simulation time needs to be linearly mapped between zero and one, as required by the Hermitian interpolation function. The first derivative of the command is expressed by equation (2.21) and represented in figure 7:
Figure 7: First derivative of the command.
By integrating with respect to time equation (2.21), we can then find the corresponding signal command which brings our slope from mo = 0 to m 1 = 15.24 m/s. The signal command is expressed by equation (2.22) and represented in figure 8:
Figure 8: Signal command.
By deriving with respect to time equation (2.21), we can then find the corresponding second derivative of the command which brings our slope from = 15.24m/s. The second derivative of the command is expressed by equation (2.23) and represented in figure 9:
Figure 9: Second derivative of the command.
We leave to the reader the exercise of implementing phase 3, where we can reuse equations (2.22), (2.21), and (2.23) to compute respectively the signal command, the first derivative of the command, and the second derivative of the command which brings OUT slope from m± = 15.24 m/s to mo = 0.
At this point we have all the pieces to compose the input to first controller (CV1), second controller (CV2), and third controller (CV3). For CV1, the control laws already provide the derivatives of control variables as analytical functions - see equations (2.22), (2.21), and (2.23), so we will be adding only the contribution of the feedback loop for closing the error. That is, with reference to (2.6), CV1 is expressed as: where the subscript cmd indicates the signal command values from (2.22) and the subscript cur indicates the value from the previous converged i-th states from RTS rigid body. One can notice in the expression both the closed loop error contribution with proportional gain equal to 1 and the analytical command derivatives.
For the second controller, with reference to equation (2.19), no analytical expression is available for CV2. Thus, according to standard procedure in control theory, we approximate the derivatives as cmd value — cmd state multiplied by a bandwidth. Since the second controller is responsible for the slow rotation dynamics, we will use a lag response system as designed in [9] to capture the dynamic response of “control mixer/surface deflection”. We will use bandwidth gains of 2rad/s for a and /3, and 1.5 rad/s for (b as advised in [8]:
Similarly, for the third controller, CV3 for equation (2.20) will be computed with a bandwidth gain of 10 rad/s to differentiate the fast dynamics of the body angular velocity vector from the slow
In conclusion, we now have all the inputs to run the co-simulation between a 6DOFs rigid body and a series of NDI controllers, receiving the input as control laws from external modules such as Al or user commands. While no external command is acting, the controller still tracks the current states of the rigid body versus the last known desired commands. Thus, this co-simulation package provides a complete way for aircraft autopilots both to maintain a route under effect of random external excitations, such as wind force applied, or to change the relevant flying conditions, e.g. altitude, speed, and/or heading.
For completeness, we will show some results where the three control laws for velocity change (figure 10), altitude change (figure 11), and heading change (figure 12) have been implemented by coding equations (2.22), (2.21), and (2.23) into MATLAB® Functions™. These inputs will enable validation against the results of Simulink® Aerospace Blockset™.
Figure 10: Velocity Control Laws.
Figure 11: Altitude Control Laws.
Figure 12: Heading Control Laws. 3 Mixed Euler /Exponential Numerical Integration
In this section, we will describe the numerical integration scheme which has been adopted for integrating the equations of motion of the rigid body, once the controller has computed the forces from the previous converged step (or from initial condition states if it is the first integration step). We previously recommended the choice of the numerical integration scheme in consideration of the externally driven time step, as 4 th order Rung^Kutta. This scheme is widely accepted for its performance and robustness. The novelty to follow will be the approach of mixing a traditional 1 st Euler approach with the novel Exponential quaternion integration exploiting the Lie Group algebra. References to these numerical integration schemes can be found in [13], [14], [15], [16].
3.1 Mixed Euler RK4 and Exponential RKMK4
The typical approach to integrate differential equations from time with the explicit algorithm RK4 - Runge-Kutta 4 th order - can be summarized as follows: where the coefficients ayj, bj and c,- can be found from the Butcher table for 4 th order - see figure 13. This approach is usually implemented for continuous states which have no restriction to their own domain, thus will be applied to solve equations (1.28), (1.30) and (1.31).
It should be clear to the reader that a brute-force application of first Euler integration method to equation (1.29), would violate the integrity condition for quaternion states, which requires the following equation to be satisfied in order to represent a rotation:
Hence, a simple Euler approach for integration of quaternion is mathematically incorrect because it violates the previous condition:
Figure 13 : Explicit coefficients from Butcher table for 4 th order Runge-Kutta.
Some approaches try to correct the equation (3.2) by either re- normalizing the quaternion after each update or by forcing a small time step integration which would slightly deviate the quaternion itself from having unit norm. This renormalization can be expensive, and it is not geometrically correct because it provides a projection of the non-normalized quaternion back on the unit circle, deviating therefore from the correct position of the incremented quaternion. Results are shown to be acceptable (see [14] ) only if the time step is sufficiently small:
Instead of being limited by small-time step or losing accuracy by projecting non-proper Euler parameters back on the unit circle, we chose to implement a mixed approach for integrating equation (1.29). The body angular velocity from equation (1.31) , integrated with MK4, it is used within a RKMK4 algorithm described in [13] , This second integration scheme preserves the unit of the quaternion via the exponential update^ and although computationally more intensive, it provides mathematically accurate Euler parameters without resorting to patch normalization or relying on a small time steps to hide the numerical error therein.
Two main operators are needed to implement the RKMK4 algorithm: the exponential mapping of a Cartesian vector to quaternion and the inverse right Jacobian associated with the body angular velocity - see [13] and [16], The exponential mapping of a vector u is expressed as follows: while the inverse right Jacobian associated with the body angular velocity of a vector u is expressed as follows:
(3-4)
Once we have these operators, we can implement the mixed RK4-RKMK4 approach. We begin integrating equations (1.28), (1.30) and (1.31) for the i-th stage using the current orientation quaternion - either IC value or previous converged value, using the equations set (3.1) for stage i-th. At this point, we compute the corresponding i-th stage for the quaternion using the RKMK4 outlined in detail below. This will use the just calculated i-th stage value of body angular velocity to compute the corresponding i-th stage value of the quaternion for equation (1.29). The process then repeats for the i-th + 1 stage, by using first RK4 - for global position, body linear velocity and body angular velocity - and then RKMK4, for quaternion orientation.
Equation (3.1) is well known in literature, thus we leave to the reader its expansion for the stages 1, The corresponding equation set for RKMK4 - Runge-K utta-M unth^Kaas is detailed as follows, using the exponential mapping (3.3) and the inverse right Jacobian (3.4):
We can now expand equation (3.5) for each of the four stages using the corresponding computed angular velocity from (3.1) - the formulas show the moment when we must send information to RK4 (#2 providing the current orientation) and when we must receive information from RK4 (#3 retrieving the corresponding body angular velocity). This synchronization is important to maintain state consistency between the two algorithms working in parallel.
• The first stage of RKMK4 for s = 1 is:
• The second stage of RKMK4 for s = 2 is:
• The third stage of RKMK4 for s — 3 is:
• The fourth stage of RKMK4 for s = 4 is:
• The summation stage or RKMK4 which provides the dt quaternion update is:
Finally, we have all the detailed stage expansions for integrating the quaternion from value θ k to value for a time step dt, as well as the parallel integration of equations (1.28), (4.30) and (1.31), based on the i-th stage quaternion value. As is evident, no quaternion normalization is required, and it can be verified by numerical assertions that the above operations maintain quaternion state integrity to correctly represent a rigid body rotation.
3.2 Specialized Containers for Mixed Approach
The above exponential integration requires more floating point operations than the standard Euler approach (RK4). Thus, specialized containers for high performance matrix computation should be developed by the implementation of this code to maintain real-time performance even with higher computational costs.
From our testing, a vectorialized approach in 3x3 matrix multiplication using a modern compiler was able to achieve high computational speed. Given the sequential requirements of the sets of operations between RK4 and RKMK4, parallel implementation did not provide any performance improvement. Dynamic memory also showed a consistent slowdown in computation.
Compiler-based vectorization from Visual Studio 2019 provides about 10% speed improvement in a standard N 2 loop needed for 3x3 matrix multiplication with respect to the open source Eigen library for the standard RK4 algorithm.
By using these containers over the RKMK4 algorithm, we measured a 5% slowdown with respect to the Eigen library for the RKMK4. This delta of 15% gap between RK4 and RKMK4 is consistent with experiments shown in literature - see [13]. However, the higher quality of results on a fast package composed by RTS RigidBody, NDI Controller, and Mixed RK4/RKMK4 integrator, is the preferred choice for a real-time physics engine.
Figure 14: Operators for Hamiltonian and Lie Group algebras.
From a mathematical standpoint, the above-mentioned specialized containers must implement both the Hamiltonian algebra to efficiently handle quaternion operations, see (3.2), and the Lie Group algebra to handle the RKMK4 operations, see (3.3) and (3,4) . The reader can review the mathematical details of both algebras in [13] and in [16]. Figure 14 shows the operators which implement those two algebras, while figure 15 shows the class declarations for the components described in the previous sections.
Figure 15: Class declarations for physics engine components.
4 Airbus A320 Aircraft Input Data
In this section, we will describe the parameterization of both rigid body and controller to simulate Airbus A320 commercial aircraft. The major differentiator from existing literature modeling is the “data-driven” design approach used for the controller. A set of NDI controllers such as the ones described in the previous section are generally model dependent, in the sense that properties of the real model which is simulated need to be carefully replicated in the controller to provide accurate forces to the rigid body. This is the approach followed by [10], [7], [8], [6]. Although this approach is widely adopted in the industry, it clashes with the “data-driven” approach which is a requirement of this physics engine, particularly in the modeling of the “control mixer/surface deflection” componentization. For example, an Airbus A320 has wings with six ailerons, one rudder and one stabilizer. A Lockheed Martin F-117 Nighthawk has a completely different wing profile. Therefore, a control mixer developed for the Airbus would need to be re-written for the Nighthawk, providing a “model-driven” design.
4.1 Integral Effect of Force/Moments
Figure 16 based on the design suggested in [8] shows how our novel approach differs from existing literature:
Figure 16: Implemented “data-driven” approach in NDI controller.
Both Engine Dynamics and Actuators (control mixer) have been replaced with the body forces written in the local rigid body reference frame. An integral effect of the three forces (2.10) and three moments (2.20) has been computed for the rigid body local frame, and inertial correction considering the fictitious forces has been added to the Newton/Euler equations of motion (1.23).
The customer data which are necessary to compute these forces, as well as the rigid body parameters needed to characterize the rigid body, can be divided into four sections: 1. Inertial - used by RigidBody and Controller:
• mass of the aircraft
• moment of inertia of the aircraft
2. Geometrical - used by Controller:
• surface reference for the airfoil
3. Aerodynamics - used by Controller:
• airfoil lift coefficient versus angle of attack
• polar diagram lift versus drag coefficient
4. Performance - used by Control Law:
• climb and descent rate for the aircraft
• heading change rate for the aircraft
Let us examine how these data are used with reference to the equations developed in the previous sections. The mass and the moment of inertia of the vehicle are used both in the differential equations for rigid body - Newton/Euler ODEs (1.30) and (1.31) - as well in the NDI controller #1 and #3 - equations (2.7), (2.9), (2.10), (2.20). The moment of inertia needs to be computed in RTS from Tait-Bryan using equation (1.22).
Equation (2.8) uses this parameter within the lift and drag coefficients and the dynamic pressure
Q, defined as:
(4-1)
The density of the air must be computed according to the geopotential altitude of the aircraft along with the speed of sound to compute the Mach number (speed) of the aircraft, according to the following look up table in figure 17:
Figure 17: Density and speed of sound as function of the geopotential altitude.
The airfoil lift coefficient versus angle of attack has already been discussed in equation (2.13) and relative figure (5) .
The polar diagram lift versus drag coefficient is another key parameter which ties together the lift and drag depending on the profile of the airfoil. These coefficients are necessary for computing equation (2.8) and a typical customer example can be seen in figure 18.
Figure 18: Lift versus Drag polar coefficients as function of multiple angles of attack.
Climb rate (2000 feet per minute for A320) and heading rates (120° in 600 s for A320) are used to compute the correct control laws as explained in the co- simulation section. Their contribution is used in equations (2.21), (2.22), and (2.23) and their examples are used in figures 11 and 12. For the velocity control lave, we tune a change in velocity with the same maneuver time of the climb rate in order to maintain an angle of attack of 1° which enables a steady flight at the beginning and ending of maneuver - the relevant control law can be seen in figure 10.
These steady flight conditions can be calculated by means of a performance spreadsheet with the above information. Below are reported two calculation examples, with the performance parameters necessary to maintain 1° angle of attack at different altitudes, for Airbus A320 (figure 19) and Lockheed F-117 Nighthawk (figure 20). It is noteworthy that, in order to climb from 5,000 m to 10,000 m, the commercial aircraft takes 492 s versus the 164 s of the military aircraft.
5 Accuracy Validation of Dynamic Response
In this section, we will provide a comparison of the package developed in C++ through the imple- mentation of the formulations derived in this paper versus Simulink® Aerospace Blockset™. This commercial package provides a similar 6DOFs rigid body system implemented in Tait-Bryan for- mulation and uses Euler angles as orientation parameters. The Simulink model has been simulated with a standard RK4 solver - named ode4 - and fixed time step, in order to provide similar inte- gration parameters to the C++ physics engine. This same product has also been used in [10] et al. to validate typical NDI controllers with “control mixer/surface deflection”.
In addition to the standard Simulink 6DOFs block, we implemented in the same block diagram a version of our controller using MATLAB® Functions™. This was necessary to provide a comparison with our C++ physics engine comprised of the classes shown in figure 15.
It also should be noted that Simulink® Aerospace Blockset™, along with other MathWorks products, are the gold standard in the aerospace industry for validating real aircraft dynamics - see Lockheed Martin testimonial in figure 21. Thus, validating the output of the new C++ physics engine against Simulink® Aerospace Blockset™, we confirm the quality of the results of our physics engine.
Figure 21: Lockheed Martin uses MathWorks products to predict F-35 fleet performance.
5.1 In-core Real Time Simulation
The following are the key differentiators between the new C++ physics engine and the Simulink® Aerospace Blockset :
• We built a model in Simulink Aerospace Blockset using the Euler angles formulation for the 6DOFs model - this was done on purpose to verify our implementation with quaternion orientation used within the C++ Rigid Body.
• The mixed algorithm RK4/RKMK4 differs from the standard ode4 implemented in Simulink, which is similar to a fixed time step RK4.
• Simulink works on Tait-Bryan reference system formulation, while our package has been entirely written in RTS formulation.
• Customers use Simulink models to run offline simulations and then post-process results. We instead use a game engine tick to drive the rigid body in a real-time simulation.
The comparative model in Simulink is shown in figure 22.
Figure 22: Simulink® Aerospace Blockset™ with MATLAB® Functions™.
Comparing figure 22 with our C++ class implementation shown in figure 15, we can make the following functional correlation:
• “Simulink 6DOF (Euler Angles)” corresponds to the classes Matrix4D, RigidBodyD, Vec3D, Mat 3D, and QuatD
• “Al Control Laws” corresponds to the class ControlLawD • “NDI Controller” corresponds to the classes ControllerBaseD, AirplaneControllerD, and
EulerAnglesD
The block masks “Al Controller Laws” and “NDI Controller” contain a set of MATLAB Func- tions used to implement in m-code the control laws and the NDI controller logic implemented in C++ classes to allow a one-to-one comparison between an offline simulation over Simulink model and an in-core simulation of the physics engine.
Figure 23 and figure 24 show the MATLAB function blocks containing the source code for the NDI controller and the control laws. It should be clear why we need a conversion in/out to the NDI RTS controller block. Simulink 6DOFs rigid body accepts only states conditions in Tait-Bryan formulation, hence for the sake of this comparison, a conversion TB → RTS must be the input of this RTS controller, and a conversion RTS → TB must be the output of this RTS controller. This guarantees state consistency within the Simulink platform - see equations (1.14) through (1.22) for details.
Figure 23: NDI controller implemented with MATLAB Functions.
Figure 24: Control laws implemented with MATLAB Functions.
This model setup can now be used for an accurate comparison against the C++ physics engine.
5.2 Constant Accuracy of l.e-6 (SI Physics Units)
We can now carry out a detailed state comparison at each time step between the Simulink output and the C++ physics engine. Given a fixed time step equal to 0.1 s with ode4 and a simulation time of 2,500 s in Simulink, we can compare the error after 25,000 solver evaluations, each evaluation composed by four stages. It is clear that any error in the integration state would accumulate over time, hence claiming an accuracy over 1 s is very easy, while it is much harder to obtain a constant accuracy after 41.67 min of flying time, for example.
It should be evident that by evaluating such a long simulation time, we are testing a potential high level of numerical inaccuracy - a small error would cumulatively sum-up over time, providing a divergence of results at the end of the simulation. Thus, it is numerically very challenging to achieve such level of accuracy by two different numerical solvers which integrate differential equations produced by such different formulations - see the formulas of this paper for reference.
Thus, our achieved results of a constant accuracy across all the states of the rigid body - global position, global linear velocity, body linear velocity, body angular velocity, Euler angles - guarantees without a doubt that the output of the two software are consistent without a divergence in integration error. The dynamics of two aircraft simulated by different software - Simulink versus C++ physics engine - is exactly the same. With that in mind, we can claim an accuracy of l.e-6 in SI Physics Units over a traditional offline simulation, while implementing a real-time in-core simulation driven by the game tick.
The above claims have been proven by internal unit tests over the developed libraries and can be seen on the following series of plots, where only a zoom below l.e-6 reveals a differentiation in the floating point values - see figure 25, 26, and 27. Note also that, in figure 27, the derivative of the traces of the error are parallel, which proves a constant offset below l.e-6 with no accumulation of error through the dynamic simulation. This means that the two software produce outputs which are consistent at the micron level (1 pm). Moreover, as seen in figure 25, the C++ physics engine is able to simulate 41.67 min in 0.38 s.
Figure 25: 2,500 s comparative simulation with Simulink Aerospace Blockset.
Figure 26: Details of second order dynamics response.
Figure 27: Parallel traces between Simulink and Rigid Body, differing at l.e-6.
For completeness, we will conclude by showing the full results of the simulation for the C++ physics engine during the test maneuver: climb from 5,000 m to 10,000 m, change in heading of 120°, descend to 5,000 m. The internal states for the C++ physics engine have been exported in mat file via MathWorks MATFile facilities, to allow post-processing. The plots show the output in standard aerospace NED reference frame.
Figure 28: Trajectory summary for 2,500 s simulation on Airbus A320.
Figure 29: Global position - C++ physics engine transformed into NED.
Figure 30: Global linear velocity - C++ physics engine transformed into NED.
Figure 31: Body linear velocity - C++ physics engine transformed into NED.
Figure 32: Body angular velocity - C++ physics engine transformed into NED.
Figure 33: Euler angles orientation - C++ physics engine transformed into NED.
Figure 34: Forces computed by controller - C++ physics engine transformed into NED.
Figure 35: Torques computed by controller - C++ physics engine transformed into NED.
Figure 36: Angle of attack and side-slip - C++ physics engine transformed into NED.
References
[1] A. A. Shabana, Dynamics of Multibody Systems, Cambridge University Press (2013).
[2] NASA Mission Planning and Analysis Division, Euler Angles, Quaternions, and Transformation Matrices, NASA Lyndon B. Johnson Space Center (Jul. 1977).
[3] W. G. Breckenridge, Quaternions proposed standard conventions, NASA Jet Propulsion Lab- oratory, Technical Report (Oct. 1979).
[4] R. F. Stengel, Flight Dynamics, Princeton University Press (2004).
[5] M. Zyskowski, Aircraft Simulation Techniques Used in Low Cost, Commercial Software, AIAA Modeling and Simulation Technologies Conference and Exhibit (2003).
[6] D. Enns et al., Dynamic inversion: An evolving methodology for flight control design Interna- tional Journal of Control, vol. 59, no. 1, pp. 71-91 (1994).
[7] R. Adams et al., Design of nonlinear control laws for high angle of attack flight, Journal of Guidance, Control, and Dynamics, vol. 17, no. 4, pp. 737-746 (1994).
[8] S. A. Snell et al., Nonlinear Inversion Flight Control for a Supermaneuverable Aircraft, Journal of Guidance, Control, and Dynamics, vol. 15, no. 4, pp. 976-984 (1992).
[9] J. Beaty, Introduction to Digital Signal Processing (DSP), Systems Analysis & Concepts Di- rectorate, NASA Langley Research Center, Hampton, VA (2011).
[10] D. Dierker, An Automated Controller Design Methodology for Six Degree of Freedom Aircraft Models, Master’s thesis, Wright State University, Dayton, Ohio (2017).
[11] K. Shimmin, An architecture for rapid modeling and simulation of an air vehicle system, Master’s thesis, University of Dayton, Dayton, Ohio (2016).
[12] J. Brendlinger, Development of Guidance Laws for a Reduced Order Dynamic Aircraft Model, Master’s thesis, Wright State University, Dayton, Ohio (2017).
[13] A. Sveier, et al., Applied Runge-Kutta-Munthe-Kaas Integration for the Quaternion Kinematics, Journal of Guidance, Control, and Dynamics, vol. 42, no. 12, pp. 2747-2754 (2019).
[14] M. S. Andrle, and J. L. Crassidis, Geometric Integration of Quaternions, Journal of Guidance, Control, and Dynamics, Vol. 36, No. 6, pp. 1762-1767 (2013).
[15] P. E. Crouch, and R. Grossman, Numerical Integration of Ordinary Differential Equations on Manifolds, Journal of Nonlinear Science, Vol. 3, No. 1, pp. 1-33 (1993).
[16] A. Iserles, H. Munthe-Kaas, S. Nprsett, and A. Zanna, Lie-Group Methods, Acta Numerica, Vol. 9, pp. 215-365 (2000).