## 2 Trajectory Generation
### Closed-Form Local Trajectory Replanning  
Instead of an optimization method that computes solutions numerically, we devised a novel method that computes all at once. It solves the local trajectory analytically or geometrically. We use the geometrical information of a map that is built through an occupancy grid [18]. The map has distance and gradient information, so we use gradient values as a repulsive vector (\(\mathbf{r}\)). When the global trajectory is near the object or in the distance, it repulses the trajectory to avoid collision. We use vector projection (\(\mathbf{r_{1}}\)) and rejection (\(\mathbf{r_{2}}\)) to repulse the trajectory with repulsive vector and velocity vector (\(v\)) of the global trajectory as shown in Figure 0(a). The velocity vector \(v\) is calculated via the first derivative of the trajectory. Mainly, we use the normal vector of the repulsive vector \(\mathbf{n}\) to push the global trajectory. The projection and rejection equations are as follows in Equations (14) and (15). \[\mathbf{r_{1}}=\frac{\mathbf{v}\cdot\mathbf{r}}{\left\|\mathbf{v}\right\|^{2 }}\mathbf{v} \tag{14}\]  
\[\mathbf{r_{2}}=r-r_{1} \tag{15}\]  
We divide the global trajectory into small pieces and modify the waypoints as shown in Figure 0(b). The normal vector pushes the global trajectory and modifies it, then a new local trajectory is generated. Now we will show the formulation method that we use for the new local trajectory. If the new waypoint is fixed, we use the non-constrained quadratic programming introduced in Equation (3). By setting some waypoints in fixed derivatives, we can again compute the minimum-snap trajectory. The difference with the global trajectory is as follows. Figure 1: Local trajectory generation. First, we set the start point and endpoint derivatives; however, as opposed to previously, we do not set them to zero. Instead, we set them at some values for continuity with the current state and global trajectory. Start derivatives are set as the last local trajectory derivatives calculated at the same waypoint. End derivatives are the same values as the global trajectory waypoint. Second, the segmentation time in the local trajectory is uniform between all waypoints. Because we divide the global trajectory into constant segment times, we can set the time allocation uniformly. Moreover, we use a time scaling factor such that all-time allocation is normalized to 1. An example of time scaling is described in Figure 2. We can represent one function in a different form. Similarly, we can apply time scaling to trajectory generation. If the time scale is applied, derivatives such as velocity must be defined again as in Equations (17) and (18) when the time scaling factor is \(s\) and \(T=s\times t\). \[P_{1}(T)\quad T\in[0,s] \tag{16}\]  
\[P_{2}(t)=P_{2}(\frac{1}{s}T)\quad T\in[0,1] \tag{17}\]  
\[P_{1}^{\prime}(T)=P_{2}^{\prime}(\frac{1}{s}T)\cdot\frac{1}{s}=P_{2}^{\prime} (t)\cdot\frac{1}{s} \tag{18}\]  
\[\int_{0}^{s}\left\|\frac{d^{4}P_{1}(T)}{dT^{4}}\right\|^{2}dT=\int_{0}^{1} \left\|\frac{d^{4}P_{2}(t)}{dt^{4}}\cdot\frac{1}{s^{4}}\cdot dt\right\|^{2}s \cdot dt=\int_{0}^{1}\left\|\frac{d^{4}P_{2}(t)}{dt^{4}}\right\|^{2}dt\cdot( \frac{1}{s})^{7} \tag{19}\]  
where \(P_{1}\) and \(P_{2}\) are 9 th-order polynomial trajectory functions. The time-scaled minimum snap cost, which is the least square of the fourth derivative, is equal to the original cost divided by the scaling factor to the power of seven, as we see in Equation (19). Now we can write the quadratic form as follows.