# A Novel Approach for a Inverse Kinematics Solution of a Redundant Manipulator
## 3 Inverse Kinematic Model and Computing Algorithm
### Final Inverse Kinematic Model  
For the final inverse kinematic model, a Jacobian-based method is used. This method is based on the minimization of the objective function, which deals with the primary task as well as secondary tasks. The advantage of this method is that the number of secondary tasks is not limited, as it is in task augmentation methods [33]. In this study, we investigate the algorithms for a five-link and 20-link manipulator moving in the plane. The redundancy of the investigated manipulator is used for the abovementioned optimization tasks, namely the obstacle avoidance task, the joint limit avoidance task, and the kinematic singularities avoidance task. The redundancy problem can be expressed by finding a vector \(\mathrm{q}\) which approximately satisfies Equation (7) by minimizing the objective function H. The final inverse kinematic model can be derived based on the same idea as mentioned in Section 3.1:  
\[\mathrm{H=}\parallel\dot{\mathrm{J_{q}}}-\dot{\mathrm{x}}\parallel^{2}+ \parallel\mathrm{J_{  
The vector of joint velocities \(\dot{\mathrm{q}}\) is expressed by \(\frac{\mathrm{dH}}{\mathrm{d}\dot{\mathrm{q}}^{\mathrm{-1}}}=0\):  
\[\dot{\mathrm{q}}=\left(\mathrm{J}^{-1}\mathrm{WJ}+\mathrm{J}_{\mathrm{c}}^{ \mathrm{T}}\mathrm{WJ}_{\mathrm{c}}+\mathrm{J}_{\mathrm{l}}^{-1}\mathrm{WJ}_{ \mathrm{l}}\right)+\mathrm{W}_{\mathrm{s}}\right)^{-1}\left(\mathrm{J}^{ \mathrm{T}}\mathrm{W}\dot{\mathrm{x}}+\mathrm{J}_{\mathrm{c}}^{\mathrm{T}} \mathrm{W}_{\mathrm{c}}\dot{\mathrm{x}}_{\mathrm{c}}+\mathrm{J}_{\mathrm{l}}^{ \mathrm{T}}\mathrm{W}_{\mathrm{l}}\dot{\mathrm{x}}_{\mathrm{l}}\right) \tag{21}\]  
Considering Equation (21), the joint velocities \(\dot{\mathrm{x}}_{\mathrm{c}}\) and \(\dot{\mathrm{x}}_{\mathrm{L}}\) have to be set to zero in order to avoid the joint limits and collisions with the obstacles. In other words, to prevent these secondary tasks, their velocities have to be zero. In this study, the dimensions of matrices \(\mathrm{W}_{\mathrm{c}}\), \(\mathrm{W}_{\mathrm{L}}\), and \(\mathrm{W}_{\mathrm{s}}\) are \(5\times 5\) for the five-link manipulator and \(20\times 20\) for the 20-link manipulator. Consequently, the final inverse kinematic model is:  
\[\dot{\mathrm{q}}=\left(\mathrm{J}^{-1}\mathrm{WJ}+\mathrm{J}_{\mathrm{c}}^{ \mathrm{T}}\mathrm{WJ}_{\mathrm{c}}+\mathrm{J}_{\mathrm{l}}^{-1}\mathrm{WJ}_{ \mathrm{l}}+\mathrm{W}_{\mathrm{s}}\right)^{-1}\left(\mathrm{J}^{\mathrm{T}} \mathrm{W}\dot{\mathrm{x}}\right) \tag{22}\]  
Next, the algorithm for the inverse kinematics solution will be presented. The aim of Algorithm 3 (Inverse kinematic model) is the positioning of the end-effector of the manipulator through the points of the planned path from Section 2 while manipulator links hold all secondary tasks. ```
1:CYCLE WHILE 1
2:Determination of new required vector \(\mathrm{x}_{\mathrm{d}}\in\mathrm{R}^{\mathrm{m}}\) from the matrix of planned path \(\mathrm{P}\in\mathrm{R}^{\mathrm{r}\times 2}\)
3:CYCLE WHILE 2
4:Computation of Jacobian matrix \(\mathrm{J}\) (damped least squares method)
5:Determination of actual end-effector position in the task space \(\mathrm{x}\in\mathrm{R}^{\mathrm{m}}\) with actual generalized variables \(\mathrm{q}\in\mathrm{R}^{\mathrm{n}}\)
6:Computation of general equation \(\dot{\mathrm{q}}=\left(\mathrm{J}^{-1}\mathrm{WJ}+\mathrm{J}_{\mathrm{c}}^{-1 }\mathrm{WJ}_{\mathrm{c}}+\mathrm{J}_{\mathrm{l}}^{-1}\mathrm{WJ}_{\mathrm{l} }+\mathrm{W}_{\mathrm{s}}\right)^{-1}\left(\mathrm{J}^{\mathrm{T}}\mathrm{W} \dot{\mathrm{x}}\right)\)
7:\(\mathrm{q}=\mathrm{q}_{\mathrm{previous}}+\mathrm{q}\mathrm{d}\mathrm{t}\)
8:\(\mathrm{q}_{the control system could work according to our requirements. For example, by adding obstacles to the manipulator workspace, while the priority of weight matrices remains the same, the numerical computing could not work as we expect. In many cases, the computing process not only slows down but the process even fails. For this reason, we have improved this method in order to deal with these problems during the simulation.