Kinematic Analysis for Trajectory Planning of Open-Source 4-DoF Robot Arm

Many small and large industries use robot arms to establish a range of tasks such as picking and placing, and painting in today’s world. However, to complete these tasks, one of the most critical problems is to obtain the desire position of the robot arm’s end-effector. There are two methods for analyzing the robot arm: forward kinematic analysis and inverse kinematic analysis. This study aims to model the forward and inverse kinematic of an open-source 4 degrees of freedom (DoF) articulated robotic arm. A kinematic model is designed and further evaluated all the joint parameters to calculate the endeffector’s desired position. Forward kinematic is simple to design, but as for the inverse kinematic, a closed-form solution is needed. The developed kinematic model’s performance is assessed on a simulated robot arm, and the results were analyzed if the errors were produced within the accepted range. At the end of this study, forward kinematic and inverse kinematic solutions of a 4-DoF articulated robot arm are successfully modeled, which provides the theoretical basis for the subsequent analysis and research of the robot arm. Keywords—Robot arm; kinematic analysis; forward kinematic; inverse kinematic; open-source


I. INTRODUCTION
A robot arm is made up of a movable chain of links that are linked together by joints. A hand or end-effector that can move freely in space is typically connected to one end, which is fixed to the ground. Robot arms are capable of performing repetitive tasks at speeds and precision well above those of human operators. Robot arms are used in various fields requiring high precision, for instance medical, industry, and some hazardous places. However, controlling the robot arm has been challenging with a higher degrees of freedom (DoF). Position analysis and trajectory planning of robot arm is an essential step in design and control.
Robotics research has gotten much traction over the years, thanks to advances in robot technology and the growing use of robotics in various fields. The robotics researchers have been focusing on more current configurations, intelligent actions, autonomous robotics, and high-level intelligence. All of these areas are related to robot kinematic, both forward and inverse. However, there are no excellent universal algorithms for producing the forward and inverse kinematic of a robot arm, especially finding the correlation between both kinematic models. The problem involves an error in achieving an accurate correlation between the forward and the inverse kinematic of a robot arm [1], [2], [3], [4], [5], [6], [7], [8], [9]. To plan an accurate robot arm's movement, we have to understand the relationship between the forward and inverse kinematic of the actuators to control the robot's resulting position in an accurate manner. Hence, there remains a scope to investigate further and work towards finding better solutions.
This study aims to develop a suitable methodology for solving the forward and inverse kinematic problem for a 4-DoF articulated robotic manipulator with relative ease. A kinematic model with an accurate correlation between the forward and inverse kinematics of a 4-DoF articulated robotic manipulator is developed using MATLAB software. The performance of the developed kinematic model is assessed and evaluated in Robot Operating System (ROS) on Ubuntu. The robot arm assessed in this research is the OpenMANIPULATOR-X robot arm manufactured by Robotis, which is an open-source robotic platform.

A. Kinematic Modeling
Kinematic is a branch of mechanics that studies the motion of bodies and structures without taking force into account. Geometry is used to research the movement of multi-DoF kinematic chains that make up the robot arm's structure. The relationship between the robot arm's linkages and its position, orientation, and acceleration is studied in robot kinematics. Kinematic analysis is an effective method when planning the robot arm's trajectory can be divided into two types: forward kinematic and inverse kinematic.
Forward kinematic refers to using the kinematic equations of a robot arm to compute the position of the endeffector's frame and joint variables relationship. Meanwhile, inverse kinematic is the reverse process that calculates the joint parameters that achieve an end-effector's position. The reverse operation, on the other hand, is much more challenging in general. The reverse operation is, in general, much more challenging. Forward kinematic has a simple and straightforward solution if compared with the inverse kinematic solution, which has many equations with a highly complex form to be solved [10].
In robotics, the inverse kinematic approach uses the kinematic equations to find the joint parameters that give each of the robot arm's end-effectors the desired configuration (position and rotation). Motion planning determines the robot arm's movement so that its end-effectors move from an initial configuration to the desired configuration. Inverse kinematic transforms the motion plan into joint actuator trajectories for the robot arm. Forward kinematic measures the chain's configuration using joint parameters, while inverse kinematic reverses this calculation to find the joint parameters that achieve the desired configuration [11].

B. Mechanism of Robot Arm
A robot arm can be either serial configuration with an open-loop structure or parallel configuration with a closedloop structure. The joint type for an industrial robot arm can be revolute or prismatic, and the link type can be rigid or flexible. Furthermore, a hybrid structure comprising both open and closed-loop mechanical chains is possible. The serial robot arm is characterized by the fact that the first joint is always starting from the fixed base and the end of the chain is free to move in space. Several different configurations of the robot arm can be formed due to the revolute and prismatic joints, and the axes of two adjacent joints can be either parallel or orthogonal. Orthogonal joints intersect by 90 • with respect to their common normal, and it can be parallel when one axis rotates 90 • [12]. Some of the robot arm mechanisms arise from open, closed, and hybrid open and closed kinematic chains.
In addition, the DoF can be defined as the particular motion of links related to any mechanism or machine. When performing a specific task, the DoF often plays an important role. The total number of DoF is always equal to the number of independent displacements of links. The number of DoF permitted by a joint and their characteristics can be determined by the design constraints of the body or link.

C. Articulated Robot Arm
The articulated robot arm is a robot arm with revolute joints and is also called a revolute, or anthropomorphic robot arm. The anthropomorphic resembles the human arm's design, including shoulder, elbow, and wrist joints [13]. The articulated robot arm can range from a simple two-joints structure to systems with 10 or more interacting joints [14]. The configuration of a 4-DoF articulated manipulator is shown in Fig. 1.

D. Denavit-Hartenberg (D-H) Convention
In the Denavit-Hartenberg (D-H) convention, the link notation can describe the spatial relationship between two relative joints. The frame that connects with another joint has a relationship to the position and geometry with another joint. Fig. 2 shows that the link parameters are α i and a i , and the joint offset (d i ) is fixed to provide the manipulator configuration. This configuration achieves a specific posture using n of θ i [15]. The posture of every configuration or endeffector can be changed if the value of θ i changes.
Once the link frame has been set, the position and orientation of the i-frame in relation to i − 1 are completely Fig. 2. Definition Parameters of a Robot Arm [15]. defined using four parameters, known as the D-H parameters. The parameters taken are as follows: 1) Joint offset, d i : This parameter is the intersection point's length at the common normal line on the zi joint axis. The measured value is at a distance between x i and x i+1 , which is measured along zi. 2) Joint angle, θ i : This parameter is the angle between the orthogonal projection on the common normal line, x i and x i+1 , and the normal plane to the z i joint axis. The rotation direction is closely related to the parameter value; when the rotation is counterclockwise, it is positive. This parameter is taken at degrees between x i and x i+1 , measured approximately z i . 3) Link length, a i : This parameter is taken at the distance of the common normal to z i and z i+1 , measured along x i+1 . 4) Twist angle, α i : This parameter is the angle between the orthogonal projections on the axis of the joint z i and z i−1 to the normal plane on the common normal line. This value can be obtained from the degree between z i and z i+1 , measured by x i .
A transformation matrix can be obtained based on the D-H parameters, which define the transformation of the i-frame relative to the i − 1 frame. This matrix can be represented as T i−1 i , and can be calculated as, where c and s represent sin and cos, respectively. For n DoF consisting of n + 1 frames, the sum of the numbers for the transformation matrix is n [16]. The concatenated matrix provides the required transformation from the n frame that corresponds to the end-effector to the 0-frame mounted on the base as follows:

E. Closed-Form Solution
A closed-form solution is an expression for an exact solution given with a finite amount of data [17]. If an equation solves a given problem in terms of functions and mathematical operations from a given commonly accepted set, it is said to be a closed-form solution. An infinite sum, for example, will not be considered a closed-form solution. The closed-form solution can be applied in solving the inverse kinematic of the robot arm. The solution obtained has the advantages of being exact, includes all solution sets, and low computational cost.

II. METHODS
Some considerations should be emphasized to ensure the robot arm can maneuver correctly, including its software and hardware. Accordingly, software should be stable and easy to use to prevent difficulties. Furthermore, hardware plays a role in forming a solid robot arm and able to move as planned. The MATLAB software (MathWorks) has been used to develop the algorithm in this study.
The primary hardware utilized in this study is the OpenMANIPULATOR-X robot arm manufactured by Robotis. The OpenMANIPULATOR-X robot arm is made up of pieces from the DYNAMIXEL-X series and 3D printing. The daisy chain method is adopted by DYNAMIXEL, which has a modular design. It enables users to add or remove joints for their own use easily. Fig. 3 shows the structure of the OpenMANIPULATOR-X robot arm [18].  Fig. 4 shows the flowchart of the forward and inverse kinematic analysis. Forward kinematic modeling was performed using the Denavit-Hartenberg (D-H) convention method. For inverse kinematic modeling, the closed-form solution method was used to obtain all sets of possible solutions. Next, correlation analysis between the forward and inverse kinematic was performed to determine whether there are any relationship between both kinematic models. Finally, performance evaluation was carried out using trajectory planning and waypoint tracking algorithm in MATLAB and ROS on Ubuntu.

B. Modeling of Forward Kinematic
The D-H convention method used to model the forward kinematic of the robot arm can be divided into three processes. The first process is the configuration analysis of the robot arm to obtain its D-H parameters. Fig. 5 shows the OpenMANIPULATOR-X robot arm's configuration analysis, while Table I shows the D-H parameters obtained after the configuration analysis is performed.
There is an offset between joint 2 and joint 3 on the robot arm, resulting in an offset angle. The offset angle is identified and considered in D-H parameters. Fig. 6 shows the calculation of the offset angle, θ 0 , between joints 2 and 3.  The second process in the D-H convention involves the calculation of the transformation matrix. After obtaining the value of the D-H parameters, the parameters will be included in the transformation matrix. Since 4 frames or 4 DoF were used, the limit for the linked matrix is T 0 4 . The transformation matrix equations can be formulated as follows: After obtaining values for T 0 1 , T 1 2 , T 2 3 and T 3 4 , the next step is to combine them in a sequence to simplify them.
The final process in the D-H convention is to obtain the position vector for the end-effector. After completing the simplification process, the transformation matrix equation is as follows: where p(p x , p y , p z ) is the position vector of the endeffector while n(n x , n y , n z ), o(o x , o y , o z ) and a(a x , a y , a z ) are orthogonal unit vectors that determine the orientation of the frame for the end-effector. p x , p y , and p z are the values for x, y, and z coordinates of the end-effector.

C. Modeling of Inverse Kinematic
The closed-form solution method involving geometric and algebraic solutions is used to model the robot arm's inverse kinematic. The solution is divided into two processes. The first process is the calculation to get the angle for joint 1. The movement of the robot arm on the x − y surface depends only on the angle of joint 1.
Regarding the x-y surface projection of the robot arm movement, the angle for joint 1, θ 1 can be calculated as follows: Since θ 1 is the rotational angle for the robot arm's base, the angle range is between −180 • and 180 • . The quadrant for θ 1 is identified to determine the sign for each trigonometric ratio in a given quadrant. Table II shows the signs for the trigonometric ratio in each quadrant.
The second process involves calculating the angles for joints 2, 3, and 4 (θ 2 , θ 3 , and θ 4 ). For obtaining the solution for θ 2 , θ 3 , and θ 4 , the 3-dimensional (3D) space which is consisting of the x, y, and z coordinate axes, is simplified to a 2-dimensional (2D) surface. The x and y-axis are merged as a new axis and known as the r-axis, as shown in Fig. 7. The x-coordinate and the y-coordinate for the end-effector are combined as r-coordinate using the Pythagorean equation as follows: (IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 12, No. 6, 2021 p r = p x 2 + p y 2 (13) Fig. 8 shows the projection of the r-z surface for the movement of the robot arm. The r 3 coordinates and the z 3 coordinates can be calculated as follows: The range of the total sum of angles for θ 2 , θ 3 , and θ 4 are between −90 • and 90 • as shown in Fig. 9. θ 2 , θ 3 , and θ 4 can be calculated using the following equations: z 2 = cos θ 2 (a 3 sin θ 3 ) + sin θ 2 (a 2 + a 3 cos θ 3 ) (24) cos θ 2 = (a 2 + a 3 cos θ 3 ) r 2 + (a 3 sin θ 3 ) z 2 r 2 2 + z 2 2 (25) sin θ 2 = (a 2 + a 3 cos θ 3 ) z 2 + (a 3 sin θ 3 ) r 2 r 2 2 + z 2 2 (26) There are two possible configurations for the robot arm, namely "elbow up" and "elbow down". Both configurations are considered in the calculation of θ 2 , θ 3 , and θ 4 .
The angle range for θ 2 , θ 3 , and θ 4 is between −90 • and 90 • , respectively. Based on the configuration of the robot arm in ROS, the angle range for θ 2 becomes 0 • and 180 • and the angle range for θ 3 becomes −180 • and 0 • . The angle limit for each joint in ROS ranges between −90 • and 90 • . Thus, the angle range for θ 2 to be considered in kinematic modeling is between 0 and 90 • , while for θ 3 is between −90 • and 0 • .

D. Trajectory Planning and Waypoint Tracking
The simulation of trajectory planning and waypoint tracking is done using MATLAB software with the help of Robotics System Toolbox, Simulink and Simscape Multibody. Fig. 10 shows the simulation procedure for trajectory planning and waypoint tracking. The first step to be completed is to analyze the data using MATLAB software. This procedure aims to identify and overcome the dependencies of the simulation files. Next, the algorithm includes uploading files related to the robot arm into MATLAB software. After that, the algorithm configures one point or a set of points to be used. The points are obtained from the modeling of the robot arm and incorporated into the algorithm. This step is very important to determine the similarity with the actual robot arm. The next step is to calculate and form a smooth trajectory. This process runs the trajectory process and uses the points configured in the previous step. Trajectory planning is one of the critical processes in robots, where it involves the smooth movement of the end-effector from the initial position to the target position [18]. When an arbitrary endpoint is given, the algorithm computes the optimal feasible path for the robot arm's movement based on the kinematic constraints.
The final process involves performing inverse kinematic of the points found on the robot arm workspace. There are six values in the weight vector. The first three values are for rotational purposes, and the last three values are for transition purposes. Then, the algorithm configures a number greater than the number of points previously configured to ensure the robot arm's smooth movement. After that, it uses a kinematic solver for each end-effector position and uses the previous configuration to make an initial guess. After completing all the processes, the movement of the robot arm is simulated. Fig. 11 shows the flowchart of the forward kinematic modeling algorithm. D-H parameters are included in the developed algorithm to obtain the end-effector's coordinate of the robot arm, and the transformation matrix is calculated to obtain the equations for the end-effector's coordinates. Next, random values of the four joint angles are generated by using the "randi" function. This function is able to generate uniformly distributed random integers from the specified interval. Finally, the end-effector's coordinates are calculated by inserting the random values for the four joint angles into the transformation matrix equations. Table III shows the results of the forward kinematic modeling developed.   Fig. 12 shows the flowchart of the inverse kinematic modeling algorithm. The coordinates of the end-effector are entered into the algorithm to obtain the joint angles that achieve a particular end-effector position. Next, the angle value for joint 1 is calculated, followed by calculating the angle values for joints 2, 3, and 4. Finally, all solution sets for the joint angles are obtained.  Table IV shows the set of solutions for joint angles in integers obtained using MATLAB software. Referring to case 1 from the results of the forward kinematic modeling in Table V  To obtain more accurate angles with more decimal points, the number of solution sets increases. The number of solution sets increases by about 10 times with the increase of one decimal point for the joint angles, as shown in Table V.

C. Correlation Analysis of Kinematic Modeling
Referring to the forward and inverse kinematic modeling results, as shown in Tables III and V, the solution is precisely the same when comparing the joint angles from the forward and inverse kinematic. The same solution set of joint angles could be obtained using the inverse kinematic model, as applied in the forward kinematic model. Thus, the correlation between the developed forward and inverse kinematic model is said to be accurate.  Table VI depicts the comparison of the endeffector's coordinates obtained from the modeling process in MATLAB and output from ROS. The most significant errors occurred in case 1 and case 5. Errors occur between the endeffector's coordinates obtained from the results of modeling and output from ROS due to the rounding calculations that unavoidable in modeling and the kinematic constraints on the simulated robot arm in ROS as follows:

1) Joint Bounds:
This constraint is satisfied if the robot configuration vector maintains all joint positions within the bounds specified.

2) Cartesian bounds:
This constraint is satisfied if the end-effector origin's position relative to the target frame remains within the bounds specified.

3) Orientation target:
This constraint requires the end-effector orientation to match a target orientation within an angular tolerance in any direction. The target orientation is specified relative to the body frame of the reference body.

4) Pose target:
This constraint requires the end-effector's pose to match a target pose within a distance and angular tolerance in any direction. The target pose is specified relative to the body frame of the reference body.

5) Position target:
This constraint requires the end-effector position to match a target position within a distance tolerance in any direction. The target position is specified relative to the body frame of the reference body.

IV. CONCLUSION
This study successfully modeled both the forward and inverse kinematic model for the 4-DoF articulated robot arm. Correlation between the forward and inverse kinematic model is analyzed, and the performance of the kinematic model is evaluated on the simulated robot arm. The developed kinematic model serves as a theoretical framework for further research, for instance robot arm trajectory planning, and structural optimization of robot design.