# Manipulator Smooth Control Method Based on LSTM-XGboost and Its Optimization Model Construction
## 4 The Stability Prediction Model of Manipulator Based on LSTM-XGboost
### Based on LSTM-XGboost Prediction Model Construction
The model input is the instruction parameters of the manipulator, including speed v, acceleration a, displacement D, and the output index of the previous step; the output is the current sequence segment index. The stability index of the manipulator is denoted as Y; Y is the vector value, namely Y = ( \(\mid a\mid\)_ave_, \(\delta_{a}\), \(a_{p}\), \(\delta_{w}\), jerk). When predicting it, the continuous motion of the manipulator is first decomposed into n single-step motions according to the action. The decomposition diagram is shown in Figure 3.  
The instruction-feature index prediction process based on XGboost is shown in Figure 4. After each single step of movement, the velocity v, acceleration a and displacement D are input into the XGboost model together with the Y value of the previous step, and the cycle is repeated until the end of the action and the resulting Y\({}_{n}\) is the final feature index. The vibration signal of the manipulator is collected by the six-axis Bluetooth attitude angle measurement sensor, and the sampling frequency is 100 Hz. The measurement sensor is fixed at the end of the six-axis manipulator. The collected signals include the acceleration, angular velocity, and angle of the XYZ axis in the tool coordinate system of the six-axis manipulator. The sample size of the test set in the data set is 300, and the 'instruction-feature index' model built in this chapter is used to predict Y. Considering that the five indexes have the same order of magnitude, the accuracy is measured by the mean absolute error (MAE). According to the above process, the model is established, and the motion sample of the manipulator is divided according to the action; that is, the input instruction for each action and the prediction information of the previous action are input, and the output is the overall indicator jerk of the sample until the action. During training, Steps are set to the number of actions of each sample, and Loss is the root mean square of the error of the entire moving process so that the complete sample motion process can be gradient descent. The number of iterations is set to 1000, and the learning rate is 0.1. Taking jerk as an example, the model predicts the jerk of a single action index. It can be seen that the model performs well in the prediction of the action index, and the error is 0.0005. See Figure 5.  
Figure 3: Mechanical arm vibration signal segmentation diagram. Further observation of the model's performance on the full sample motion shows each sample, including multiple actions and multiple instructions. According to the instruction combination sequence, the index jerk of the sample is predicted. Figure 6 shows that the model can give the sample motion index jerk according to the instruction sequence, and the consistency is good. The performance of the model in index prediction is shown in Table 2. It can be seen from the results in Table 2 that the MAE values predicted for the five indicators are low and the prediction accuracy is high. Figure 4: Instruction–Feature Index Prediction Model Based on XGboost. The data are preprocessed before training the model. Relevant features are then extracted to predict velocity (v), acceleration (a) and displacement (D) then the training data are split into subsets, as shown in the blue region in the figure. The XGboost algorithm (green) is used to train the model using the training dataset. The XGBost algorithm has hyperparameters that control the training process. The performance of the model is then evaluated using the testing dataset (brown region) to show the accuracy of predicting acceleration, velocity and displacement, and the feature index (\(Y_{n}\)) is obtained. Figure 5: Single Step Prediction Effect of Test Set. The feature indicators and input instructions obtained in the XGboost model are used as the input of the LSTM model, and the score card is scored as the label value. The model is trained, and the output score prediction value of the LSTM is compared with the sample score card score.