# An Algorithm for Solving Robot Inverse Kinematics Based on FOA Optimized BP Neural Network
## 3 Algorithm Principle  
### BP Neural Network Algorithm  
In 1985, the scholars [PERSON] and [PERSON] proposed a multi-layer feedforward artificial neural network using the error back propagation algorithm, namely BP neural network [30]. The ordinary BP neural network contains two parts: the forward propagation of the signal and the back propagation of the error. The actual output is calculated from the input to the output, and weights and thresholds are corrected from the output to the input. A single basic artificial neuron model is shown in Figure 4.  
Among them, \(x_{j}(j=1,2,\cdots,N)\) is the input of the \(j\)-th node, \(w_{ij}\) is the weight, \(\theta_{i}\) is the threshold, and \(y_{i}\) is the output of neuron \(i\). The output \(y_{i}\) can be expressed as:  
\[y_{i}=f(\text{net}_{i})=f(\sum_{j=1}^{N}w_{ij}x_{j}+\theta_{i}) \tag{7}\]  
Among them, the \(f\) function is the activation function, and the most commonly used form is the Sigmoid function, and its expression is Formula (8):  
\[f(x)=\frac{1}{1+e^{-ax}},a\in\text{C} \tag{8}\]  
If the net activation \(f\) is positive, the neuron is in an excited state. Otherwise, the neuron is in a suppressed state.  
This paper uses the BP algorithm to solve inverse kinematics. A neural network structure is established, and the input layer has six input signals, corresponding to \(p_{x}\), \(p_{y}\), \(p_{z}\), \(\alpha\), \(\beta\), \(\gamma\). The output layer has three output signals, respectively, corresponding to the robot's three joints \(\theta_{1}\), \(\theta_{2}\), \(\theta_{3}\).  
According to [PERSON]'s theorem, a BP neural network with one hidden layer can complete any n-dimensional to m-dimensional mapping [31]. Increasing the number of layers of the neural network can improve the accuracy. However, it will complicate  
Figure 4: Single artificial neuron model.  
Figure 3: The model of the FOA optimized BP neural network.  
the neural network and extend the training time. Using two hidden layers can make the mapping effect of the neural network better, and increasing the number of neurons in the hidden layer can improve the accuracy. In the BP neural network, the number of neurons in each layer has a great influence on the network performance. According to Equation (6), after experiments and comparisons, this paper chooses a network structure containing two hidden layers. The first hidden layer has 24 neurons, and the second hidden layer has 43 neurons. The designed BP neural network topology is shown in Figure 5.  
Figure 5 shows the topology of the designed BP neural network. The layers are fully interconnected, and there is no interconnection between the same layers.  
The core of the BP neural network algorithm is to solve the minimum value of the error function. BP neural network adjusts the weights and thresholds of each layer according to the error gradient descent method. There are weaknesses, such as slow convergence, low learning efficiency, weak generalization ability, and easy to fall into local minimums. Therefore, the optimization algorithm is combined for improvement.