## 4 Trajectory Optimization Problem  
A UAV may work as an airborne BS (UAV-BS) to provide aerial wireless communication for intelligent vehicles, or it may be equipped with RIS (RISeUAV [38]) for the reflection of the communication signals in the sky toward intelligent vehicles (see Figure 2). This scenario is practical in future 6G wireless networks (that are limited to LoS communication links) in smart cities where intelligent vehicles require V2V and V2X wireless communication and supportive stable wireless communication links for autonomous driving and autonomous mission accomplishment (e.g., in a natural disaster or traffic congestions). Therefore, the trajectory design is needed for the UAV to navigate through a path that is energy-efficient (for navigation endurance) and provides maximum support for the wireless communication of IoVs. Furthermore, the kinodynamic motion and crash avoidance constraints must be satisfied, leading to the trajectory design problem. We introduce the following trajectory optimization problem (\(\mathcal{P}1\)), for which both linear kinodynamic motion models \(\mathcal{DKM1}\) and \(\mathcal{DKM2}\) can be used. Also, \(\mathcal{P}1\) is formulated to be computationally feasible to be solved in real time for the autonomous navigation of the UAV. The navigation time interval of interest \(\mathcal{T}\) is discretized with sampling time \(h\) into \(K=\lceil\mathcal{T}/h\rceil\) sampling slots in the set \(\mathcal{K}=\{1,\,2,\ldots,K\}\), where \(\lceil\,.\rceil\) denotes the ceiling operator. The optimization problem \(\mathcal{P}1\) is solved for every sampling time consecutively. For example, by solving \(\mathcal{P}1\) for step time \(k\), the input at step time \(k\) (\(\mathbb{A}[k]\)) is determined. Then, using \(\mathbb{A}[k]\), the UAV's waypoint at \(k+1\) is calculated on the basis of the motion model and is used for the next time step. Velocity and acceleration can be calculated and bounded by constraints if \(\mathcal{DKM2}\) is used. \[\mathcal{P}1:\] OF1. \[\min_{ \begin{subarray}{c}\mathfrak{U}[k]\\ \end{subarray} }\underbrace{\omega_{1_{1}}||\mathfrak{U}[k]||_{2}^{2}}_{\text{ OF1}}+\omega_{1_{2}}\underbrace{\sum_{n=1}^{N}||\xi[k]-p_{n}[k]||_{2}^{2}}_{\text{OF1}_{ 2}}\] s. t. \[ \begin{array}{l}\text{C1}_{1}.\\ \text{C1}_{2}.\end{array} \] \[ \begin{array}{l}\text{C1}_{3}.\\ \text{C1}_{4}.\\ \text{C1}_{5}.\end{array} \] \[ \begin{array}{l}\text{C1}_{4}.\\ \text{C1}_{5}.\end{array} \] \[ \begin{array}{l}\text{C1}_{6}.\\ \begin{array}{l}\begin{bmatrix}v_{x}[k]\\ \end{bmatrix}\\ \begin{bmatrix}v_{y}[k]\\ \end{bmatrix}\\ \begin{bmatrix}v_{y}[k]\\ \end{bmatrix}\\ \begin{bmatrix}v_{y}[k]\\ \end{bmatrix}-\begin{bmatrix}1+\frac{\gamma_{2}}{\omega_{max}}\\ \end{bmatrix}\\ \begin{bmatrix}v_{x}[k-1]\\ \begin{bmatrix}v_{y}[k-1]\\ \end{bmatrix}\\ \begin{bmatrix}v_{y}[k-1]\\ \end{bmatrix}\end{array}<0;\\ \text{C1}_{7}.\end{array} \]  
where \(\omega_{1_{1}}\) and \(\omega_{1_{2}}\) are weighting coefficients; \(\mathfrak{U}= \begin{bmatrix}u_{3}&u_{2}&u_{1}\end{bmatrix} ^{\top}= \begin{bmatrix} v_{x}&v_{y}&u_{z}\end{bmatrix} ^{\top}\in\mathbb{R}^{3}\) denotes control input effort; \(p_{n}[k]\in\mathbb{R}^{3}\) denotes the 3D coordinates of the \(n^{th}\) vehicle at sample time \(k\); \(N\) denotes the number of vehicles in the IoVs; \(\mathbb{P}_{\text{Obstacle}}\) denotes the set of coordinates associated with obstacles; \(\varnothing\) indicates an empty set; \(Z_{min}\) and \(Z_{max}\) denote minimum and maximum permitted altitudes; \(V_{max}\) and \(U_{max}\) denote maximum linear horizontal and vertical velocities; \(\mathcal{A}_{max}\) denotes maximum reachable acceleration; and \(\gamma_{1}\) and \(\gamma_{2}\) are hyperparameters to control the vertical speed based on the horizontal speed and the rate of change of the horizontal speed, respectively. Objective function OF1\({}_{1}\) minimizes the input effort as an indicator of minimizing energy consumption by propellers, and OF1\({}_{2}\) minimizes the average Euclidean distances between the UAV and vehicles in the IoVs.