## 5 Mathematical Modeling and the Control of Attitude Dynamics
### Controller Design
#### 5.4.3 Yaw-Rate Controller  
From Figure 11, by including the torque from the four motors for creating an unbalanced torque about the \(z\)-axis and considering the values of the moment of inertia of the octocopter and selected propeller in the \(z\)-axis, the open-loop transfer function of the yaw rate-control loop without the controller by taking the rate gyro gain as 0.86 volts/(rad/s) is given as follows:  
\[\left(\frac{\dot{\Psi}}{\dot{\Psi}_{\text{desired}}}\right)_{\text{open\_loop }}=\frac{20.915\times 10^{-7}}{[(1.524\times 10^{-10})s^{2}+(1.06\times 10^{-6})s+8.32 8\times 10^{-6}]}. \tag{26}\]  
The open-loop transfer function obtained from the yaw-rate control system is a Type-0 system. Therefore, a steady-state error exists for step input. Thus, the yaw rate controller's function is to obtain a faster response with zero steady-state error. Therefore, in this study, the selected yaw-rate controller was set as a proportional-integral (PI) controller. Here, the integral action is used to obtain the zero steady-state error, and proportional action is used to obtain a faster transient response. It was desirable to obtain the response of the octocopter without any overshoot for a desired yaw rate command to maintain further stability. Based on this, the desired controller specifications for the yaw-rate command are listed in Table 3.  
The PI controller required a pole to be placed at the origin to increase the system's type number by one. To retain the transient response, zero was placed close to the origin. Here, the PI controller's zero was selected as 0.01, and the transfer function of the PI controller  
Figure 14: Pitch response of the octocopter with the designed PD controller. \begin{table}
\begin{tabular}{c c} \hline \hline
**Specifications** & **Value** \\ \hline settling time & 0.005 s \\ overshoot & zero \\ steady-state error & zero \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Yaw rate controller design specifications. was given by \(\frac{\text{K}(\text{s}+0.01)}{\text{s}}\), where K is the forward-loop gain corresponding to zero overshoot and a settling time of 0.005 s.  
The pole location corresponded to a 0.005 s settling time of \(-800\). From the root locus of the yaw rate control system with the PI controller, the value of K corresponding to the pole location, 800, was found to be 355. From the standard form of the transfer function of the PI controller, the proportional gain KP = 355 and integral gain KI = 3.55. The octocopter response with the yaw-rate controller for the desired yaw-rate command was obtained using MATLAB, as shown in Figure 15.  
The controller gains are given in Table 4, and their responses are compared with and without the controllers in Table 5. From the comparison results, it is clear that the designed controllers satisfy our requirements. \begin{table}
\begin{tabular}{c c c c} \hline \hline \multirow{2}{*}{**Controller**} & \multicolumn{3}{c}{**Gains**} \\ \cline{2-4}  & **Proportional Gain, KP** & **Integral Gain, KI** & **Derivative Gain, KD** \\ \hline roll controller & 2240.28 & - & 12.6 \\ pitch controller & 1105 & - & 38 \\ yaw-rate controller & 355 & 3.55 & - \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Controller gains. Figure 15: Yaw rate response of the octocopter with the designed proportional-integral (PI) controller for an input rate of 10 deg/s.