# Three-Dimensional Obstacle Avoidance Strategy for Fixed-Wing UAVs Based on Quaternion Method
## 3 Improved 3D-VO Method for UAV Collision Avoidance
### Avoidance Velocity
\[\left(\mathbf{v}_{avo_{x}}^{\delta},\mathbf{v}_{avo_{y}}^{\delta}\right)\in\left\{ \left(\mathbf{x}_{avo}^{\delta},\mathbf{y}_{avo}^{\delta}\right)\bigg{|}\ \mathbf{z}_{vo}^{\delta}=0\ \right\}\cap\left\{\left(\mathbf{x}^{\delta},\mathbf{y}^{\delta}\right)\bigg{|} \mathbf{\left(x}^{\delta}\right)^{2}+\left(\mathbf{y}^{\delta}\right)^{2}=\|\mathbf{v}_{ UAV}\|^{2}\right\} \tag{23}\]  
Figure 4: (**a**) Maximum tracking errors in (m) for the fixed-wing UAV and for varying direction of control velocities \(\mathbf{v}_{avo}\). (**b**) The flight trajectory of the fixed-wing UAV under varying direction of control velocities. Example in the picture, the initial velocity is set to \(\mathbf{v}_{UAV}\) = 40 m/s and the initial quaternion to \(\mathbf{q}_{bs}=\left[1\ \mathbf{0}^{T}\right]^{T}\). In Equation (23), the velocity point in the avoidance plane \(S^{\delta}\) is defined as the intersection of the conic section \(\mathcal{F}\) and circular curve \(\left\{\left(x^{\delta},y^{\delta}\right)\middle|\left(x^{\delta}\right)^{2}+ \left(y^{\delta}\right)^{2}=\left\|v_{UAV}\right\|^{2}\right\}\). As shown in Figure 5, three situations need to be considered: (a) \(\mathcal{F}\) and the circular curve only have one intersection, \(\mathbf{v}_{\alpha\mathbf{v}_{01}}\), in the feasible region (gray). Then this point is defined as the velocity point. (b) There are two intersection points of \(\mathcal{F}\) and the circular curve in the feasible region. Then the vector with the smallest \(\alpha\) is chosen as the avoidance velocity. (c) There is no intersection point of \(\mathcal{F}\) and the circular curve in the feasible region. Then the vector corresponding to \(\alpha_{\max}\) is the avoidance velocity. In this case, a reasonable selection of \(d_{\text{safe}}\)[11] can ensure that the UAV avoids collision in the worst scenario (the UAV flying toward the obstacle):  
\[\left\{ \begin{aligned} d_{\min}=&\sqrt{ \left(2\sqrt{\frac{\left\|\mathbf{v}_{UAV}\right\|\mathbf{v}_{pz}\tau}{\alpha_{\max} }}+\left\|\mathbf{v}_{OBS}\right\|T\right)^{2}+\mathbf{r}_{pz}^{2}}\\ T=&\frac{\tau}{\alpha_{\max}}\text{arctan}\left( \frac{2\sqrt{\left\|\mathbf{v}_{UAV}\right\|\mathbf{v}_{pz}\tau\alpha_{\max}}}{\left\| \mathbf{v}_{UAV}\right\|\tau-\alpha_{\max}\mathbf{r}_{pz}}\right)\\ d_{\text{safe}}\geq& d_{\min}\end{aligned} \right. \tag{24}\]  
where \(\tau\) is the control system cycle. The smaller \(\alpha_{\max}\) is, the larger \(d_{\text{safe}}\) is needed. Nevertheless, the selection of \(d_{\text{safe}}\) needs to meet the requirements of \(\alpha_{\max}\) and consider the detection range of the sensor. When Equation (15) is satisfied, \(\mathbf{v}_{\alpha\mathbf{v}}^{\delta}\) is calculated in each avoidance plane \(S^{\delta}(\delta=\delta_{1},\delta=\delta_{2}\cdots\delta=\delta_{n})\). Among these solutions, the avoidance velocity with the smallest angle \(\alpha\) will be selected and mapped to the inertial coordinate system to generate the avoidance points:  
\[\mathbf{p}_{\alpha\mathbf{v}}^{n}(t)=\mathbf{p}_{UAV}^{n}(t_{0})+\int_{t_{0}}^{t}\mathbf{v}_ {\alpha\mathbf{v}}^{n}(t)\;dt \tag{25}\]  
where \(t_{0}\) is the initial time of the avoidance mode, \(\mathbf{v}_{\alpha\mathbf{v}}^{n}(t)\) is constantly updated, and \(\mathbf{p}_{\alpha\mathbf{v}}^{n}(t)\) will be used in the next chapter to construct the avoidance coordinate system and be mapped onto the control input.