## 2 Trajectory Generation
### Closed-Form Local Trajectory Replanning
\[\int_{0}^{s}\left\|\frac{d^{4}P_{1}(T)}{dT^{4}}\right\|^{2}dT=\mathbf{c_{1}^{ \intercal}Q}(T)\mathbf{c_{1}} \tag{20}\]  
\[\int_{0}^{1}\left\|\frac{d^{4}P_{2}(t)}{dt^{4}}\right\|^{2}dt=\mathbf{c_{2}^{ \intercal}Q}(1)\mathbf{c_{2}} \tag{21}\]  
\[\mathbf{r_{2}}=r-r_{1} \tag{15}\]0  
where \(\mathbf{c_{1}}(\in\mathbb{R}^{10\times 1})\) and \(\mathbf{c_{2}}(\in\mathbb{R}^{10\times 1})\) are the coefficient vectors of each polynomial and \(\mathbf{Q}(\text{T})\), \(\mathbf{Q}(\text{1})\) are the mapping matrices to convert to the quadratic form. You can see that the segment time \(T\) of \(\mathbf{Q}(\text{T})\) is now replaced by 1 in \(\mathbf{Q}(\text{1})\). As Equations (20) and (21) show, the  
\[\mathbf{r_{2}}=r-r_{1} \tag{15}\]1 Time-scaling. relationship between the original quadratic equation and scaled quadratic Equation (22) is proportional to \((\frac{1}{s})^{7}\). Now we can write \(\mathbf{Q}(1)\) matrix as follows. \[\mathbf{Q}(1)= \begin{bmatrix}0&0&0&0&0&0&0&0&0&0\\ &&&\vdots&&&&&&&\\ 0&0&0&0&24^{2}&\frac{24\text{-}120}{220}&\cdots&&\\ 0&0&0&0&\frac{24\text{-}120}{22}&\frac{120\text{-}120}{3}&\cdots&&\\ &&&\vdots&&&&\\ &&&\cdots&&&\frac{1680\text{-}3024}{10}&\frac{3024^{2}}{11}\end{bmatrix}  \tag{23}\]  
In this form we are substituting \(1\) as \(T\) in (7). Similarly, matrix \(\mathbf{A}\) in (4) is replaced by \(\mathbf{A}(1)\) by substituting \(1\) for \(T\). \[\mathbf{A}(1)= \begin{bmatrix}1&0&0&0&0&0&0&0&0&0\\ 0&1&0&0&0&0&0&0&0&0\\ 0&0&2&0&0&0&0&0&0&0\\ 0&0&0&6&0&0&0&0&0\\ 0&0&0&0&24&0&0&0&0&0\\ 1&1&1&1&1&1&1&1&1&1\\ 0&1&2&3&4&5&6&7&8&9\\ &&&\vdots&&&&&&&\\ 0&0&0&24&120&&\cdots&&\end{bmatrix}  \tag{24}\]  
We simplified the \(\mathbf{Q}\) and \(\mathbf{A}\) matrices and continually used them to replan the local trajectory. This approach can reduce computation complexity. After computing the polynomial coefficient of the local trajectory that is scaled to \(1\), we restore the trajectory's real value. Velocity and acceleration are obtained by multiplying by a scale factor, as in Equation (18). This closed-form method has some merits against the optimization-based numerical method. First, it can solve every case after the waypoints are obtained. As can be seen in Equation (25), the form of the cost function is positive semi-definite. \[\mathbf{J}=\int_{0}^{1}\left\|\frac{d^{4}p(t)}{dt^{4}}\right\|^{2}dT=\mathbf{ c}^{\intercal}\mathbf{Q}\mathbf{c}= \begin{bmatrix}\mathbf{d}_{\mathbf{F}}\\ \mathbf{d}_{\mathbf{P}}\end{bmatrix} ^{\intercal}\mathbf{M}^{-\intercal} \mathbf{A}^{-\intercal}\mathbf{Q}\mathbf{A}^{-\intercal}\mathbf{M}^{- \intercal} \begin{bmatrix}\mathbf{d}_{\mathbf{F}}\\ \mathbf{d}_{\mathbf{P}}\end{bmatrix} \geq 0 \tag{25}\]  
For example, if a hessian matrix is positive semi-definite for any \(x\), \(f(x)\) is convex. We can now see that this closed form is also convex. So, the analytical solution we can obtain by differentiation as in Equation (13) is the global minimum. The second merit is that this method can compute much faster. The fast and simple process allows the quadrotor to navigate a complicated environment where the onboard computer computes the local trajectory. Moreover, fast computation enables the quadrotor to fly faster because the computer can react to objects or obstacles quickly. As shown in Figure 2(a), we expect a safe and non-collision local trajectory that avoids obstacles. If the waypoints were calculated only by gradient information, then the local trajectory could fail, as shown in Figure 2(b). Thus, to correct this issue, an Algorithm 1 was created to prevent the failure of the trajectory. If the angle between normal vectors of successive waypoints is over \(90^{\circ}\) degrees, we reverse the post-normal vector direction. We realized that when the velocity of navigation is faster, the tracking error is higher. Because the object generates gradient fields only around itself, the local trajectory can be formed steeply.