2_link_kinematics
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
2_link_kinematics [2018/09/23 10:45] – [2-Link Kinematics of Planar Robotic Arm] ntorresreyes | 2_link_kinematics [2018/09/27 01:12] (current) – [Graphical Simulation] ntorresreyes | ||
---|---|---|---|
Line 29: | Line 29: | ||
\\ | \\ | ||
The rest of this tutorial is presented as follows: | The rest of this tutorial is presented as follows: | ||
- | * Homogeneous Transformations | ||
* Background And Theory | * Background And Theory | ||
* Analytical Solution | * Analytical Solution | ||
Line 70: | Line 69: | ||
\\ | \\ | ||
{{: | {{: | ||
+ | \\ | ||
+ | \\ | ||
+ | Next, the translation matrix can be multiplied by the rotation matrix to obtain the complete homogeneous transformation matrix: | ||
+ | \\ | ||
+ | \\ | ||
+ | {{: | ||
+ | \\ | ||
+ | \\ | ||
+ | To obtain the coordinates for a given point **p** in frame B relative to frame A, the transformation matrix is multiplied by the vector of **p** in frame B. For example, in Matlab: | ||
+ | \\ | ||
+ | \\ | ||
+ | < | ||
+ | theta = 30*(pi/ | ||
+ | Px = 2; Py = 3; | ||
+ | PframeB = [1; 4; 1]; | ||
+ | T = [cos(theta) -sin(theta) Px; ... | ||
+ | | ||
+ | 0 0 1]; | ||
+ | |||
+ | PframeA = T*PframeB | ||
+ | |||
+ | PframeA = | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | \\ | ||
+ | \\ | ||
+ | In the above example, frame B is translated in the (x,y) direction of frame A by (2,3) and rotated counter-clockwise by 30 degrees along the z-axis. The **p** vector in frame B has coordinates (1, 4) and the same vector in frame A has coordinates (0.8660, 6.9641). | ||
+ | \\ | ||
+ | \\ | ||
+ | To perform a combinations of rotations, translations, | ||
+ | \\ | ||
+ | \\ | ||
+ | If the transformation is about the new reference frame, then it is post-multiplied. If the transformation is about the old reference frame, then it is pre-multiplied. | ||
+ | \\ | ||
+ | \\ | ||
+ | For 3D rotations and translations, | ||
+ | \\ | ||
+ | \\ | ||
+ | {{: | ||
\\ | \\ | ||
\\ | \\ | ||
Line 75: | Line 115: | ||
\\ | \\ | ||
\\ | \\ | ||
- | {{: | + | {{: |
\\ | \\ | ||
The image above shows a diagram of the 2-link robotic arm that will be used in this example. | The image above shows a diagram of the 2-link robotic arm that will be used in this example. | ||
- | The forward kinematics are used to calculate the joint angles. This is done using planar transformations to go from the origin plane to the end-effector plane using the equation below. | ||
- | {{: | ||
\\ | \\ | ||
- | Each matrix " | + | \\ |
+ | The forward kinematics are used to calculate the joint angles. This is done using planar transformations to go from the origin plane to the end-effector plane. This can be done with arbitrary translations and rotations, but a more practical approach is to use the Denavit-Hartenberg parameters. | ||
+ | \\ | ||
+ | \\ | ||
+ | Each relative transformation can be described by a matrix **A**: | ||
+ | \\ | ||
+ | \\ | ||
+ | < | ||
+ | \\ | ||
+ | \\ | ||
+ | Using Matlab, the relative transformation **A** can be calculated easily using symbolic variables (can also be done by hand): | ||
+ | \\ | ||
+ | \\ | ||
+ | < | ||
+ | >> | ||
+ | >> | ||
+ | sin(theta) | ||
+ | 0 0 1 0;... | ||
+ | 0 0 0 1]; | ||
+ | >> | ||
+ | 0 1 0 0;... | ||
+ | 0 0 1 d;... | ||
+ | 0 0 0 1]; | ||
+ | >> | ||
+ | 0 1 0 0;... | ||
+ | 0 0 1 0;... | ||
+ | 0 0 0 1]; | ||
+ | >> | ||
+ | 0 cos(alpha) -sin(alpha) 0;... | ||
+ | 0 sin(alpha) cos(alpha) 0;... | ||
+ | 0 0 0 1]; | ||
+ | >> A = Rotz*Trans_d*Trans_a*Rotx | ||
+ | |||
+ | A = | ||
+ | |||
+ | [ cos(theta), -cos(alpha)*sin(theta), | ||
+ | [ sin(theta), | ||
+ | [ 0, | ||
+ | [ 0, 0, 0, 1] | ||
+ | |||
+ | </ | ||
+ | \\ | ||
+ | \\ | ||
+ | Once each **A** matrix is obtained, the complete transformation **T** from frame {0} to frame {N} can be found through: | ||
+ | \\ | ||
+ | \\ | ||
+ | < | ||
\\ | \\ | ||
\\ | \\ | ||
Line 87: | Line 171: | ||
\\ | \\ | ||
\\ | \\ | ||
- | The DH-parameters (theta_j, d_j, a_j, alpha_j) are obtained from a set of rules that can be easily referenced online. \\ | + | The DH-parameters (theta_j, d_j, a_j, alpha_j) are obtained from a set of rules that can be easily referenced |
- | *The first parameter, the joint angle, is labeled on the diagram and is the angle from the previous x-axis to the new x-axis about the old z-axis. | + | \\ |
+ | *The first parameter, the Joint Angle, is labeled on the diagram and is the angle from the previous x-axis to the new x-axis about the old z-axis. | ||
\\ *The Link Offset is the distance from the origin of the previous frame of reference to the new x-axis along the old z-axis. | \\ *The Link Offset is the distance from the origin of the previous frame of reference to the new x-axis along the old z-axis. | ||
\\ *The link length is the distance between the old z-axis and the new z-axis along the new x-axis. | \\ *The link length is the distance between the old z-axis and the new z-axis along the new x-axis. | ||
Line 95: | Line 180: | ||
{{: | {{: | ||
\\ | \\ | ||
- | The parameters obtained can be substituted into the "A" matrix below for each transformation (with j = 1,2): | + | The parameters obtained can be substituted into the **A** that we calculated earlier |
\\ | \\ | ||
{{: | {{: | ||
\\ | \\ | ||
+ | ==== Analytical Solution - Geometric ==== | ||
+ | \\ | ||
+ | {{: | ||
+ | \\ | ||
+ | \\ | ||
+ | First, a triangle can be made from the two link arm with the above parameters specified. | ||
+ | \\ | ||
+ | \\ | ||
+ | Recalling the cosine rule, A< | ||
+ | \\ | ||
+ | \\ | ||
+ | {{: | ||
+ | \\ | ||
+ | \\ | ||
+ | {{: | ||
+ | \\ | ||
+ | \\ | ||
+ | From the above equation and diagram, we can gather that: | ||
+ | \\ | ||
+ | \\ | ||
+ | {{: | ||
+ | \\ | ||
+ | \\ | ||
+ | Finally, we have an analytical solution for each joint angle: | ||
+ | \\ | ||
+ | \\ | ||
+ | {{: | ||
==== Numerical Simulation - MatLab ==== | ==== Numerical Simulation - MatLab ==== | ||
- | |||
\\ | \\ | ||
- | ---- | + | \\ |
- | clear; clc; format compact; | + | The following code uses the equations obtained in the analytical solution to calculate the joint angles for the 2-link mechanism. |
+ | \\ | ||
+ | \\ | ||
+ | < | ||
+ | clear; clc; format compact; | ||
- | L1 = 1; \\ | + | L1 = 2; %link 1 length |
- | L2 = 1; | + | L2 = 3; %link 2 length |
+ | xPos = 2; %x position of end-effector | ||
+ | yPos = 1; %y position of end-effector | ||
- | L(1) = Link([0 0 L1 0]); \\ | + | P = [xPos yPos]; %end-effector position vector |
- | L(2) = Link([0 0 L2 0]); | + | |
- | TwoLink_arm | + | theta2 |
- | ---- | + | theta1 |
- | The code above in Matlab creates a planar | + | |
- | \\ | + | |
- | ---- | + | |
- | T = transl(1,0,0) \\ | + | |
- | T = | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | >> q = TwoLink_arm.ikine(T,' | + | |
- | q = | + | |
- | 1.0472 | + | |
- | >> p = TwoLink_arm.fkine(q) \\ | + | |
- | p = | + | JointAngles |
- | | + | </ |
- | | + | |
- | | + | |
- | | + | |
+ | In this case, the joint angles obtained for the first and second links are -1.1071 and 2.3005 radians respectively (or -63.4 and 131.8 degrees). The benefits of the analytical solution are rapid calculation times and precise answers. | ||
\\ | \\ | ||
- | ---- | ||
- | The ' | ||
\\ | \\ | ||
+ | As a sanity check, we can go back to the forward kinematics and apply the necessary transformations to calculate the position of the end-effector based on the joint angles obtained. For the above example: | ||
\\ | \\ | ||
- | {{: | + | \\ |
+ | < | ||
+ | >> | ||
+ | sin(theta1) | ||
+ | 0 0 1 0;... | ||
+ | 0 0 0 1]; | ||
+ | >> | ||
+ | 0 1 0 0;... | ||
+ | 0 0 1 0;... | ||
+ | 0 0 0 1]; | ||
+ | >> | ||
+ | sin(theta2) | ||
+ | 0 0 1 0;... | ||
+ | 0 0 0 1]; | ||
+ | >> | ||
+ | 0 1 0 0;... | ||
+ | 0 0 1 0;... | ||
+ | 0 0 0 1]; | ||
+ | |||
+ | >>T = Rotz1*Trans1*Rotz2*Trans2 | ||
+ | T = | ||
+ | 0.3685 | ||
+ | 0.9296 | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | The final transformation vector shows that the coordinates of the end of the 2nd link are indeed (2,1), which is what we wanted. | ||
+ | \\ | ||
+ | \\ | ||
+ | We can also use the forward kinematics to plot a simple graph that shows the 2-link arm positions. With the following code the intermediate and final transformation matrices can be obtained. | ||
+ | \\ | ||
+ | \\ | ||
+ | < | ||
+ | >> T_01 = Rotz1*Trans1 | ||
+ | T_01 = | ||
+ | 0.4472 | ||
+ | | ||
+ | | ||
+ | | ||
+ | >> T_02 = T_01*Rotz2*Trans2 | ||
+ | T_02 = | ||
+ | 0.3685 | ||
+ | 0.9296 | ||
+ | | ||
+ | | ||
+ | >> P = [0; | ||
+ | >> P1 = T_01*P; P2 = T_02*P; | ||
+ | >> plot([0 P1(1) P2(1)],[0 P1(2) P2(2)]); grid on; | ||
+ | </ | ||
+ | The resulting plot will look like the following: | ||
+ | \\ | ||
+ | \\ | ||
+ | {{: | ||
==== Graphical Simulation ==== | ==== Graphical Simulation ==== | ||
\\ | \\ | ||
- | TBA | + | Matlab can be used to produce a graphical simulation of the 2-link arm mechanism for a given angle. Many of these simulations are based on the [[http:// |
+ | \\ | ||
+ | \\ | ||
+ | The following code can be used to model a planar 2-link arm. Many of the functions behind the arm use the same theory and math covered previously in the tutorial. | ||
+ | \\ | ||
+ | \\ | ||
+ | < | ||
+ | >> | ||
+ | >> | ||
+ | </ | ||
+ | Which results in the following image: | ||
+ | \\ | ||
+ | \\ | ||
+ | {{: | ||
+ | \\ | ||
+ | \\ | ||
+ | Next, a translation can be made and inverse kinematics applied: | ||
+ | \\ | ||
+ | \\ | ||
+ | < | ||
+ | >> T = transl(1.5, | ||
+ | T = | ||
+ | 1.0000 | ||
+ | | ||
+ | | ||
+ | | ||
+ | >> q = p2.ikine(T,' | ||
+ | q = | ||
+ | | ||
+ | >> p2.plot(q) | ||
+ | </ | ||
+ | Which will plot the arm with the joint angles that will result in the end-effector having a position of (1.5, 0.5) | ||
+ | \\ | ||
+ | \\ | ||
+ | {{: | ||
+ | \\ | ||
\\ | \\ | ||
+ | By changing the T matrix with different values of transl(x, | ||
==== Final Words ==== | ==== Final Words ==== | ||
\\ | \\ | ||
- | TBA | + | Hopefully, the information presented in this tutorial is enough for the reader to gain a good understanding of the background, theory, and practical knowledge required to apply this to a 2-link planar robot arm and possibly a 3-link planar arm. |
\\ | \\ | ||
\\ | \\ |
2_link_kinematics.1537724735.txt.gz · Last modified: 2018/09/23 10:45 by ntorresreyes