## 4 Trajectory Planning
### Trajectory Planning Mehthod  
Two methods for the trajectory planning are presented in this section. One is formulating the trajectory in the human-robot workspace directly, and then calculating the mechanical joint motions through the inverse kinematic. The other is inputting the patient's joint information, including the ROM and the training speed; the next step is constructing the trajectory and then calculating the mechanical joint motions. Two kinds of the training trajectories planned by two methods are shown in Figures 11 and 12. Figure 11: Circle training trajectory. Figure 10: The variable human-robot workspace. The circle training trajectory is applied in the sagittal multiple joint training, which is calculated by the first method. The main approach is calculating the typical incircles of the workspace boundaries, and other circles could be obtained by modifying the typical circles. The position of the incircle center could be obtained from Equation (14), and the circle trajectory is expressed as Equation (15). \[\left\{ \begin{array}{l}\left(x_{0}-x_{1}\right)^{2}+\left(z_{0}-z_{1}\right)^ {2}=\left(r_{1}+r_{0}\right)^{2}\\ \left(x_{0}-x_{2}\right)^{2}+\left(z_{0}-z_{2}\right)^{2}=\left(r_{2}-r_{0} \right)^{2}\end{array} \right., \tag{14}\]  
\[\left\{ \begin{array}{l}x=x_{0}+r_{0}sin(\omega t)\\ z=z_{0}+r_{0}cos(\omega t)\end{array} \right., \tag{15}\]  
where \(x_{0}\) and \(z_{0}\) represent the center position of the trajectory circle; \(r_{0}\) is the radius of the trajectory circle. \(x_{i}\) and \(z_{i}\) (\(i=1\) and \(2\)) represent the center position of boundary arcs; \(r_{i}\) (\(i=1\) and \(2\)) represents the radius of boundary arcs. \(\omega\) represents the angular velocity of the trajectory circle, and \(t\) represents time. Because there are multiple inverse position solutions of the robot mechanism model, the single position planning cannot meet the requirement for all joints. Therefore, it is necessary to add the angle (\([\mu_{1},o_{1},a_{1}]\)) planning of the end effector. The main principle is remaining the absolute angle value of the end effector in a lower degree to guarantee the human joints are trained in safe range. The spherical ellipse training trajectory is used for the hip circumduction rehabilitation, and it is planned depending on the patient's joint ROM through the second method. To guarantee the training effect of the hip joint, the patient's leg is left straight in the circumduction training. The rotation center could be calculated from the simplified Equation (4) by inputting the joint angle (\(\theta_{5}\) and \(\theta_{6}\)) ranges of the hip joint, and the trajectory of the human ankle could be built as follows:  
\[\left\{ \begin{array}{l}x_{0}=X_{F}-(l_{6}+l_{5})cos\overline{\theta}_{5}cos \overline{\theta}_{6}\\ y_{0}=(l_{6}+l_{5})sin\overline{\theta}_{5}cos\overline{\theta}_{6}\\ z_{0}=Z_{F}+(l_{6}+l_{5})sin\overline{\theta}_{6}\end{array} \right., \tag{16}\]  
\[\left\{ \begin{array}{l}x=X_{F}-(l_{6}+l_{5})cos(\overline{\theta}_{5}+Asin( \omega t))cos(\overline{\theta}_{6}+Bcos(\omega t))\\ y=(l_{6}+l_{5})sin(\overline{\theta}_{5}+Asin(\omega t))cos(\overline{\theta}_{6 }+Bcos(\omega t))\\ z=Z_{F}+(l_{6}+l_{5})sin(\overline{\theta}_{6}+Bcos(\omega t))\end{array} \right., \tag{17}\]  
where \(x_{0}\), \(y_{0}\) and \(z_{0}\) represent the rotation center position of the trajectory; \(\overline{\theta}_{i}\) represents the average value of the joint angle range. \(A\) and \(B\) refer to the major semi-axis and minor semi-axis of the ellipse trajectory, which are related to joint angle ranges. Figure 12: Spherical ellipse training trajectory. As the second method firstly considers the human joint ranges, the final trajectory should be checked and modified to avoid exceeding the robot workspace. Each final trajectory calculated from two methods is divided into a set of multitude points by the numerical method.