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/26 20:59] – ntorresreyes | 2_link_kinematics [2018/09/27 01:12] (current) – [Graphical Simulation] ntorresreyes | ||
---|---|---|---|
Line 184: | Line 184: | ||
{{: | {{: | ||
\\ | \\ | ||
- | ==== Analytical Solution ==== | + | ==== Analytical Solution |
+ | \\ | ||
+ | {{: | ||
+ | \\ | ||
+ | \\ | ||
+ | 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 ==== | ||
- | |||
\\ | \\ | ||
- | ---- | + | \\ |
+ | 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; | + | 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 = atan2(yPos,xPos) - atan2((L2*sin(theta2)),(L1 + L2*cos(theta2))); | ||
+ | |||
+ | JointAngles = [theta1 theta2] %joint angle vector | ||
</ | </ | ||
- | ---- | + | |
- | The code above in Matlab creates a planar 2-link robotic arm class with arbitrary link lengths. From this, many functions can be used to do simulations | + | 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. |
+ | \\ | ||
+ | \\ | ||
+ | As a sanity check, we can go back to the forward kinematics and apply the necessary transformations | ||
+ | \\ | ||
\\ | \\ | ||
- | ---- | ||
< | < | ||
- | T = transl(1,0,0) | + | >> |
- | T = | + | |
- | | + | 0 0 1 0;... |
- | | + | 0 0 0 1]; |
- | | + | >>Trans1 |
- | | + | 0 1 0 0;... |
- | >> | + | 0 0 1 0;... |
- | q = | + | 0 0 0 1]; |
- | | + | >>Rotz2 = [cos(theta2) -sin(theta2) 0 0;... |
- | >> | + | |
- | + | 0 0 1 0;... | |
- | p = | + | 0 0 0 1]; |
- | | + | >> |
- | -0.8660 | + | 0 1 0 0;... |
- | | + | |
- | | + | |
- | </ | + | |
+ | >>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. | ||
\\ | \\ | ||
- | ---- | ||
- | The ' | ||
\\ | \\ | ||
+ | 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.1538020767.txt.gz · Last modified: 2018/09/26 20:59 by ntorresreyes