# Neural Network-Enhanced Fault Diagnosis of Robot Joints
## 3 Diagnosis Framework
### BP Neural Network for Classification  
The task of the neural network here is to act as a classifier to classify the trajectories in Figure 5. Since the trajectories of the sixth joint of the robotic arm are characteristic of a fault, and no faults are the same and therefore cannot be classified, the first step is to consider only the six trajectories generated by the no fault condition and the first five joints fault in sequence to classify them, so as to achieve the preliminary fault diagnosis. The feature extraction of the position of the actuator at the end of the robotic arm is mentioned above, and combined into one data set; the structure of the network is shown in Figure 7. There are three inputs and six outputs, which include two hidden layers of the neural network and the inputs of the neural network from the \(x\)\(y\)\(z\) positions of the database, and the  
Figure 5: Trajectories for different joint faults. Figure 6: Process of feature extraction. outputs are six classifications. In addition to this, a label matrix needs to be pre-designed, i.e., for an experiment with n samples per trajectory, the label matrix is 6n \(\times\) 1, and the labels are changed every n rows to achieve that each trajectory has its own corresponding label for classification. In order to obtain information about the effect of different sampling numbers, i.e., database sizes, on the results, the number of samples per trajectory was set to 1500, 5000, and 10,000, respectively, when the fault injection was one degree, and the total database size was the number of samples of a single trajectory multiplied by the number of trajectories (6). In total, 70% of the data will be used as a training set, and 15% of the remaining data will be used as a validation set and a test set, respectively. The results of the network structure, related parameters and training are shown in the following tables, where the Tables 1-3 show the result of network training with different size of injected fault. It can be seen that the fault diagnosis accuracy of the neural network reaches more than 94% when the fault injection is one degree, and improves with an increase in data. \begin{table}
\begin{tabular}{l c c c c} \hline \hline
**Sampling Number** & **Number of Epochs** & **Layers** & **Accuracy (\%)** & **Cross-Entropy Loss** \\ \hline
1500 & 400 & 3-11-11-6 & 94.33 & 0.2318 \\
5000 & 400 & 3-11-11-6 & 96.33 & 0.2152 \\
10,000 & 400 & 3-11-11-6 & 96.80 & 0.1125 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Network training results of joint diagnosis for robots. Size of joint angle error = 1\({}^{\circ}\) (single feature: position). \begin{table}
\begin{tabular}{l c c c c} \hline \hline
**Sampling Number** & **Number of Epochs** & **Layers** & **Accuracy (\%)** & **Cross-Entropy Loss** \\ \hline
1500 & 800 & 3-11-11-6 & 89.83 & 0.2762 \\
5000 & 800 & 3-11-11-6 & 93.10 & 0.3324 \\
10,000 & 800 & 3-11-11-6 & 95.97 & 0.2872 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Network training results of joint diagnosis for robots. Size of joint angle error = 0.2\({}^{\circ}\) (single feature: position). Figure 7: Structure of the neural network. This means that, when classifying a section of trajectory, a relatively accurate diagnosis of the trajectory with or without fault, and which specific joints are in fault, can be determined. If the goal is to diagnose faults more accurately, a good way is to reduce the size of the injected faults by setting the size of the injected faults to 0.5 and 0.2 degrees and repeating the above steps, the results of which are shown in Tables 4 and 5. It can be seen that, if the size of the injected faults is reduced to achieve an increase in diagnostic accuracy, the accuracy of the classification of the corresponding neural network will be reduced and the number of epochs required will increase, which means that more time and resources are required for fault diagnosis and there is a high risk of overfitting.