## 3 Improved Artificial Potential Field Method Based on Joint Space
### The Gradient of the Potential Field Function  
The potential energy function is only dependent on joint angles \((\theta_{1},\cdots,\theta_{n})\) for a robotic arm. We use the gradient descent method to minimize the potential energy function and determine a set of angles so that the robotic arm can reach the target position in the direction of the fastest potential energy descent without a collision with obstacles. The attraction \(F_{att}\) is the negative of the gradient of the attraction potential field \(U_{att}\), and it can be expressed as (7):  
\[F_{att}=-\
abla U_{att}(\theta_{1},\cdots,\theta_{n})=-\mu d\Big{(}q,q_{goal} \Big{)}\
abla d(q,q_{goal}) \tag{7}\]  
\(q\) is the current position configuration of the robot, and \(q_{goal}\) is the position configuration of the robot when reaching the goal position. If the manipulator is entirely composed of revolute joints, \(q\) can be assumed to be \([\theta_{1},\cdots,\theta_{n}]\), and \(q_{goal}\) can be assumed to be \([\theta_{1}^{*},\cdots,\theta_{n}^{*}]\). Then, \(d\Big{(}q,q_{goal}\Big{)}\) can be expressed as (8):  
\[d\Big{(}q,q_{goal}\Big{)}=\sqrt{\sum_{i=1}^{n}\big{(}\theta_{i}-\theta_{i}^{* }\big{)}^{2}} \tag{8}\]  
If the manipulator comprises both prismatic joints (from joint 1 to joint \(j\)) and revolute joints (from joint \(j+1\) to joint \(n\)), in this case, \(q\) can be assumed to be \(\big{[}d_{1},\cdots,d_{j},\theta_{j+1},\cdots,\theta_{n}\big{]}\), \(q_{goal}\) can be assumed to be \(\big{[}d_{1}^{*},\cdots,d_{j}^{*},\theta_{j+1}^{*},\cdots,\theta_{n}^{*}\big{]}\), and we assign a weight \(\omega_{1}\) to the prismatic joint and a weight \(\omega_{2}\) to the revolute joint to eliminate the units of nonhomogeneous form. Then, \(d\Big{(}q,q_{goal}\Big{)}\) can be expressed as (9):  
\[d\Big{(}q,q_{goal}\Big{)}=\omega_{1}\times\sqrt{\sum_{i=1}^{j}\big{(}d_{i}-d_{ i}^{*}\big{)}^{2}}+\omega_{2}\times\sqrt{\sum_{i=j+1}^{n}\big{(}\theta_{i}- \theta_{i}^{*}\big{)}^{2}} \tag{9}\]  
The repulsive force \(F_{rep}\) is the negative of the gradient of the repulsive potential field \(U_{rep}\) can be expressed as (10):  
\[F_{rep}=-\
abla U_{rep}(\theta_{1},\cdots,\theta_{n})= \begin{cases}k\Big{(} \frac{1}{d(q,q_{obs})}-\frac{1}{d_{0}}\Big{)}\frac{1}{d^{2}(q,q_{obs})}\
abla d (q,q_{obs}),d(q,q_{obs})\leq d_{0}\\ 0,d(q,q_{obs})>d_{0}\end{cases}  \tag{10}\]  
We use the gradient descent to minimize the potential energy function in Equation (6). Equation (11) presents the generalized formula utilized for the \(s\)th iteration of gradient descent. and Equation (12) shows how the learning rate \(\lambda\) is calculated. \(q_{s}\) represents the position configuration of the robot arm at the \(s\)th cycle. \[q_{s}=q_{s-1}-\lambda\times\
abla U(\theta_{1},\cdots,\theta_{n}) \tag{11}\]  
\[\lambda=\epsilon 1+\epsilon 2\times d\Big{(}q,q_{goal}\Big{)}+\epsilon 3 \times d(q,q_{obs}) \tag{12}\]  
The learning rate \(\lambda\) is dynamic, and it depends on the distance between the end-effector and goal point and the distance between the joints of robot and obstacle. \(\epsilon 1,\epsilon 2,\epsilon 3\) are positive constants. \(\epsilon 1\) specifies the basic learning rate and \(\epsilon 2,\epsilon 3\) specify the sensitivity to the position of manipulator. As the end-effector approaches the goal point and the joint of the robot approaches the obstacle, the learning rate decreases. This is performed to avoid collision with obstacles and reach the goal point more accurately. If faster algorithm execution is desired, the values of \(\epsilon 1,\epsilon 2\), and \(\epsilon 3\) can be increased accordingly. In this paper, \(\epsilon 1,\epsilon 2\), and \(\epsilon 3\) are adjusted within the range of 0.5-1. The gradient of the attractive potential field is easy to calculate, while the gradient of the repulsive potential field is difficult to calculate, because the shortest distance \(d(q,q_{obs})\) between the robotic arm and the obstacle is difficult to calculate.