# Motion Planning in UAV-Aided Data Collection with Dynamic Jamming
## 3 Global Replanning Based on CFC
### Minimum Time Path Initialization Based on CFC
```
1:function\(Initial\_CFC\_path(p_{0},p_{N},p_{5N},p_{jammer})\)
2: Compute the \(CFC\) of the \(SN\) with Algorithm 1:
3: Find_CFC(\(p_{SN},p_{UAV},p_{jammer}\))
4: Set the initial point to \(p_{1}\), the end point to \(p_{5}\), and the \(SN\) position to \(p_{3}\):
5:\(p_{2}=p_{1}p_{3}\cap CFC\), \(p_{4}=p_{3}p_{5}\cap CFC\)
6:if UAV is not in CFC and \(Q_{current}\leqslant Q_{th}\)
7: Calculate the discrete points of \(|p_{1}p_{2}|\) and \(|p_{4}p_{5}|\) according to Equation (57)
8: Calculate the discrete points of \(|p_{2}p_{3}|\) and \(|p_{3}p_{4}|\) according to Equations (60) and (61)
9:elsif UAV is in CFC and \(Q_{current}\leqslant Q_{th}\)
10: Calculate the discrete points of \(|p_{4}p_{5}|\) according to Equation (57)
11: Calculate the discrete points of \(|p_{2}p_{3}|\) and \(|p_{3}p_{4}|\) according to Equations (60) and (61)
12:else
13: Calculate the discrete points of \(|p_{UAV}p_{5}|\) according to Equation (57)
14: Output the path discrete point:
15:\(\textbf{p}_{initCFC}=\{p_{1}(0)\cdots p_{2}(0)\cdots p_{3}(0)\cdots p_{4}(0)\cdots\}\)
16:end
```  
**Algorithm 2** For a given initial position \(p_{0}\), end position \(p_{N}\), and position of the jammer and SN, find the initial global discrete path. It is worth noting that if the UAV enters the CFC during its flight, the discrete points of \(|p_{1}p_{2}|\) are not calculated. If the amount of collected data meets the requirements, the UAV \(|p_{3}p_{4}|\) and \(|p_{2}p_{3}|\) will no longer be calculated. However, the discrete points of the line segment from the position of the UAV to the destination will be calculated directly. The initial path obtained by the Algorithm 2 does not consider the treatment of obstacles. Therefore, we continue to design a method based on expansion for the treatment of obstacles. As shown in Figure 4, we first detect the initial path points generated based on the CFC. If these points are within the obstacle area, we move the direction of the vertical line to where these path points are located until a safe distance from the obstacle is found. This is accomplished through the following four steps: (1) Calculate the equation of the line for the neighboring points \(\textbf{p}_{initCFC}(i-1)\) and \(\textbf{p}_{initCFC}(i)\) on \(\textbf{p}_{initCFC}\); (2) calculate the distance \(d_{p}\) from the center of the obstacle to \(l_{\textbf{p}_{initCFC}(i-1)\textbf{p}_{initCFC}(i)^{2}}\); (3) determine if the distance \(d_{p}\) is shorter than \(r_{safe}\). Calculate the vertical line \(l_{\textbf{p}_{initCFC}(i)p_{m}}\) going through the point \(\textbf{p}_{initCFC}(i)\); (4) search for a point \(p_{v}\) on the vertical line \(\textbf{p}_{initCFC}(i)p_{v}\) which satisfies that the distance from the obstacle center \(p_{m}\) to \(\textbf{p}_{initCFC}(i-1)\) is greater than \(r_{safe}\). Use that point as the new \(\textbf{p}_{initCFC}(i)\). The specific implementation steps are shown in Algorithm 3. ```
1:functionInitial_OA_path(\(\mathbf{p}_{initCFC},p_{m},r_{safe},\lambda\))
2:Loop for\(i=2,3,\cdots\)
3: Calculate the line going through points \(\mathbf{p}_{initCFC}(i-1)\) and \(\mathbf{p}_{initCFC}(i)\)
4:\(a=\left[ \begin{array}{cc}\mathbf{p}_{initCFC}(i)-\mathbf{p}_{initCFC}(i-1) \end{array} \right]\)
5:\(\Lambda=\left[ \begin{array}{cc}0&1\\ -1&0\end{array}