# Dynamic Modeling and Altitude Control for Flying Cars Based on Active Disturbance Rejection Control
## 3 Active Disturbance Rejection Controller  
As shown in Figure 3, to compensate for the external disturbances, a double-loop controller is designed based on active disturbance rejection control. In the flying car system, the flight altitude is controlled by adjusting the thrust of the propellers, and the rotation speed of the propellers is controlled by the motor. In the proposed controller, the system input of the outer-loop controller is the flight altitude of the flying car. The control input of the outer-loop controller is the thrust of the propellers. The outer-loop controller calculates the reference thrust for the inner loop. The inner-loop controller controls the rotation speed of the motor. Its control input is the voltage of the motor. It dynamically changes the rotation speed of the motor. Then, using the propeller model, the thrust is transformed into the dynamic model of the flying car to control its flight altitude. Taking the outer-loop controller as an example, the flight altitude can be expressed as:  
\[\left\{ \begin{array}{c}\ddot{h}(t)=f(t,h(t),\dot{h}(t),w_{dt}(t))+b_{1}(t)u_ {1}(t)\\ y=h(t)\end{array} \right. \tag{22}\]  
where \(h\) denotes the flight altitude, \(b_{1}\) denotes the control gain of the outer-loop controller, \(u_{1}\) denotes its control input, \(w_{dt}\) denotes the external disturbance, and \(y\) denotes the system state. Firstly, define \(f=f(t,h(t),\dot{h}(t),w_{dt}(t))\), \(X_{1}=[x_{1},x_{2},x_{3}]^{T}\). Equation (22) can be transformed into the form of a state space expression. It is expressed as:  
Figure 3: Double-loop controller based on active disturbance rejection control. \[\left\{ \begin{array}{c}\dot{x}_{1}(t)=x_{2}(t)\\ \dot{x}_{2}(t)=x_{3}(t)+b_{1}(t)u_{1}(t)\\ \dot{x}_{3}(t)=\dot{f}\\ y_{1}=x_{1}(t)\end{array} \right. \tag{23}\]  
where \(x_{3}\) denotes the total disturbance \(f\), \(x_{1}\) denotes the flight altitude, and \(x_{2}\) can be regarded as the vertical velocity. Based on Equation (23), the extended state observer (ESO) can be built as:  
\[\left\{ \begin{array}{c}\dot{Z}_{1}(t)=AZ_{1}(t)+B(t)u_{1}(t)+L_{1}\dot{y}_{1 }(t)\\ \dot{y}_{1}(t)=CZ_{1}(t)\end{array} \right. \tag{24}\]  
\[A=\left[ \begin{array}{ccc}0&1&0\\ 0&0&1\\ 0&0&0\end{array} \right],B=\left[ \begin{array}{c}0\\ b_{1}T\\ 0\end{array} \right],C=\left[ \begin{array}{ccc}1&0&0\end{array} \right] \tag{25}\]  
where \(Z_{1}=[z_{1},z_{2},z_{3}]^{T}\) denotes the observed state, \(\dot{y}_{1}\) denotes the sampling value of the system state, \(T\) denotes the sampling time, and \(l=[l_{1},l_{2},l_{3}]^{T}\) denotes the observation gain. It is clear that in ADRC, the main target is to compensate for the total disturbance \(x_{3}\), minimizing the error between \(X_{1}\) and \(Z_{1}\). To make sure that the observation error satisfies the upper bound, \(l_{i}\) should be set to \(-w_{o}(w_{o}>0)\), which can be expressed by:  
\[\lambda_{0}(s)=s^{3}+l_{1}s^{2}+l_{2}s+l_{3}=(s+w_{o})^{3} \tag{26}\]  
where \(l_{1}=3w_{o},l_{2}=w_{o}^{2},l_{3}=w_{o}^{3}\), with \(w_{o}\) denoting the observation bandwidth. Under this condition, the ESO can be built. The states can be accurately observed by the ESO. Based on this, the control input can be defined as:  
\[u_{1}=\frac{u_{0}-z_{3}}{b_{1}}=\frac{k_{p1}(r(t)-z_{1}(t))+k_{d1}(r(t)-z_{2}( t))-z_{3}}{b_{1}} \tag{27}\]  
where \(r\) denotes the reference flight altitude, \(k_{p1}=2w_{c}\), and \(k_{d1}=w_{c}^{2}\). In Equation (27), \(z_{3}\) is regarded as the total disturbance. Using Equation (27), Equation (22) can be rewritten as:  
\[\ddot{h}(t)=f+b_{1}u_{1}=f+u_{0}-b_{3}\approx u_{0} \tag{28}\]  
Thus, in Equation (28), the error between \(z_{3}\) and \(x_{3}\) can be minimized. This nonlinear system can be regarded as a linear system. Under this condition, its control difficulty can be significantly reduced. It is also the main advantage of the active disturbance rejection control method. The outer-loop controller can be built based on Equations (22)-(28). The inner-loop controller has a similar structure.