3.1.2. Attitude–Altitude Control

The height and orientation angles (roll, pitch, yaw) of the quadcopter are controlled by the attitude–altitude controller. As stated in Equations (12)–(15):

$$u\_1(t) = \frac{1}{\cos(\phi)\cos(\theta)} (K\_{PZ}e\_z(t) + K\_{IZ} \int\_0^t e\_z(\tau)d\tau + K\_{DZ} \frac{de\_z(t)}{dt} + mg) \tag{12}$$

$$p\_d(t) = K\_{P\phi} e\_\phi(t) + K\_{I\phi} \int\_0^t e\_\phi(\tau) d\_\tau + K\_{D\phi} \frac{d e\_\phi(t)}{dt} \tag{13}$$

$$q\_d(t) = K\_{P\theta} e\_\theta(t) + K\_{I\theta} \int\_0^t e\_\theta(\tau) d\_\tau + K\_{D\theta} \frac{d e\_\theta(t)}{dt} \tag{14}$$

$$r\_d(t) = K\_{P\Psi} \varepsilon\_{\Psi}(t) + K\_{I\Psi} \int\_0^t \varepsilon\_{\Psi}(\tau) d\_{\tau} + K\_{D\Psi} \frac{de\_{\Psi}(t)}{dt} \tag{15}$$

*KPZ*, *KIZ*, *KDZ* express PID gains that control the movement of quadcopter in the *Z* position; *KPφ*, *KIφ*, *KD<sup>φ</sup>* specify PID gains that control the roll angle; *KPθ*, *KIθ*, *KD<sup>θ</sup>* describe PID gains that control the pitch angle; *KPψ*, *KIψ*, *KD<sup>ψ</sup>* denote PID gains that control the yaw angle. The inputs of the controller are desired and measured height, roll, pitch, and yaw angles; the outputs are *u*1; and the desired angular velocities are (*pd*, *qd*, *rd*). *u*<sup>1</sup> obtained at the controller output is input into the quadcopter system, and this control variable enables the quadcopter to increase [38].
