# A Hybrid Mapping Method with Position and Stiffness for Manipulator Teleoperation
## 4 Stiffness Mapping Method for Compliant Teleoperation
### Stiffness Identification System at the Human Arm Endpoint
#### 4.3.2 Stiffness Classification at the Human Arm Endpoint  
For teleoperating the stiffness of the slave robot to execute most tasks, it is not necessary to adjust the end stiffness continuously and accurately. For the offline samples, the pattern classification with K-means++ clustering is firstly used to cluster the continuous stiffness into three types. For the online applications, the K nearest neighbor (KNN) and XGBoost (eXtreme Gradient Boosting) are utilized to classify the stiffness at the human arm endpoint.  
(1) Stiffness Clustering for Offline Samples  
Because it is not necessary to adjust the stiffness at the robot endpoint continuously and accurately in most tasks, according to the features of sEMG signals, the pattern classification method with K-means++ clustering is utilized to classify the stiffness \(K_{x}\), \(K_{y}\), \(K_{z}\) for offline samples at the human arm endpoint into three categories (low, middle and high). The stiffness cluster center at the human arm endpoint with K-means++ is shown in Table 1.  
(2) Stiffness Classification for Online Applications  
According to the stiffness clustering, the K nearest neighbor (KNN) and XGBoost (eXtreme Gradient Boosting) are utilized for online applications to classify the real-time stiffness at the human arm endpoint. The features of sEMG signals are the input, and the classification results of stiffness at the human arm endpoint based on k-means++ cluster are used as output.  
(a) KNN  
KNN is a simple and widely used classification method. If most of the k neighbor samples in the feature space belong to a certain category, the sample also belongs to this category and has the characteristics of the samples in this category. Obviously, the parameter k is important for the classification effect of the model, and it is general set to less than 30. According to the actual prediction accuracy, the k for \(K_{x}\), \(K_{y}\) and \(K_{z}\) classifiers are set to 26, 18 and 22, respectively. The accuracy of stiffness classification with KNN is shown as Figure 7, and the confusion matrix of stiffness classification based on MAV1 is shown as Figure 8.  
In Figure 7, the accuracy of stiffness classification at the human arm endpoint is close to 70% when the sEMG features are extracted by MAV1, WL, WPTSVD and WTSVD, while it is only about 40% when the ZC is selected as the sEMG features. In Figure 8, it can be seen that the stiffness at the human arm endpoint in all directions has certain coupling. Moreover, the stiffness classification method with KNN is better for low stiffness and high stiffness, but worse for middle stiffness. The main reasons for this phenomenon are that the operator is difficult to determine to apply the appropriate force to generate a middle stiffness. Because of time consuming with WPTSVD, three kinds of sEMG feature (MAV1, WL and WTSVD) are used to predict the stiffness at the human arm endpoint in real-time based on KNN.  
(b) XGBoost  
XGBoost implements machine learning algorithms under the Gradient Boosting framework, and it is an optimized distributed gradient boosting library designed to be highly efficient, flexible and portable. In this paper, the Python package xgboost [25] is used for the stiffness classification at the human arm endpoint in online applications. Table 2 is the hyper parameter table obtained by the cross-validation. The accuracy of stiffness classification with XGBoost is shown as Figure 9, and the confusion matrix of stiffness classification based on MAV1 is shown as Figure 10.  
In Figure 9, Compared with the KNN algorithm, the accuracy of stiffness classification with XGBoost is improved. The classification accuracy is over 75% when the MAV1 is selected as the feature of sEMG signals. According to the confusion matrix of stiffness in Figure 10, the classification effect at the human arm endpoint for low stiffness and high stiffness is better than that of middle stiffness, which is similar to the results of KNN method.