## 6 Joint Angle Prediction Using Gaussian Process Dynamical Motion Models  
State \(\mathbf{x}_{t}\) is used to predict \(\mathbf{x}_{t+1}\) through the learned dynamical mapping, \(f_{x}\). Figure 10 shows the proposed state transition system for real-time robot imitation. The dynamical mapping enables state transition, and the GPDM decoder reconstructs the humanoid robot joint angles. Hence, we can predict the humanoid robot joint angles in real time by map \(\mathbf{x}_{t}\rightarrow\mathbf{\theta}_{t+1}\). In addition, we devised a similarity measurement module to improve the prediction accuracy of the humanoid robot joint angles, as the accuracy from discrete state \(\mathbf{x}_{t}\) is limited. The similarity measurement determines the position of \(\mathbf{x}_{t}\) in the learned motion model. A sequence of states \(\mathbf{X}^{*}=[\mathbf{x}_{t-k-1},\cdots,\mathbf{x}_{t-1},\mathbf{x}_{t}]\) is used instead of discrete state \(\mathbf{x}_{t}\), with \(k\) being the size of \(\mathbf{X}^{*}\). The learned motion model is divided to form database \(\mathbf{X}_{u}=[\mathbf{X}_{1},\mathbf{X}_{2},\mathbf{X}_{3},\cdots]\) (as shown in Figure 11), where the size of each \(\mathbf{X}_{i}\) (\(\mathbf{X}_{i}\subset\mathbf{X}_{u}\)) is also \(k\). A cosine distance function is adopted to calculate the similarity between \(\mathbf{X}^{*}\) and \(\mathbf{X}_{i}\):  
\[dis=\frac{\mathbf{X}^{*}\cdot\mathbf{X}_{i}}{||\mathbf{X}^{*}||||\mathbf{X}_{i}||}. \tag{9}\]  
Then, input \(\mathbf{X}^{*}\) is updated with the \(\mathbf{X}_{i}\) retrieving the highest similarity. Thus, the joint angle is predicted with an updated \(\mathbf{X}^{*}\), reducing the uncertainty of discrete state \(\mathbf{x}_{t}\), and thus, improving the prediction accuracy. Figure 11: Similarity measurement for state \(\mathbf{x}_{t}\). Figure 10: Real-time joint angle prediction using GPDM motion models. Figure 9: Joint angle reconstruction using decoder \(f_{\theta}\). To verify the prediction system, we collected the humanoid robot joint angles from the same motion as learning data to form a test dataset. The test dataset contained 500 frames of humanoid robot joint angles. Figure 12 illustrates the encoding of humanoid robot joint angle \(\mathbf{\theta}_{t}\) into \(\mathbf{x}_{t}\). Based on the GPDM learned motion models, we made predictions using the dynamical mapping to obtain \(\mathbf{x}_{t+1}\). Finally, the humanoid robot joint angles in state \(\mathbf{\theta}_{t+1}\) were reconstructed. Note that the GPDM does not define an encoder mapping, which is obtained by a feed-forward neural network, where the learning dataset of humanoid robot joint angles, \(\Theta\), is the input, and the GPDM learned motion model, \(X\), is the output. We perform relearning for map \(\Theta\to X\) as the encoder. Note that we divide the learning dataset in to training set (70%), validation set (15%), and testing set (15%) in learning encoder mapping. We set \(k=5\) and performed predictions of the humanoid robot joint angles in real time to verify the prediction system. We selected two important humanoid robot joint angles (LShoulderRoll and LElbowRoll) and obtained the accurate predictions shown in Figure 13. For further verification, we applied the predicted joint angles to a simulated NAO humanoid robot. We found that the predicted joint angles without using the proposed similarity measurement elicit unnatural motions of the humanoid robot. Errors occur by the predicted joint angles being beyond the range of humanoid robot motion. Figure 13a,b shows the predicted joint angles using the proposed similarity measurement. The predicted joint angles with the similarity measurement module appear to be smooth and are consistent with the real joint angles. The predicted joint angles with the proposed similarity measurement make the robot wave its hands naturally, as shown in Figure 14, verifying the effectiveness of using this measurement. Figure 12: Verification of joint angle prediction.