## 2 Trajectory Generation  
### Global Trajectory Generation  
As quadrotors have differential flatness property [2], a 3D coordinate \((x,y,z)\) trajectory (except for the yaw angle \((\psi)\)) of the quadrotor is generated, since the yaw angle is responsible for the camera's direction. A yaw angle trajectory is generated independently. The whole trajectory is divided into a series of segments indicated by waypoints. Each of these segments has a polynomial-based trajectory from its starting waypoint to an ending waypoint. This relationship can be described by the \(N\)th-order polynomial \((P(t))\) as shown below. However, this function only covers the trajectory of one axis. Thus, in order to fully represent a 3D trajectory, the formula must be used on all axes. \[P(t)=a_{0}+a_{1}t+a_{2}t^{2}+a_{3}t^{3}+\cdots+a_{N}t^{N} \tag{1}\]  
\[\mathbf{p}=[a_{0},a_{1},a_{2},\cdots,a_{N}]^{\intercal} \tag{2}\]  
where vector \(\mathbf{p}(\in\mathbb{R}^{N\times 1})\) are polynomial coefficients. Due to the differential flatness property of quadrotors, the desired motor speed of the quadrotor is represented by the fourth derivative of its position. By minimizing snap, an optimal trajectory can be obtained. The equation is as follows. \[argmin_{p}\int_{0}^{T}\left\|\frac{d^{4}P(t))}{dt^{4}}\right\|^{2}dt \tag{3}\]  
\[\mathbf{Ap}=\mathbf{d} \tag{4}\]  
where \(T\) is the end time of the trajectory segment, and \(\mathbf{A}(\in\mathbb{R}^{N\times N})\) is a mapping matrix from polynomial coefficients to the trajectory constraints at the start time or end time. Vector \(\mathbf{d}\) represents trajectory constraints of position (\(p\)), velocity (\(v\)), acceleration (\(a\)), jerk (\(j\)), and snap (\(s\)). The \(m\)-th segment of \(d\) is represented as \(d_{m}\). \[\mathbf{d_{m}}=[p_{m},v_{m},a_{m},j_{m},s_{m},p_{m+1},v_{m+1},a_{m+1},j_{m+1},s_ {m+1}]^{\intercal} \tag{5}\]  
where \(p_{m},v_{m},a_{m},j_{m},s_{m}\) is the \(m\)-th segment of position, velocity, acceleration, jerk, and snap. As seen in Equation (5), we use constraints up to snap, meaning that one segment polynomial has 10 constraints where 5 constraints are located at the start point and the remaining 5 are located at an endpoint, so we should use a 9 th-order polynomial as a trajectory. To extend the equation, we can rewrite (3) as follows:  
\[\int_{0}^{T}\!\!\left\|\frac{d^{4}P(t)}{dt^{4}}\right\|^{2}dt=\mathbf{p}^{ \intercal}\mathbf{Q}\mathbf{p} \tag{6}\]  
where \(\mathbf{Q}\) is the mapping matrix from coefficient to the integral of the squared norm of the fourth derivative. Again, the \(\mathbf{Q}\) matrix is as follows when the polynomial is of 9 th order. \[\mathbf{Q}= \begin{bmatrix}0&0&0&0&0&0&0&0\\ &&&\vdots&&&&\\ 0&0&0&0&24^{2}T&\frac{24\cdot 120}{2}T^{2}&\dots&\\ 0&0&0&0&\frac{24\cdot 120}{2}T^{2}&\frac{120\cdot 120}{3}T^{3}&\dots&\\ &&&\vdots&&&&\\ &&\dots&&&&\frac{1680\cdot 3024}{10}T^{10}&\frac{3024^{2}}{3}T^{3}\end{bmatrix}  \tag{7}\]  
where the matrix dimension of \(\mathbf{Q}\) is 10 \(\times\) 10. Using quadratic programming, the quadratic Equation (6), otherwise known as the cost function, can be minimized in order to obtain an optimal trajectory. However, the iteration process is required for optimization, which can be a heavy task due to the number of parameters needed to calculate the polynomial coefficients; thus, this method is not very efficient when the quadrotor has too many waypoints. To solve this problem, unconstrained quadratic programming was proposed by [PERSON], [PERSON], and [PERSON] [3]. Unconstrained quadratic programming solves the optimal trajectory directly without iteration, so the computation time can be reduced. They divided constraints into two kinds: fixed derivatives \(\mathbf{d_{F}}\) and free derivatives \(\mathbf{d_{P}}\). \(\mathbf{d_{F}}\) are waypoint position and constraints for continuity. \(\mathbf{d_{P}}\) are the free variables velocity and acceleration at the waypoint. Especially in the global trajectory domain, each waypoint is a fixed derivative.