## 3 Disturbance Rejection Dynamic Inverse Control
### Problem Formulation and Control Objective  
For NDI controller design, the equations of angular motions are rewritten in the form of a nonlinear affine system:  
\[\left\{ \begin{array}{l}\dot{x}_{1}=f(x_{1},x_{2})+g(x_{1},x_{2})u+d_{1}\\ \dot{x}_{2}=h(x_{1},x_{2})+d_{2}\\ y=x_{2}\end{array} \right. \tag{12}\]  
with the fast states \(x_{1}=[p,q,r]^{T}\), the slow states \(x_{2}=[\alpha,\beta,\mu]^{T}\), the input vector \(u=[\delta_{u},\delta_{e},\delta_{r}]^{T}\), the output vector \(y\), and the mismatched disturbances of \(d_{1},d_{2}\). The nonlinear behavior of the system lies in the continuous vector functions of \(f(x_{1},x_{2})\), \(g(x_{1},x_{2})\) and \(h(x_{1},x_{2})\). \[f=J^{-1}\left(-x_{1}\times Jx_{1}+\left[\begin{array}{c}QSb\Big{(}C_{l0}++ \hat{C}_{l_{p}}\hat{p}+\hat{C}_{l_{r}}\hat{r}\Big{)}\\ QS\bar{\varepsilon}\Delta C_{m_{\delta_{e}}}\Big{.}\ \ \ \ \ \ \ \ \ \ \ QS\bar{\varepsilon}\Delta C_{m_{\delta_{e}}}\ \ \ \ \ \ \ \ \  
The inner loop is responsible for the inversion of the nonlinear aerodynamic database and attitude dynamics. For the application of NDI, the attitude dynamics are here rewritten in the state-space form:  
\[\dot{x}_{1}=f(x_{1},x_{2})+g(x_{1},x_{2})u \tag{16}\]  
\[y_{1}=x_{1} \tag{17}\]  
Recall the approach of feedback linearization, Equation (17) should be successively time differentiated until a relation between the input \(u\) and the output \(y_{1}\) is found. After one time differentiation, Equation (17) yields  
\[\dot{y}_{1}=\dot{x}_{1}=f(x_{1},x_{2})+g(x_{1},x_{2})u \tag{18}\]  
Substituting the desired differentiated output with the pseudo-control input of Equation (19), the inversion control law of Equation (20) is obtained by inverting Equation (18), the resulting closed inner loop is expressed in Equation (21). \[\dot{y}_{1}^{d}=B_{1}(x_{1}^{c}-x_{1}) \tag{19}\]  
\[u=g^{-1}[B_{1}(x_{1}^{c}-x_{1})-f] \tag{20}\]  
\[\dot{x}_{1}+B_{1}(x_{1}-x_{1}^{c})=0 \tag{21}\]  
where the superscript \(d\) represents the desired value, the superscript \(c\) represents the command from the outer loop as shown in Figure 3. The bandwidth matrix \(B_{1}\), described in Equation (22), is responsible for stabilizing and improving the performance of the closed-loop system when the inversion or the model is not exact. \[B_{1}=\left[ \begin{array}{ccc}k_{p}&0&0\\ 0&k_{q}&0\\ 0&0&k_{r}\end{array} \right] \tag{22}\]  
As the steady-state error in the inner loop will be solved by inserting an integrator in the outer loop, \(B_{1}\) is only composed of the proportional elements. The gains of \(k_{p},\ k_{q},k_{r}\) are tuned to achieve rapid step response without exciting structural modes or exceeding the bandwidth limitations of the actuators [46]. The outer loop performs the inversion of the attitude kinematics equations, which are rewritten as:  
\[\dot{x}_{2}=h(x_{1},x_{2}) \tag{23}\]  
\[y_{2}=x_{2} \tag{24}\]  
Similar to the inner loop, the output of Equation (24) is not immediately invertible and should be time differentiated once. \[\dot{y}_{2}=\dot{x}_{2}=\left[ \begin{array}{ccc}-\tan\beta\cos\alpha&1&- \tan\beta\sin\alpha\\ \sin\alpha&0&-\cos\alpha\\ \sec\beta\cos\alpha&0&\sec\beta\sin\alpha\end{array} \right]x_{1} \tag{25}\]  
Figure 3: Configuration of the baseline nonlinear dynamic inversion (NDI) controller. \[\dot{y}_{2}^{d}=B_{2}(x_{2}^{c}-x_{2}) \tag{26}\]  
The outer loop control law is computed by substituting Equation (26) into Equation (25) and then inverting it. \[x_{1}^{c}=\left[ \begin{array}{ccc}-\tan\beta\cos\alpha&1&-\tan\beta\sin\alpha \\ \sin\alpha&0&-\cos\alpha\\ \sec\beta\cos\alpha&0&\sec\beta\sin\alpha\end{array} \right]^{-1}B_{2}(x_{2}^ {c}-x_{2}) \tag{27}\]  
resulting in the closed outer loop  
\[\dot{x}_{2}+B_{2}(x_{2}-x_{2}^{c})=0 \tag{28}\]  
To improve the steady-state performance in the presence of modeling uncertainties, proportional-integral elements (NDI-PI) are used in the bandwidth matrix of \(B_{2}\). \[B_{2}=\left[