Inverse Kinematic Algorithm with Newton-Raphson Method iteration to Control Robot Position and Orientation based on R programming language

Program transformasi homogen adalah fungsi yang digunakan untuk menghitung matriks transformasi homogen pada posisi dan orientasi tertentu dari manipulator tiga tautan. Matriks transformasi homogen adalah matriks 4x4 yang digunakan untuk mewakili posisi dan orientasi suatu objek dalam ruang tiga dimensi. Pada program, matriks rotasi R dihitung menggunakan rumus Euler dan disimpan dalam matriks 4x4 beserta koordinat posisinya. Fungsi matriks Jacobian menghitung matriks Jacobian pada posisi dan orientasi tertentu dari manipulator tiga tautan menggunakan matriks transformasi homogen. Rumus Euler yang digunakan dalam program didasarkan pada matriks rotasi untuk rotasi di sekitar sumbu x, y, dan z. Keluaran dari fungsi ini dapat


INTRODUCTION
The homogeneous transformation matrix is a mathematical tool used to describe the position and orientation of an object in three-dimensional space. It is a 4x4 matrix that combines a 3x3 rotation matrix with a 3x1 translation vector [1]. The homogeneous transformation matrix can be used to convert between coordinate frames or to transform a point from one coordinate frame to another [2]. In the case of a three-link manipulator, the homogeneous transformation matrix can be used to represent the position and orientation of the end-effector (the tool at the end of the manipulator) [3]. The function homogeneous transform takes as input the joint angles of the manipulator and the link lengths, and returns the homogeneous transformation matrix at that specific position and orientation [4]. The Euler formula used in the function calculates the 3x3 rotation matrix R based on the three angles of rotation around the x, y, and z axes (also known as roll, pitch, and yaw angles) [5].
The rotation matrix R is then combined with the 3x1 translation vector (the position coordinates of the end-effector) to create the 4x4 homogeneous transformation matrix [6]. The Jacobian matrix is a mathematical tool used to describe the relationship between joint velocities and end-effector velocities [7]. It can be used to compute the inverse kinematics of a manipulator (i.e. determine the joint angles required to move the end-effector to a desired position and orientation) and to plan trajectories for the manipulator [8]. In the case of a threelink manipulator, the Jacobian matrix can be used to determine how changing the joint angles will affect the position and orientation of the end-effector [9]. The jacobian function takes as input the joint angles of the manipulator, the link lengths, and the position and orientation coordinates of the end-effector, and returns the Jacobian matrix at that specific position and orientation [10]. The Jacobian matrix is a 6x3 matrix, where the first three columns represent the linear velocities of the end-effector (the rate of change of position in the x, y, and z directions), and the last three columns represent the angular velocities of the end-effector (the rate of change of orientation around the x, y, and z axes). The values in the Jacobian matrix are calculated based on the link lengths and the current joint angles of the manipulator, and can be used to determine the joint velocities required to achieve a desired end-effector velocity.
Research gap exists in these two functions. The functions are only applicable to threelink manipulators with fixed link lengths and cannot be used for manipulators with variable link lengths. There is a need to develop functions that can handle manipulators with variable link lengths. The current functions use the Euler formula to calculate the rotation matrix, which is not suitable for all types of manipulators. There is a need to develop alternative methods to calculate the rotation matrix that can be used for different types of manipulators.

METHODS
The research method used in this program code is an experimental method. The experimental method is a research method that is carried out by measuring and direct observation of the object or phenomenon under study. The aim of the experimental method is to obtain empirical data that can be used as a basis for developing and testing hypotheses. In this program code, measurements are made on the position and orientation of an object in threedimensional space using a homogeneous transformation matrix and a Jacobian matrix. The homogeneous transformation matrix is used to represent the position and orientation of objects in three-dimensional space, while the Jacobian matrix is used to calculate the partial derivative of the effector tip position vector to the velocity of the manipulator joints [11].
The empirical data generated from this experimental method is used to test the correctness of the Euler formula used in the homogeneous transform program and the formula for calculating the Jacobian matrix in the Jacobian program. Thus the experimental method used in this program code can be used to obtain empirical data that can be used as a basis for testing hypotheses about the calculation of the homogeneous transformation matrix and the Jacobian matrix on the three-link manipulator.

The function to calculate the homogeneous transformation matrix at a certain position and orientation
The R-based programs that will be reviewed are as follows:  The homogeneous transform program is a function used to calculate a homogeneous transformation matrix at a certain position and orientation from a three-link manipulator [12]. Homogeneous transformation matrix is a 4x4 matrix that is used to represent the position and orientation of an object in three-dimensional space [13]. The mathematical equation for calculating a homogeneous transformation matrix at a certain position and orientation is as follows in eq (1). where R11, R12, R13, R21, R22, R23, R31, R32, and R33 are the elements of the 3x3 rotation matrix that represent the object's orientation in three-dimensional space, and pos x, pos y, and pos z are the coordinates of the object's position in three-dimensional space. In the homogeneous transform program, the 3x3 R rotation matrix is calculated using Euler's formula and stored in 4x4 matrix form along with the post position coordinates, which are then returned as function output [14]. 11 The Euler formula used in the program is as follows: R  are 3x3 rotation matrices for rotations of theta on the x-axis, y-axis, and z-axis, respectively. To calculate the rotation matrix R in the homogeneous transform program, the following Euler formula is used: R  are 3x3 rotation matrices for rotations of theta on the x-axis, y-axis, and z-axis, respectively. To calculate the rotation matrix R in the homogeneous transform program, the following Euler formula is used

Figure 3 Function to calculate position and orientation errors between target and actual Program
The error function in this program calculates the difference between the actual position and orientation of the robot and the desired target position and orientation [15]. Mathematically, the error is calculated by: a. Calculating the T04 homogeneous transformation from the actual position and orientation of the robot using the homogeneous transform(pos, r) function. b. Calculate target T's homogeneous transformation of the target's position and orientation using the function homogeneous transform(target pos, target r). c. Calculating the difference in position by subtracting the actual position of the robot (pos) with the target position (target pos) to get error pos. d. Calculates the orientation difference for each x, y, and z axis using the formula: Where i is the axis being calculated (i=1 for the axis x, i=2 for the y-axis, and i=3 for the z-axis). This formula calculates the angular difference between the target axis and the robot's actual axis on the axis being calculated. e. Merge error pos and error r into one error vector using the c() function. f. Returns the error vector as the function result.
By using this error function, the program can perform Newton-Raphson iterations to control the robot's position and orientation so that it approaches the desired target position and orientation.

Function to find inverse kinematic solutions using the Newton-Raphson method
The R-based programs that will be reviewed are as follows: orientation of the end-effector (robot arm) which is controlled by several robot joints [16]. The Newton-Raphson method is used to calculate delta q, which is the change in each joint required to achieve the desired position and orientation. Delta q is calculated by minimizing the error resulting from the difference between the actual position and orientation and the target position and orientation.
The program above performs iterations to calculate delta q and change the position and orientation of the robot's hand along with the changes in each joint. During iteration, the program calculates the Jacobian (matrix of partial derivatives) and positional and rotational errors [17]. Then the program calculates delta q using the equation solve(J) %*% e. Delta q is then used to update the position and orientation of the robot's hand using rodrigues Iterations are carried out until the error reaches the specified tolerance or the maximum iteration is reached.

Discussion
The three-link manipulator is a robotic arm consisting of three links or segments connected by two joints. The position and orientation of the end effector, which is the part of the manipulator that interacts with the environment, are determined by the joint angles of the three links. The homogeneous transformation matrix is used to represent the position and orientation of the end effector in three-dimensional space. It is a 4x4 matrix consisting of a 3x3 rotation matrix R and a 3x1 translation vector pos. The rotation matrix R represents the orientation of the end effector relative to the base frame of the manipulator, while the translation vector pos represents the position of the end effector relative to the base frame. The Euler formula is used to calculate the rotation matrix R in the homogeneous_transform function. The Euler formula relates the rotation matrix to three angles, which are known as the Euler angles. There are different conventions for defining the Euler angles, but the most common convention is the XYZ convention, which specifies that the rotation is performed first around the x-axis, then around the y-axis, and finally around the z-axis. The resulting rotation matrix R is stored in a 4x4 matrix along with the translation vector pos to form the homogeneous transformation matrix. The Jacobian matrix, on the other hand, represents the derivative of the end effector position and orientation with respect to each joint angle. It is a 6x3 matrix consisting of the partial derivatives of the position and orientation of the end effector with respect to each joint angle. The first three rows of the Jacobian matrix represent the partial derivatives of the position of the end effector with respect to each joint angle, while the last three rows represent the partial derivatives of the orientation of the end effector with respect to each joint angle. The jacobian function is used to calculate the Jacobian matrix for the three-link manipulator. The Jacobian matrix is an important tool in robotics because it allows us to analyze the sensitivity of the end effector position and orientation to changes in the joint angles. This information is useful for tasks such as trajectory planning, motion control, and obstacle avoidance.
The research gap in this area may include the need for a more efficient and accurate algorithm for calculating the homogenous transformation matrix and the Jacobian matrix for manipulators with more than three links. Additionally, there may be a need for research on the impact of noise and measurement errors on the accuracy of these calculations. This can be addressed by developing a robust algorithm that can take into account noise and measurement errors while minimizing computational complexity. The applicability of these

CONCLUSSION
This result discusses the function to calculate the homogeneous transformation matrix at a certain position and orientation and the function to calculate the Jacobian at a certain position and orientation from a three-link manipulator. In this study, there were two results produced.
First, the homogeneous transform program is used to calculate a homogeneous transformation matrix that represents the position and orientation of an object in threedimensional space. Second, the jacobian function is used to calculate the Jacobian matrix which represents the relationship between changes in position and orientation of objects with changes in the joint angle of the three-link manipulator. From the results of this study, it can be concluded that the homogeneous transform program and the jacobian function can be used to accurately model the three-link manipulator. Several research gaps that need attention and become suggestions for future research.
First, in the homogeneous transform program, Euler's formula is used to calculate the 3x3 rotation matrix. There are some limitations to using Euler's formula, such as the singularity and multiple singularity problems. Future research can consider using an alternative rotation method that is more stable and effective for calculating the rotation matrix. Second, in the jacobian function, only the geometric jacobian is calculated, while the analytical jacobian is not calculated. As a result, future studies may consider calculating analytical jacobian and its comparison with geometric jacobian to further understand the advantages and disadvantages of each method. Third, this study only models a three-link manipulator with a certain joint angle. Research can consider the development of a more complex and more flexible three-link manipulator model to broaden the scope of manipulator applications. Fourth, this study only focuses on the development of a three-link manipulator mathematical model. Future research can consider the application of the three-link manipulator model that has been developed to the problem of controlling manipulator movements.
In conclusion, this research makes an important contribution in the development of a three-link manipulator mathematical model. However, there are several research gaps that need to be considered and become suggestions for future research to improve the limitations and expand the scope of application of the three-link manipulator model that has been developed.