# MC_MoveAbsolute(0) 4 th Order Real-Time Trajectory Generation Function Algorithm and Implementation
## 3 Fourth Order Position Profile Generation
### Calculation of Time \(t_{j}\)  
When time (\(t_{\overline{d}}\)) is calculated, the very next step is to calculate the value of time (\(t_{\overline{j}}\)), while taking into account movement constraints and sampling time rounding of calculated values. The value \(t_{\overline{j}}\) means the time of jerk (3 rd order derivative of position), as shown in Figure 4. Derivation of time (\(t_{\overline{j}}\)) starts from calculations:  
\[\begin{array}{rcl}P&=&-\frac{1}{6}t_{\overline{d}}^{2}\\ Q&=&-\frac{1}{2}t_{\overline{d}}^{3}-\frac{\overline{x}}{4 dd_{3}|2|t_{ \overline{d}}}\\ D&=&\sqrt{P^{3}+Q^{2}}\\ D&=&\sqrt[3]{-Q+D}\\ t_{\overline{j}j_{\text{max}}}&=&R-\frac{P}{R}-\frac{5}{3}t_{\overline{d}}\\ \end{array} \tag{23}\]  
This rounded up with respect to the sampling time (\(T_{s}\)) yields the following:  
\[T_{s}\text{ceil}\left(\frac{t_{\overline{j}j_{\text{max}}}}{T_{s}}\right)=T_{ s}\text{ceil}\left(\frac{R-\frac{P}{R}-\frac{5}{3}t_{\overline{d}}}{T_{s}}\right) \tag{24}\]  
Then:  
\[dd4=\left[\begin{array}{c}t_{\overline{d}}\\ T_{s}\text{ceil}\left(\frac{t_{\overline{j}j_{\text{max}}}}{T_{s}}\right)\\ \frac{\overline{x}}{t_{\overline{d}}\left(t_{\overline{d}}^{3}+\left(T_{s} \text{ceil}\left(\frac{t_{\overline{j}j_{\text{max}}}}{T_{s}}\right)\right) \right)\left[8t_{\overline{d}}^{2}+\left(T_{s}\text{ceil}\left(\frac{t_{ \overline{j}j_{\text{max}}}}{T_{s}}\right)\right)\right)\left(5t_{\overline{d} }+T_{s}\text{ceil}\left(\frac{t_{\overline{j}j_{\text{max}}}}{T_{s}}\right) \right)\right]}\end{array}\right] \tag{25}\]  
If the following Equation (26) holds true:  
\[\overline{v}\geq v^{\prime}{}_{\text{max}}=dd4_{1}dd4_{3}\left[2 dd4_{1}{}^{2} +dd4_{2}(3 dd4_{1}+dd4_{2})\right] \tag{26}\]  
Then:  
\[dd5=dd4 \tag{27}\]  
Otherwise:  
\[t_{\overline{j}v_{\text{max}}}=\sqrt{\frac{1}{4}t_{\overline{d}}^{2}+\frac{ \overline{v}}{dd3_{2}t_{\overline{d}}}}-1.5t_{\overline{d}} \tag{28}\]This rounded up with respect to the sampling time (\(T_{s}\)) yields the following:  
\[T_{s}\text{ceil}\Bigg{(}\frac{t_{\overline{j}\gamma_{\text{max}}}}{T_{s}}\Bigg{)}= T_{s}\text{ceil}\left(\frac{\sqrt{\frac{1}{4}t_{\overline{d}}^{2}+\frac{\overline{u}}{ 4d3_{2}t_{\overline{d}}}}-1.5t_{\overline{d}}}{T_{s}}\right) \tag{29}\]  
Then:  
\[dd5=\left[\begin{array}{c}t_{\overline{d}}\\ T_{s}\text{ceil}\Bigg{(}\frac{t_{\overline{j}\gamma_{\text{max}}}}{T_{s}} \Bigg{)}\\ \frac{1}{t_{\overline{d}}\Big{(}\Big{[}\frac{t_{\overline{j}\gamma_{\text{max}} }}{T_{s}}\Big{)}\Big{]}}\end{array}\right] \tag{30}\]  
If the following Equation (31) holds true:  
\[\overline{a}\geq{a^{\prime}}_{\text{max}}=dd5_{3}dd5_{1}(dd5_{1}+dd5_{2}) \tag{31}\]  
Then:  
\[dd6=dd5 \tag{32}\]  
Otherwise:  
\[t_{\overline{j}a_{\text{max}}}=\frac{\overline{a}}{dd3_{2}t_{\overline{d}}}- t_{\overline{d}} \tag{33}\]  
This rounded up with respect to the sampling time (\(T_{s}\)) yields the following:  
\[T_{s}\text{ceil}\Bigg{(}\frac{t_{\overline{j}a_{\text{max}}}}{T_{s}}\Bigg{)} =T_{s}\text{ceil}\left(\frac{\overline{d}}{\frac{d3_{2}t_{\overline{d}}}{T_{s} }-t_{\overline{d}}}\right) \tag{34}\]  
Then:  
\[dd6=\left[\begin{array}{c}t_{\overline{d}}\\ T_{s}\text{ceil}\Bigg{(}\frac{t_{\overline{j}\gamma_{\text{max}}}}{T_{s}} \Bigg{)}\\ \frac{1}{t_{\overline{j}}\big{[}t_{\overline{j}}+T_{s}\text{ceil}\Big{(}\frac{ t_{\overline{j}\gamma_{\text{max}}}}{T_{s}}\Big{)}\big{]}}\end{array}\right] \tag{35}\]  
Time \(t_{\overline{j}}\) is derived from Equation (35) as:  
\[t_{\overline{j}}=dd6_{2} \tag{36}\]  
The following section considers calculations of acceleration phase time (\(t_{\overline{d}}\)).