# A Trajectory Generation Method for Multi-Rotor UAV Based on Adaptive Adjustment Strategy
## 3 Method
### B-Spline Curve and Security Guarantee Method
#### 3.1.3 B-Spline Error Upper-Bound Property and Security Guarantee  
In order to ensure the flight safety of multi-rotor UAVs, it is necessary to ensure that the trajectory will not collide with obstacles. This paper proposes a trajectory safety assurance method based on the upper-bound property of the error between the B-spline curve and the control polygon. Compared with the trajectory safety representation method based on the B-spline convex hull property introduced in [17], the method proposed in this paper can achieve more accurate estimation results.  
The line connecting adjacent B-spline control points can be transformed into a function \(\mathbf{I}(t)\) with time \(t\) as a parameter in the domain \([0,T]\). When \(t_{i+p_{\rm b}}<t<t_{i+N+1}\), it is defined as  
\[\mathbf{I}(t)=\mathbf{Q}_{i}+(\mathbf{Q}_{i+1}-\mathbf{Q}_{i})\frac{t-t_{i+N}}{i_{i+N+1}-t_{i+ N}} \tag{9}\]  
The maximum error between the B-spline curve \(\mathbf{p}(t)\) and the control polygon \(\mathbf{I}(t)\) is called the error upper bound, which is defined as shown in Formula (10).  
\[d_{max}=\left\|\mathbf{p}(t)-\mathbf{I}(t)\right\|_{max} \tag{10}\]  
In references [21; 22], [PERSON] et al. proved that \(d_{max}\) is only related to the degree of the B-spline curve and the second-order variance of the control polygon:  
\[d_{max}\leq N_{\infty}(n)\|\Delta_{2}p\|_{\infty} \tag{11}\]  
In Formula (11), \(\Delta_{2}b\) is the second-order variance of the control polygon, \(n\) is the order of the B-spline, \(N_{\infty}(n)\) is a function of \(n\), which is defined as Formula (12).  
\[N_{\infty}(n)=\frac{\left\lfloor\frac{n}{2}\right\rfloor\left\lceil\frac{n}{ 2}\right\rceil}{2n} \tag{12}\]  
\(\left\|\Delta_{2}b\right\|_{\infty}\) is the maximum value of the second-order variance of the control polygon:  
\[\left\|\Delta_{2}b\right\|_{\infty}=max\|\mathbf{Q}_{i}+\mathbf{Q}_{i+2}-2\mathbf{Q}_{i+1 }\|_{\infty} \tag{13}\]  
The principle of error upper bound indicates that there is an upper bound for the error between the B-spline curve and the control polygon, and it can be calculated by the second-order variance of the control polygon and the B-spline order. Based on the upper bound, this paper proposes a more accurate method for calculating the safe distance of the control point.  
In Figure 2, \(P\) is an arbitrary point on the B-spline curve, \(P^{\prime}\) is the corresponding point of \(P\) point on the control polygon. The distance between \(P\) point and the obstacle is recorded as \(d(P)\). The distance between \(P^{\prime}\) and the obstacle is recorded as \(d(P^{\prime})\), and the distance between \(P\) and \(P^{\prime}\) is recorded as \(d(P,P^{\prime})\). According to the geometric property of the triangle, \(d(P)\geq d(P^{\prime})-d(P,P^{\prime})\), and the upper bound of the error of the B-spline curve is recorded as \(e_{max}\), then \(d(P,P^{\prime})\leq e_{max}\), so to make \(d(P)\geq d(P^{\prime})-e_{max}\), if \(d(P^{\prime})\geq e_{max}\), then \(d(P)\geq 0\), that is, point \(P\) will not collide with the obstacle.  
Mark the distance between point \(B\) and point \(C\) as \(l\). If point \(P^{\prime}\) is close to point \(C\), then \(P^{\prime}C\leq 0.5l\). According to the geometric properties of the triangle, \(d(P^{\prime})\geq d(C)-P^{\prime}C\geq d(C)-0.5l\), so only \(d(C)-0.5l\geq e_{max}\) is required, that is, \(d(C)\geq 0.5l+e_{max}\), then \(d(P^{\prime})\geq e_{max}\) can be guaranteed to ensure \(d(P)\geq 0\), so as to ensure trajectory safety. Therefore, it is concluded that for any control point \(Q\), to ensure the safety of the trajectory, it is necessary to ensure that the distance between the point \(Q\) and the obstacle satisfies Formula (14).  
\[d_{Q}\geq\frac{1}{2}l+e_{max} \tag{14}\]