# Three-Dimensional Obstacle Avoidance Strategy for Fixed-Wing UAVs Based on Quaternion Method
## 2 Problem Formulation
### Problem Statement  
Assumption:  
1. The UAV and obstacle are seen as spheres with radii \(r_{UAV}\), \(r_{OBS}\), respectively;
2. The obstacle mentioned in this article is assumed to be a moving but non-maneuvering obstacle;
3. Suppose sensors mounted on the UAV can accurately provide measurements, such as locations \(\mathbf{p}_{UAV}\), \(\mathbf{p}_{OBS}\in\mathbb{R}^{3}\), velocities \(\mathbf{v}_{UAV}\), \(\mathbf{v}_{OBS}\in\mathbb{R}^{3}\) and radii \(r_{UAV}\), \(r_{OBS}\) of the UAV itself and obstacles;
4. The control system cycle is consistent with the detection system cycle;
5. The influence of wind is ignored during the flight of the UAV to simplify the problem.  
The UAV and the obstacle are moving in a three-dimensional space \(\mathcal{W}=\mathbb{R}^{3}\). \(\mathcal{X}\subset\mathbb{R}^{m1}\) represents the set of states of the UAV, \(m1\) denotes the dimension of the state space, \(\mathcal{U}\subset\mathbb{R}^{m2}\) represents the set of control input of the UAV, and \(m2\) denotes the dimension of the control input  
\[\dot{\mathbf{x}}(t)=f_{1}(\mathbf{x}(t))+f_{2}(\mathbf{x}(t))\mathbf{u}(t) \tag{5}\]  
where \(\mathbf{x}\in\mathcal{X},\mathbf{u}\in\mathcal{U}\), \(f_{1}(\cdot)\) and \(f_{2}(\cdot)\) are nonlinear functions of the state \(\mathbf{x}\). Given an initial \(\mathbf{x}(t_{0})\) and a control input \(\mathbf{u}(t)\), the state of the robot at time \(t\geq t_{0}\) can be solved. If \(\text{rank}[f_{2}(\mathbf{x}(t))]<\dim[\mathbf{x}(t)]\), the system described in Equation (5) is said to be underactuated. The position of the UAV \(\mathbf{p}_{\text{UAV}}\) can be derived from \(\mathbf{x}(t_{0})\) and \(\mathbf{u}(t)\):  
\[\mathbf{p}_{UAV}(t)=f_{3}(\mathbf{x}(t_{0}),\mathbf{u}(t)) \tag{6}\]  
where \(f_{3}(\cdot)\in\mathcal{X}\times\mathcal{U}\rightarrow\mathbb{R}^{3}\). \(D(\mathbf{p},\mathbf{r})=\{\mathbf{l}\ |\ \|\mathbf{l}\mathbf{-}\mathbf{p}\|\leq r\}\) denotes the area occupied by a sphere, centered at \(\mathbf{p}\) with radius \(r\). Similarly, the airspace occupied by the UAV can be expressed as \(O(\mathbf{p}_{\text{UAV}})=D(\mathbf{p}_{UAV},r_{UAV})\in\mathbb{R}^{3}\), where \(r_{UAV}\) is the radius of the UAV. This also applies to obstacles \(O(\mathbf{p}_{OBS})=D(\mathbf{p}_{OBS},\ r_{OBS})\in\mathbb{R}^{3}\).  
**Definition 1**.: _The UAV will remain collision-free with the obstacle in period \(\tau\)._  
\[O(\mathbf{p}_{UAV}(t))\cap O(\mathbf{p}_{OBS}(t))=\emptyset,\ \forall t\in\left[ \begin{array}{cc}t_{0}&t_{0}+\tau\end{array}\right) \tag{7}\]  
**Definition 2**.: _The UAV arrives at the destination \(\mathbf{p}_{pre}\)._  
\[\mathbf{e}:=\mathbf{p}_{UAV}-\mathbf{p}_{pre},\ \|e(t_{0})\|>\varepsilon>0,\ \exists t>0,\ \varepsilon\leq e(t)\leq\Lambda \tag{8}\]  
When \(\|e(t)\|\leq\Lambda\), we conclude that the UAV has arrived at the destination point. To achieve Definitions 1 and 2, we define a desired frame-\(d\) and make the frame-\(s\) align with the desired frame-\(d\) by controlling the attitude and speed of the UAV. Quaternions \(\mathbf{q}_{ea}\) and \(\mathbf{q}_{ne}\) are used to represent the obstacle avoidance and target tracking sub-task, respectively, and then the quaternion multiplication \(\mathbf{q}_{m}\)=\(\mathbf{q}_{ne}\otimes\mathbf{q}_{ea}\) is utilized to combine these sub-tasks into a total task, which is defined as the desired quaternion, \(q_{nd}\): \(:=q_{na}\). The purpose of this work can be defined as follows: given the initial state \(\mathbf{x}(t_{0})\) and the information of the obstacle, computing a control input \(\mathbf{u}(t)\) for the UAV, such that  
\[q_{nd}\rightarrow\left[\begin{array}{cc}1&\mathbf{0}^{\mathsf{T}} \end{array}\right]^{\mathsf{T}} \tag{9}\]