# Trajectory Planning of Robotic Arm Based on Particle Swarm Optimization Algorithm
## 2 Trajectory Planning
### Velocity Planning
The fourth segment: achieve with a constant speed \(v\) a uniform motion. The fifth segment: reduce the acceleration from zero to the preset value \(-a\) with a constant negative jerk \(J\). The sixth segment: decelerate with a constant acceleration \(-a\). The seventh segment: increase the acceleration from the preset \(-a\) value to zero with a constant jerk \(J\). Figure 2: Trapezoidal speed planning. Compared to the three-stage planning of the trapezoidal velocity curve, the S-shaped curve is considerably more complex. By strategically planning acceleration in the acceleration stage, deceleration stage, and acceleration and deceleration stage, S-shaped curve planning achieves superior acceleration continuity compared to trapezoidal curve planning. This substantial improvement significantly impacts during the process of mechanical operation. Therefore, Figure 3 provides a schematic diagram of S-shaped velocity planning. For the S-shaped velocity curve, given the maximum acceleration \(a_{\max}\) and the jerk \(J\), the corresponding acceleration of each stage of the seven stages described previously is defined as follows:  
\[a(t)=\left\{ \begin{array}{l}Jt,0\leq t\leq t_{1}\\ a_{\max},t_{1}\leq t\leq t_{2}\\ a_{\max}-J(t-t_{2}),t_{2}\leq t\leq t_{3}\\ 0,t_{3}\leq t\leq t_{4}\\ -J(t-t_{4}),t_{4}\leq t\leq t_{5}\\ -a_{\max},t_{5}\leq t\leq t_{6}\\ -a_{\max}+J(t-t_{6}),t_{6}\leq t\leq t_{7}\\ \end{array} \right. \tag{10}\]  
Thus, the velocity function corresponding to each stage can be obtained as follows:  
\[v(t)=\left\{ \begin{array}{l}\frac{1}{2}Jt^{2},0\leq t\leq t_{1}\\ v_{1}+a_{\max}(t-t_{1}),t_{1}\leq t\leq t_{2}\\ v_{2}+a_{\max}(t-t_{2})-\frac{1}{2}J(t-t_{2})^{2},t_{2}\leq t\leq t_{3}\\ v_{3},t_{3}\leq t\leq t_{4}\\ v_{4}-\frac{1}{2}J(t-t_{4})^{2},t_{4}\leq t\leq t_{5}\\ v_{5}-a_{\max}(t-t_{5}),t_{5}\leq t\leq t_{6}\\ v_{6}-a_{\max}(t-t_{6})-\frac{1}{2}J(t-t_{6})^{2},t_{6}\leq t\leq t_{7}\\ \end{array} \right. \tag{11}\]  
Figure 3: S-shaped speed planning. According to the time, speed, acceleration, and jerk of each stage, the final position can be expressed as follows:  
\[s(t)=\left\{ \begin{array}{l}\frac{1}{6}{I}t^{3},0\leq t\leq t_{1}\\ s_{1}+v_{1}(t-t_{1})+\frac{1}{2}{a}_{\max}(t-t_{1})^{2},t_{1}\leq t\leq t_{2}\\ s_{2}+v_{2}(t-t_{2})+\frac{1}{2}{a}_{\max}(t-t_{2})^{2}-\frac{1}{6}{J}(t-t_{2} )^{3},t_{2}\leq t\leq t_{3}\\ s_{3}+v_{3}(t-t_{3}),t_{3}\leq t\leq t_{4}\\ s_{4}+v_{4}(t-t_{4})-\frac{1}{6}{J}(t-t_{4})^{3},t_{4}\leq t\leq t_{5}\\ s_{5}+v_{5}(t-t_{5})+\frac{1}{2}{a}_{\max}(t-t_{5})^{2},t_{5}\leq t\leq t_{6}\\ s_{6}+v_{6}(t-t_{6})-\frac{1}{2}{a}_{\max}(t-t_{6})^{2}+\frac{1}{6}{J}(t-t_{6} )^{3},t_{6}\leq t\leq t_{7}\end{array} \right. \tag{12}\]  
In the S-shaped curve, the speed determines the speed of the system, whereas the acceleration defines the speed of the system's acceleration and deceleration. The jerk determines the flexibility of the system; the greater the jerk is, the greater the impact caused by the operation of the manipulator will be. Assuming that the urgency is infinite, the S-shaped velocity curve is switched into a trapezoidal velocity curve. Furthermore, the S-shaped velocity curve planning consists of planning the parameters relative to the jerk, the acceleration, the velocity, and so on, in each stage to realize a flexible operation in the manipulator. In practical application, the S-shaped velocity curve planning can also be removed from uniform acceleration and deceleration to reduce the number of stages to five. Furthermore, the uniform velocity can also be removed, yielding a total of four stages.