Using a Neural Network instead of IKM in 2R Planar Robot to follow rectangular path
Subject Areas : Neural Networks
1 - Mechatronics , Mechanical and Electrical Engineering , Tishreen University , Lattakia , Syria
Keywords: Direct Kinematic Model (DKM), Denavit Hartenberg (DH), Neural Network (NN), Inverse Kinematic Model (IKM), Back-Propagation(BP),
Abstract :
Abstract— An educational platform is presented here for the beginner students in the Simulation and Artificial Intelligence sciences. It provides with a start point of building and simulation of the manipulators, especially of 2R planar Robot. It also displays a method to replace the inverse kinematic model (IKM) of the Robot with a simpler one, by using a Multi-Layer Perceptron Neural Network (MLP-NN), to make the end-effector able to track a specific path, which has a rectangular shape (in this article), and allocated in the robot's workspace. The method is based on Back-Propagation Levenberg Marquardt algorithm. This paper also suggests a good strategy for the simulation of the robot's motion in Matlab to tell the beginners how the operation could be done quite closely to the built-in Matlab functions. The control part was ignored here for the simplicity. So we can classify this paper as a manual in the robotic world.
1. Dorsey, N. Top 5 Robotic Systems to Watch in Agriculture. 2018 [cited 2019 19 September ]; Available from: https://www.precisionag.com/in-field-technologies/top-5-robotic-systems-to-watch-in-agriculture/.
2. Bouchard, S. Industrial robots: What are the different types? 2014 [cited 2019 19 September]; Available from: https://blog.robotiq.com/bid/63528/what-are-the-different-types-of-industrial-robots.
3. Household robots. [cited 2019 19 September ]; Available from: http://www.allonrobots.com/household-robots.html.
4. [cited 2019 19 September]; Available from: https://www.youtube.com/watch?v=ZWZGfWU8_p0.
5. Zhao, J., et al., A learning-based multiscale modelling approach to real-time serial manipulator kinematics simulation. Neurocomputing, 2019; Available from: https://www.sciencedirect.com/science/article/abs/pii/S0925231219314456.
6. Kieffer, S., V. Morellas, and M. Donath. Neural network learning of the inverse kinematic relationships for a robot arm. in Proceedings. 1991 IEEE International Conference on Robotics and Automation. 1991. IEEE.
7. Banga, V., Y. Singh, and R. Kumar, Simulation of robotic arm using genetic algorithm & AHP. World Academy of Science, Engineering and Technology, 2007. 25(1): p. 95-101; Available from: https://pdfs.semanticscholar.org/cbef/ee29e571ec3a50637e8de3c6f6ce56d00338.pdf.
8. Hao, W.G., Y.Y. Leck, and L.C. Hun. 6-DOF PC-Based Robotic Arm (PC-ROBOARM) with efficient trajectory planning and speed control. in 2011 4th International Conference on Mechatronics (ICOM). 2011. IEEE.
9. Spong, M.W., S. Hutchinson, and M. Vidyasagar, Robot modeling and control. 2020: John Wiley & Sons.
10. Beale, H.D., H.B. Demuth, and M. Hagan, Neural network design. Pws, Boston, 1996; Available from: https://pdfs.semanticscholar.org/6a81/22861b80842ee6f406acdeec35aec913f1b8.pdf.
4
Journal of Advances in Computer Engineering and Technology
Using a Neural Network instead of IKM in 2R Planar Robot to follow rectangular path
Abstract— An educational platform is presented here for the beginner students in the Simulation and Artificial Intelligence sciences. It provides with a start point of building and simulation of the manipulators, especially of 2R planar Robot. It also displays a method to replace the inverse kinematic model (IKM) of the Robot with a simpler one, by using a Multi-Layer Perceptron Neural Network (MLP-NN), to make the end-effector able to track a specific path, which has a rectangular shape (in this article), and allocated in the robot's workspace. The method is based on Back-Propagation Levenberg Marquardt algorithm. This paper also suggests a good strategy for the simulation of the robot's motion in Matlab to tell the beginners how the operation could be done quite closely to the built-in Matlab functions. The control part was ignored here for the simplicity. So we can classify this paper as a manual in the robotic world.
I. INTRODUCTION
W
ITH the development of the robotic sciences, the importance and exciting of robots have grown up day by day. We can provide them with an Artificial Intelligence techniques to be able to mimic the human's performance in many fields such as industry, agriculture, domestic robots, etc. [2, 1, 3]. They can be a big assistance for the person in his daily life. One common type of those manipulators is 2R planar robot. It has two links (i.e. two degrees of freedom). Actually it is very similar to the human arm, but this robotic arm works only in 2D plane, it can also be used as a plotter machine in some cases [4]. This work splits into two main sections: Simulation, and the Neural Network based solution robot's IKM. The results, and the conclusions of this manual are exited in sections five and six respectively. The seventh section is specified for used figures and tables. In other words this article could be a useful tool especially for the students in mechatronics and robotic departments.
II. related works
In April 1991 , Stuart Kieffer, Vassilios Morellas and Max Donath published their paper : Neural Network Learning of the Inverse Kinematics Relationships for a Robot Arm, in which a Widrow-Hoff based Kohonen's (SOM) neural network is learnt the inverse kinematic model of a 2 DOF robotic arm , and the results show that the suggested approximation is indeed successful [6].
In 2007 Simulation of Robotic Arm using Genetic Algorithm & AHP article suggested a method to reduce the cost of a 3 DOF robotic arm's motion using Genetic Algorithm and Analytical Hierarchy Process by V. K. Banga, Y. Singh, and R. Kumar. This paper simulated and tested the inverse kinematics, fitness value evaluation and binary encoding like tasks . Movement, friction and least settling time (or min. vibration) are used for finding the fitness function / fitness values [7].
Wong Guan Hao, Yap Yee Leck and Lim Chot Hun edited their paper 6-Dof pc-based robotic arm (PC-ROBOARM) with efficient trajectory planning and speed control in 2011 , which introduces the design and development of 6-DOF (degree of freedom) PC-Based Robotic Arm (PC-ROBOARM) . The robotic arm design and control solution is implemented by self-developed computer software which is named as SMART ARM . It allows user to model or design virtual robotic arm before building the real one . Therefore, the user can estimate the optimum size of actual robotic arm at the beginning so as to minimize the building cost and suite the practical environment. Furthermore, once the actual robotic arm has been built, the user can reuse the software to control the actual robotic arm in an effortless way without wasting time in constructing new control solution [8].
A novel learning-based multiscale modelling approach is proposed in [5] to address the efficiency and accuracy issues
through a combination of models with different levels of fidelity. Specifically, low-fidelity models are formulated using the Kernel Ridge Regression (KRR), which has a much lower computational cost compared with kinematic approximation models. Additionally, in order to eliminate position singularity of a serial manipulator, high-fidelity models are based on the Long Short Term Memory (LSTM) neural network are also created to calibrate fidelity by training the significant fidelity samples.
III. SIMULATION OF THE ROBOTIC ARM
1. The Model of The Arm
In this section, the model of the robot is built.
Firstly, we establish the joint coordinates frames. Frame (0) is for the first link and it is allocated exactly at the center of the joint one. Frame (1) is of the second link, and it is centered exactly at the joint two. Frame (2) is centered at the grip joint. According to the right-hand rule we can conclude that Z0, Z1 and Z2 axes are perpendicular on (X0-Y0), (X1-Y1) and (X2-Y2) planes, outside of the paper. So the frames of the robot will be like those in figure (1).
Secondly, We need to fill the DH Parameters Table (Look at table 1), Where:
ai: is the distance between Z i-1 and Z i axes along Xi axes.
αi: is the angle between Z i-1 and Z i axes along X i axes.
di: is the distance between X i-1 and X i axes along Z i-1 axes.
Ѳi: is the angle between X i-1 and X i axes along Zi-1 axes.
Thirdly, we write DH Transformation Matrix:
T ii-1 = Rot z , Ѳi .Trans z , di .Trans x , ai . Rot x , αi [9]2.
(1)
(2)
(3) (4)
(5)
Where:
C1 = Cos(Ѳ1), S2= Sin(Ѳ2), C12 = Cos (Ѳ1+Ѳ2),
S12 = Sin (Ѳ1+Ѳ2).
2. The Direct Kinematic Model of The Robot
DKM is used to calculate the (x-y-z) coordinates of the grip depending on the values of the links angles. From the last column in (5), we obtain:
X = L1.cos(θ1) + L2.cos(θ1+ θ2) (6)
Y = L1.sin(θ1) + L2.sin(θ1+ θ2) (7)
Z = 0 (8)
Those three equations form " Direct Kinematic Model of Two-link planar manipulator (DKM) ".
From (5) , The Rotation Matrix is:
(9)
If Zz ≠ ±1, then
Θ = acos(Zz) (10)
Φ = atan2 (Zx,-Zy) (11)
Ψ = atan2(Xz ,Yz) (12)
Roll – Pitch – Yaw Parameters [9]4:
β = atan2(-Xz,±) (13)
If β ≠ ± π/2, then
α = atan2(Xy ,Xx) (14)
γ = atan2(Yz ,Zz) (15)
3. The Inverse Kinematic Model of The Robot
IKM is used to calculate the links angles depending on the values of (x-y-z) coordinates. From (6) and (7), we can generate Ѳ1 and Ѳ2 equations:
(6)2 + (7)2 =
X2 + Y2 =
So:
(16)
It is a standard formula of a trigonometric equation like this form:
We can solve it as the follow:
(17)
After calculating Ѳ2 values, we replace Ѳ2 in (7):
Y = L2.sin(θ2).cos(θ1) + (l1+L2. cos(θ2)).sin(θ1)
Y = a . cos(θ1) + b . sin(θ1) (18)
We can solve it as the following:
(19)
That was the basic model of the 2R planar robot. It contains DKM in which we know the values of the links' angles and then we conclude the (X-Y-Z) Coordinates of the grip, and there is IKM in which we know the (X-Y-Z) Coordinates and we want to calculate the angles of the two links.
4. Simulation Algorithm
In this section the simulation of the 2R Planar Robot is presented using basic programming instructions. I need to design a function to determine the workspace of the robot. It just takes the lengths of the links (l1 and l2), and it returns two circles where the workspace of the robot is between them. Next there is a function used to calculate the T02 matrix called "total_Tran". Another is called "Tran" which is used to calculate T01 and T12 matrices respectively.
Next, two functions called: "Euler" and "R_P_Y " are designed to calculate Euler and Roll-Pitch-Yaw parameters. From (9) we can note that zz equals to (1). So (Theta = 0 ) and ( Phi = Psi = Nan ) in all cases.
Now it is necessary to show the motion of the robot. Hence I suggest a method to animate this motion Depending on the successive image display (image by image). The animation steps of the link one will be explained reaching to a defined point in the workspace, and the other link uses the same steps. First, the whole rotation angle of the link one is acquired (Ѳ1) in radian, then it is segmented into smaller angles each segment is equaled to (t1) therefore, a step value for the motion should be defined firstly – the step value will be better if it is as possible as small to make the animation process smoother – . At each segment/frame the position of the second joint should be calculated using "Tran" function which has two parameters (the updated frame angle, and the fixed length of the first link), Note that "Tran" function gets the previous angle plus the step (t1) towards the goal point.
This method is good if the arm moves from the origin point to another one counterclockwise, but if we want to move the arm in a clockwise direction, then we should subtract the step (t1) from the previous frame angle. So, for one link there are two cases of motion (CW and CCW ), but there will be four possible cases for two links: (Look at table 2).
The second link animation is done by the same algorithm. It should be mentioned that the number of segments/ frames of the total animation is determined by the maximum integer number of the frames of each link. You can see the animation algorithm box diagram in figure (3) .
In this section the algorithm used to simulate the 2R Planar Robot is designed and explained.
IV. the architecture of the neural network
Now, I will illustrate how to build the neural network used in the application of this article. I suppose the path we want to follow has a rectangular shape. we should mention that the path must be allocated in the workspace of the Robot, else the Robot may face singularity cases. I use a Multi-Layer Perceptron (MLP), and Back Propagation algorithm (BP) to train the network. The main purpose of using the Neural Network in this manual is: controlling of the end effector to follow a specific path without using IKM or even DKM. This thing is important for the Robot controlling process, because of the grip can follow any path regardless of the mathematical formula of that path, it just needs to detect the sample points from the path using some sensors for one time. And the most exciting thing is: anyone can control the grip even if he does not have any mathematical background of trigonometric and mathematical equations, he just should move the end effector on the specific path for the first one, and lets the rest of the operation to the neural network.
Designing steps of the NN are:
1) Choosing of training patterns.
2) Determining the number of Inputs and outputs of the network and Identifying them.
3) Specifying the number of hidden layer neurons.
4) Choosing of the transfer functions used in the NN.
1. Choosing of training patterns
Training samples are some points acquired from the rectangular path. The whole sample points number is equaled to (QW = 148 points), I will separate them into two groups, the first one is called "Training Group" it contains (80.405%) of QW (i.e. QT = 119 points) and the second one is called "Generalization Group", it contains (19.595%) of QW (i.e. QG = 29 points), it is also used to check the NN's ability to generalize. We can select the elements of the Generalized Group and Trained Group like the following: (start from the first element of the Whole Group, then count four elements after it. Put all of the last elements in the Trained Group. Put the fifth element in the Generalized Group. Repeat the same steps until reaching of the final element in the QW).
2. Determining the number of inputs and outputs of the NN and identifying them
Since we want to replace the IKM of the Robot by NN, so the inputs of the network are (X ,Y ,Z) coordinates of the sample points, and the outputs are the rotation angles of both links (Ѳ1, Ѳ2). I will ignore Z coordinates, because it is always equaled to zero. Hence the number of the NN's inputs is two, and the number of the NN's outputs is also two.
3. Specifying the number of hidden layer neurons
Actually it is an experimental issue, depending on trial and error, but there is a constraint should not be exceeded. It is about the Generalization problem which is: "the parameters of the NN should be equal to or even smaller than the training patterns QT" [10]5.
I depend on this rule to limit the hidden layer neurons number. In this article, I use three layers (Input – Hidden – Output) for the NN. The parameters number of the NN is distributed as the follow: In the first layer there are two inputs (i.e. R=2). In the Hidden layer there are S1 neurons and b1 biases (one bias for each neuron). Finally in the output layer there are two neurons (S2 = 2), and also two bias (b2 = 2). The parameters of the NN involves the weights and biases used in the network. The weight matrix between the input and hidden layers has a [S1. R] size. The biases of the hidden layer has a [S1.1] size. The weight matrix between the hidden and output layers has a [S2.S1] size. The biases of the output layer has a [S2.1] size,
Here is the previous constraint mathematical expression :
W1 + b1 + W2 + b2 ≤ QT (20)
[S1.R] + [S1.1] + [S2.S1] + [S2.1] ≤ 119
2.S1 + S1 + 2. S1 + 2 ≤ 119
So : S1 ≤ 23 (21)
I tried multiple scenarios by changing S1 and epoch values, and the results are illustrated in the figure (4) representing the relationship between Ѳ1 and Ѳ2 at the same inputs. The blue color in that figure refers to desired output of the NN, the red one refers to the actual output of the network, and the black one represents the NN response to the generalization group elements.
We can note in figure (4), that all the scenarios have a hidden neurons number less than (23). It is also obvious that the best result from the same figure is (d). which have only one big error.
At the upper left corner of figure (4) we have scenario (a), in which (S1 = 10 neurons, epochs = 1,000). On the right of (a) sub-figure there is the scenario (b), in which (S1 = 10 neurons, epochs = 50,000); (c): (S1 = 10 neurons, epochs = 1,000,000); and so on.
We continue the same method until we reach to an acceptable result. I choose this one: (S1 = 11, and epochs = 50,000).
4. Choosing the transfer functions used in the NN
We can conclude that our problem is a function approximation matter. In figure (4) we have a blue curve presenting one function (the relationship between Ѳ1 and Ѳ2), and we want to make the neural network converge it. Actually, we can converge any function using Back Propagated based Neural Network contains one hidden layer with sigmoid transfer function, and one output layer with linear transfer function, if there are enough neurons in the hidden layer [10]6. So that, the hidden transfer function is sigmoid:
(22)
, And the output transfer function is linear:
(23)
V. the results
To speed up the convergence process I used Levenberg Marquardt method by using "trainlm" function in Matlab with initial value of µ = 0.001, and the last value of µ is 1.00e-07 [10]7. The performance function is Mean Squared Error (the goal error = 0, the actual performance = 1.90e-05), train time = 0:00:01, iterations = 244, Gradient = 0.00221, cost of the NN-based solution of Robot's IKM is 2.047888s. We should tell about one more thing: since the robot displays only one solution in IKM for all cases, so if Ѳ1 is equal or smaller than
(180o), the link (1) will rotate counter clockwise CCS, but if Ѳ1 is bigger than (180o), the link will rotate with clock wise CS. To avoid that reflection especially when the robot follows a continues path, I add (+360o) to the value of Ѳ1 angle if it is more than (180o); (i.e. I use the complementary of Ѳ1 to 3600 when the angle/ rotation is negative).
System setup: (Intel® Core™2 Duo CPU T6500 @ 2.10 GHZ – RAM 4GB – Windows 64 bits), Matlab version: (R2016a).
The training process produced these values for the parameters of the NN:
VI. conclusions
This work is a manual for the students. It shows the IKM solution using a neural network trained by Levenberg Marquardt algorithm. It also suggests a practical method to simulate the motion of the 2R Planar Robot with Programming from scratch. The controlling results of the grip with and without IKM are largely Identical. We saw some acceptable aliasing in NN result in fig. (7), while the IKM result is so straight fig. (5).Using NN instead of IKM makes the following task easier regardless the mathematical formula of the path, or even the student's mathematical background, but it costs more time than IKM (2.047888s for NN vs. 0.676140s for IKM ). The used NN is valid only for the last rectangular path, but if we want to use another path, we should take a new sample points from it, and repeat the same stages to train the NN again.
VII. Figures and tables
Figure (3) shows the final application Graphical User Interface and DKM of the two-link Planar manipulator. You can see the workspace of the Robot between two red circles. We type the values of Ѳ1 and Ѳ2, then the application calculates the X-Y-Z coordinates. You can also note that the application calculates both of Euler and R-P-Y parameters, as expected (Teta = 0) and (Phi = Psi = NaN) in all cases.
Figure (5) shows the grip of the Robot following a rectangular blue path; We can note how accurate the result is. The approximation result of the training process with (S1 = 11 neurons in the hidden layer, and epochs = 50,000) is illustrated in figure (6). We can note that the convergence is acceptable. Figure (7) shows the end effector of the Robot following the same specific rectangular path using the neural network.
(a) (b) (c) (d) (e) (f) (g) (h) (i) Fig . 4. Using trial and error to detect the number of the hidden neurons. [o: training, +: generalization, o: target] patterns.
|
Fig. 6. The Convergence final result (the relationship between Ѳ1 and Ѳ2). * Horizontal axes is Ѳ1, and Vertical axes is Ѳ2.
|
Denavit Hartenberg Parameters
|
POSSIBLE ROTATION DIRECTIONS FOR TWO LINKS
|
VIII. References
[3] http://www.allonrobots.com/household-robots.html, Last accessed on 19 – September – 2019.
[4] https://www.youtube.com/watch?v=ZWZGfWU 8_p0, last accessed on 19 – September – 2019.
[5] Jiaxin Zhao , Hongwei Wang , Wenzheng Liu , Heming Zhang. A learning-based multiscale modelling approach to real-time serial manipulator kinematics simulation, Neurocomputing (2019), doi: https://doi.org/10.1016/j.neucom.2019.04.101
[2] On (p. 56 – 57).
[3] on (pp . 47 – 49).
[4] on (pp . 49 – 50).
[5] on (pp . 378 – 380).
[6] on (pp . 362).
[7] Look at Chapter 12 on (pp . 431 – 439).