# Uniform vs. Lognormal Kinematics in Robots: Perceptual Preferences for Robotic Movements
## 3 Robotic Arm Modelling
### Pose of an Object
#### 3.1.2 Inverse Kinematic  
The goal of inverse kinematics is to deduce the position of each joint to obtain a given pose on the tool. In certain robots, these equations cannot be deduced in a closed fashion and they must therefore be calculated iteratively. In the case of the ABB IRB120 robot, the equations for each of the joints can be deduced and can be found at [18]. In a six-degrees-of-freedom robot such as the ABB IRB120, its tool can reach any pose that lies within its working area. Broadly speaking, this is due to the fact that the first three joints are mainly used to position the tool and the last three to orientate it. If the robot's tool only needs to describe a path regardless of the orientation, or it needs to set the values of some of the joints, then the method described in [18] is not valid and must be modified. In this work, the last three joints are intended to be kept immobile and the position of the tool should only depend on the first three joints. That means that the robot will behave like a three-degrees-of-freedom system. To this end, the following tasks were performed in a Matlab script:  
1. The variables of the last three joints were defined as global and kept constant: \[\mathbf{q_{46}}=[q_{4},q_{5},q_{6}]\] (7)
2. The value of the point to calculate its inverse kinematic was inserted and declared as a global variable: \[\mathbf{p}=[p_{x},p_{y},p_{z}]\] (8) \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Joint** & \(\theta\) & \(d\) & \(a\) & \(\alpha\) \\ \hline
1 & \(q_{1}\) & \(L_{1}\) & 0 & \(-\pi/2\) \\
2 & \(q_{2}-\pi/2\) & 0 & \(L_{2}\) & 0 \\
3 & \(q_{3}\) & 0 & \(L_{3}\) & \(-\pi/2\) \\
4 & \(q_{4}\) & \(L_{4}\) & 0 & \(\pi/2\) \\
5 & \(q_{5}\) & 0 & 0 & \(-\pi/2\) \\
6 & \(q_{6}+\pi\) & \(L_{5}\) & 0 & 0 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Denavit–Hartemberg parameters. 3. A function called ErrorFract was created, with its parameter being a variable having the value of the first three joints and formatted as: \[\mathbf{q_{13}}=[q_{1},q_{2},q_{3}]\] (9) This function has as input parameters the positions of the first three joints. The position of the last three joints, \(\mathbf{q_{46}}\) and the point used to calculate the inverse kinematic p are passed to the function as global variables. This function, which uses forward kinematics, calculates and returns the error when applying a joint position. Algorithm 1 shows this function:  
4. The Matlab fminsearch function is used and introduces the function to be minimized and the seed value used to begin the iteration. The function returns the positions of the first three joints that minimize the error and has the following format: \[\mathbf{q_{13c}}=fminsearch(^{\prime}ErrorFract^{\prime},\mathbf{q_{130}})\] (10)
5. By combining the positions of the first three joints with those of the last three, the position of the robot is obtained: \[\mathbf{q}=[\mathbf{q_{13c}},\mathbf{q_{46}}]\] (11)  
To calculate several consecutive points of a trajectory, the procedure above is repeated for each new point, but using the value obtained from the previous point as a seed. **4. Generating Movements with the Robot**  
One of the objectives of both current and future automation is to have robots interact with people. This carries many advantages since there are tasks in which the presence of a human facilitates automation and in the event of a breakdown or malfunction of the robotic cell, the fact that it can be accessed without the need to stop production increases productivity considerably. While a lot of effort has been invested in developing the sensors to apply in the cell and in their implementation in robot control software, one aspect that has not been given enough importance is the movement of robots. It has been shown that the speed profile of human movements is a flared one, meaning that the speed increases rapidly in the first stage of movement until it reaches a maximum and then decreases until it reaches its destination point.