*3.2. Three-Dimensional Path Planning Model of the Quadcopter*

The 3D path planning algorithm proposed in this study is operated to define the optimum path by avoiding the obstacle region after the starting and ending point are determined. There are two limit values of the objective function, the starting (*xs*, *ys*, *zs*) and the ending points (*xt*, *yt*, *zt*). The number of waypoints to be generated, including starting, ending, payload hold, and payload release points, are entered. Afterwards, the locations of the spherical barriers on the map are defined as central positions (*xobs*, *yobs*, *zobs*) and the radius (*robs*), and these locations are given as an input to the algorithm. The 3D pathplanning algorithm presented in this study consists of three different objective functions. In the first part, the length of the generated path is indicated as:

$$d = \sum\_{i=1}^{N\_p - 1} \sqrt{d\mathbf{x}\_i^2 + dy\_i^2 + dz\_i^2} \tag{22}$$

where *dx*, *dy*, *dz* are the infinitesimal lengths traversed by the quadcopter along *X*, *Y*, *Z* axes, respectively, and *Np* is the number of generated points [43]. In the second part, the total energy consumed by the quadcopter is expressed as:

$$E\_t = K\_E \sum\_{i=1}^{N\_p} \Delta t \sum\_{k=1}^4 w\_{ki}^3 \tag{23}$$

where *KE* = (2*ρA*)( *KvK<sup>τ</sup> Kt* )3, and <sup>Δ</sup>*<sup>t</sup>* is the sampling period. Motor speeds *wk* (*<sup>k</sup>* <sup>=</sup> 1, 2, 3, 4) have been calculated in order to obtain *dxi*, *dyi*, *dzi* in each *i* by using Equation (6) to obtain *u*1, *u*2, *u*3, *u*4, as well as the UAV model Equations (3) and (4). The collision of the quadcopter with obstacles is represented as violation function. The violation function is calculated as indicated in Algorithm 1. In the third part, the distance of each point on the pathway to a specific obstacle is expressed as:

$$dobs\_i = \sqrt{(X\_i - x\_{obs})^2 + (Y\_i - y\_{obs})^2 + (Z\_i - z\_{obs})^2} + r\_{uav} \tag{24}$$

$$r\_{\text{inv}} = 2(l + \Delta l) \tag{25}$$

where *Xi*, *Yi*, *Zi* are the generated points, and Δ*l* is the propeller radius. If this distance is greater than the radius of the obstacle, then it is assumed that the obstacle is outside the quadcopter's field of view. The feasible constraint takes the following form:

$$
abla s\_i \leq\_r r\_{obs} \tag{26}$$

in Equation (26) [44]. The points chosen on the map representing the flight path attain a value calculated as:

$$w\_i = \begin{cases} 0, & (1 - \frac{d \text{obs}\_i}{r\_{\text{obs}}}) < 0 \\ (1 - \frac{d \text{obs}\_i}{r\_{\text{obs}}}), & (1 - \frac{d \text{obs}\_i}{r\_{\text{obs}}}) > 0 \end{cases} \tag{27}$$

in Equation (27). The average value of *vi* with respect to a particular obstacle is obtained. Subsequently, the average of *vi* with respect to the other obstacle is obtained, and the total violation function is expressed as:

$$V = \frac{1}{N\_p} \sum\_{i=1}^{N\_p} \sum\_{j=1}^{n\_{obs}} \upsilon\_{ij} \tag{28}$$

in Equation (28). The objective function is calculated by combining Equation (22), Equation (23), and Equation (28):

$$J\_E = \min\{ (d + E\_t)(1 + \zeta V) \}\tag{29}$$

where *ξ* and *V* are the violation coefficient and function, respectively.

