3.3.1. Trajectory Interpolation

The trajectory constraints of Equation (8) represent the initial joint position *f*(0), joint position *<sup>f</sup>*(*th*) to hit the ball, initial joint velocity . *<sup>f</sup>*(0), and velocity . *f*(*th*) to hit the ball. θ<sup>0</sup> and θ*<sup>h</sup>* represent the initial position of the joint and the joint position at the moment of hitting the ball, *th* represents the time of the moment of hitting the ball, and *uh* represents the angular velocity vector at the moment of hitting the ball. Four simultaneous equations are constructed according to four constraints, and each coefficient can be obtained by calculating the simultaneous equations.

After hitting the ball, a joint trajectory has to be generated to reduce the speed of the robot arm. By calculating the simultaneous equations with the following four constraints, a joint trajectory is generated to decrease the velocity of robot arm.

$$f(t\_{\hbar}) = \Theta\_{\hbar \prime} \, f\left(t\_f\right) = \Theta\_{f\prime} \, \dot{f}(t\_{\hbar}) = u\_{\hbar \prime} \, \dot{f}\left(t\_f\right) = 0 \tag{9}$$

The initial joint position is the angle to hit the ball, the final joint position is the angle in the configuration where the robot arm stops, the initial velocity is *uh* at the time of the hit, the final velocity is 0, and *tf* is the time to stop.

#### 3.3.2. Robot Batting Trajectory

The angular and velocity trajectories of joints 1 and 3 for when the batting task is performed as generated by the cubic spline function and constraints are shown in Figure 10. Through cubic spline interpolation, the trajectories of the joints were smoothly interpolated from the initial position before batting to the stop position after batting. The batting time is 0.274 s and the time it takes for the robot arm to stop completely after it starts moving is 0.914 s. The maximum angular velocity is given only to joints 1 and 3 because the maximum angular velocity of the other joints is limited and has little effect on the speed of the end-effector. After hitting, the robot arm stops smoothly by imposing a constraint on the angular velocity of joints 1 and 3 as 0. The velocity of the end-effector is calculated as

$$\mathbf{V}\_{\mathbf{R}} = \mathbf{J}\dot{\boldsymbol{\Theta}}\tag{10}$$
  $\text{where } \mathbf{J} = \begin{bmatrix} \frac{\partial P\_{\mathbf{Y}}}{\partial \theta\_1} & \cdots & \frac{\partial P\_{\mathbf{Y}}}{\partial \theta\_6} \\ \frac{\partial P\_{\mathbf{Y}}}{\partial \theta\_1} & \cdots & \frac{\partial P\_{\mathbf{Y}}}{\partial \theta\_6} \\ \frac{\partial P\_{\mathbf{Y}}}{\partial \theta\_1} & \cdots & \frac{\partial P\_{\mathbf{Y}}}{\partial \theta\_6} \end{bmatrix}, \dot{\boldsymbol{\Theta}} = \begin{bmatrix} \dot{\theta}\_1 \\ \vdots \\ \dot{\theta}\_6 \end{bmatrix}$ 

<sup>J</sup> is the Jacobian matrix of the robot arm, and . Θ is a vector consisting of the angular velocities of the joints of the robot arm. The calculated velocity of the end-effector is 6.2 m/s.

**Figure 10.** The angular and velocity trajectories of joints 1 and 3. When the robot arm hits the ball, the joint angular velocity of joint 1 and joint 3 was constrained to −500◦/s, and the rest of the joints to zero.

#### 3.3.3. Ball Direction Control

The ultimate goal of the batting task is to move the object to the desired target position in a single collision. The orientation of the end-effector of the robot must be controlled to move the ball to the desired target position. That is, the direction of the ball after the collision can be controlled by controlling the normal vector perpendicular to the circular plate of the end-effector. The normal vector can be calculated from the coefficient of restitution between the ball and the end-effector, the velocity of the ball and the endeffector before and after the collision, and some assumptions. Figure 11 shows the velocity vector of the ball before the batting (*VB*<sup>1</sup> ∈ *<sup>R</sup>*3), the velocity vector of the ball after the batting (*VB*<sup>2</sup> ∈ *<sup>R</sup>*3), and the velocity vector of the end-effector of the robot (*VR* ∈ *<sup>R</sup>*3) and the normal vector (*<sup>n</sup>* ∈ *<sup>R</sup>*3) perpendicular to the plane of the end-effector.

**Figure 11.** Vector arrangements representing end-effector velocity (*VR*), ball velocity before collision (*VB*1), ball velocity after collision (*VB*2), and normal vector (*n*).

The vector shown in Figure 11 can be expressed as shown in Figure 12 under the assumption that there is no change in the velocity of the end-effector before and after the collision, and that there is only energy loss caused by the deformation of the ball in the collision.

**Figure 12.** Vector analysis before and after collision.

From Figure 12, the relationship between the velocity vectors and the normal vector can be defined by the collision coefficient equation

$$\varepsilon = \frac{(v\_{B2} - v\_R) \cdot n}{(v\_{B1} - v\_R) \cdot n} \tag{11}$$

The collision coefficient (e) is the speed ratio before and after the collision of the ball, and the material of the ball and the end device has a major influence on the collision coefficient. Considering the inherent properties between the ball and the end-effector, we obtained the collision coefficient through collision experiments. The coefficient was obtained by dropping the ball perpendicular to the end-effector to measure the speed

before and after the impact. The average collision coefficient obtained from 20 experiments is 0.6506 and the standard deviation is 0.0448. Based on the assumptions above, the velocity of the horizontal component before and after the collision of the ball is preserved and can be expressed as

$$
v\_{B1} - v\_R - \left\{ (v\_{B1} - v\_R) \cdot n \right\} n = v\_{B2} - v\_R - \left\{ (v\_{B2} - v\_R)n \right\} n \tag{12}$$

The above equation can be rearranged as

$$m = \frac{\upsilon\_{B2} - \upsilon\_{B1}}{||\upsilon\_{B2} - \upsilon\_{B1}||}\tag{13}$$

Note that the normal vector is in the same direction as that of the difference in the velocity vector before and after the collision of the ball. Therefore, the information of *vB*<sup>1</sup> and *vB*<sup>2</sup> is needed to calculate *n*. The *vB*<sup>1</sup> is calculated by differentiating Equation (5), and the direction of *vB*<sup>2</sup> is calculated from the estimated trajectory of the ball and the target position. Therefore, to calculate the normal vector, it is necessary to calculate the magnitude of the *vB*2.

The direction of the velocity vector after the collision is derived from the vector geometry. The velocity vector after the collision in Figure 12 can be set to one side of the triangle as shown in Figure 13. *ρ* is the direction vector of *v*2, and *σ* represents the horizontal relative velocity vector that is preserved before and after the collision of the ball. The Pythagorean theorem applies to the two triangles *abc* and *acd* and is represented by the following two equations:

$$||v\_{B1} - v\_R||\_2 = ||(v\_{B1} - v\_R) \cdot \sigma||\_2 + ||(v\_{B1} - v\_R) \cdot n||\_2. \tag{14}$$

$$||\upsilon\_{\mathcal{B}2} - \upsilon\_{\mathcal{R}}||\_2 = ||(\upsilon\_{\mathcal{B}1} - \upsilon\_{\mathcal{R}}) \cdot \sigma||\_2 + ||(\upsilon\_{\mathcal{B}1} - \upsilon\_{\mathcal{R}}) \cdot n||\_2 \epsilon^2 \tag{15}$$

**Figure 13.** Vector analysis.

The difference between the two equations is

$$||v\_{\mathcal{B}1} - v\_{\mathcal{R}}||\_2 - ||v\_{\mathcal{B}2} - v\_{\mathcal{R}}||\_2 = ||(v\_{\mathcal{B}1} - v\_{\mathcal{R}}) \cdot n||\_2 \left(1 - e^2\right) \tag{16}$$

The cosine law is applied to *abd* as

$$||(v\_{B1} - v\_R) \cdot n||\_2(\varepsilon + 1)^2 = ||v\_{B1} - v\_R||\_2 + ||v\_{B2} - v\_R||\_2 - 2||v\_{B1} - v\_R|| ||v\_{B2} - v\_R|| \cos \theta\_\prime \tag{17}$$

$$\text{where } \theta = \cos^{-1} \frac{(v\_{B1} - v\_R) \cdot \rho}{||v\_{B1} - v\_R|| ||\rho||}$$

From Equations (16) and (17), we can calculate the relative velocity of the ball after the collision as

$$||v\_{\rm B2} - v\_{\rm R}|| = \frac{||v\_{\rm B1} - v\_{\rm R}||(1 - e)\cos\theta + \sqrt{\left(||v\_{\rm B1} - v\_{\rm R}||(1 - e)\cos\theta\right)^2 + 4||v\_{\rm B1} - v\_{\rm R}||\_2 e}}{2} \tag{18}$$

From Equations (13) and (18), the normal vector perpendicular to the circular plate of the terminal end-effector can be expressed as

$$m = \frac{\upsilon\_{B2} - \upsilon\_{B1}}{||\upsilon\_{B2} - \upsilon\_1||} = \frac{(\upsilon\_{B2} - \upsilon\_R) - (\upsilon\_{B1} - \upsilon\_R)}{||(\upsilon\_{B2} - \upsilon\_R) - (\upsilon\_{B1} - \upsilon\_R)||}\tag{19}$$

From the calculated normal vector, the orientation of the ball after the collision is adjusted by adjusting the orientation of the robot end-effector.
