Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. % this script determines a Homogeneous Transformation HT matrix
  2. clear all
  3. % declaration of symbols
  4. syms d1 a1 a2 th2 d3 q1 q2 q3 th4 a4 a5 al1 al4 q4 q5 th5 a3
  5. % determination of a symbolic form of HT matrices –
  6. % application of mA function
  7. A1=mA(0,d1,a1,al1);
  8. A2=mA(th2,0,a2,0);
  9. A3=mA(0,d3,0,0);
  10. A4=mA(th4,0,a4,al4);
  11. A5=mA(th5,0,a5,0);
  12. % multiplication of matrices
  13. T01=A1;
  14. T02=A1*A2;;
  15. T03=A1*A2*A3;
  16. T04=A1*A2*A3*A4;
  17. T35=A4*A5;
  18. T05=A1*A2*A3*A4*A5;
  19. % substitution of rotational joint variables
  20. % for the simplification purpose
  21. T01v=subs(T02,{al1},{q1});
  22. T02v=subs(T02,{th2},{q2});
  23. T03v=subs(T03,{al1,th2},{q1,q2});
  24. T04v=subs(T04,{al1,th2,th4,al4},{q1,q2,q3,q4})
  25. T35v=subs(T35,{th4,th5},{q4,q5});
  26. T05v=subs(T05,{al1,th2,th4,al4,th5},{q1,q2,q3,q4,q5});
  27. % indication of joint coordinates
  28. % variables: d1,th2,a3,th4 and al5 indicated by ‘1’s
  29. zmie1=[[0,1,0,0]];
  30. zmie2=[[0,1,0,0];[1,0,0,0]];
  31. zmie3=[[0,1,0,0];[1,0,0,0];[0,1,0,0]];
  32. zmie4=[[0,1,0,0];[1,0,0,0];[0,1,0,0];[1,0,0,0]];
  33. zmie5=[[0,1,0,0];[1,0,0,0];[0,1,0,0];[1,0,0,0];[1,0,0,0]];
  34. zmie6=[[1,0,0,0];[1,0,0,0]];
  35. % a simplified form of the evaluated HT matrices
  36. % for interpretation purpose for a user
  37. T01u=zam(zmie1,T01v,'q');
  38. T02u=zam(zmie2,T02v,'q');
  39. T03u=zam(zmie3,T03v,'q');
  40. T04u=zam(zmie4,T04v,'q');
  41. T05u=zam(zmie5,T05v,'q');
  42. T35u=zam(zmie6,T35v,'q');
  43. % numerical matrices
  44. syms d1_V th2_V d3_V th4_V th5_V
  45. %variables
  46. d1_V = 500;
  47. th2_V = -pi/3;
  48. d3_V = 500;
  49. th4_V = pi/4;
  50. th5_V = pi/3;
  51. T01n=double(subs(T01,{d1,a1,al1},{d1_V,500,pi/2}));
  52. T02n=double(subs(T02,{d1,a1,al1,th2,a2},{d1_V,500,pi/2,th2_V,500}));
  53. T03n=double(subs(T03,{d1,a1,al1,th2,a2,d3},{d1_V,500,pi/2,th2_V,500,d3_V}));
  54. T04n=double(subs(T04,{d1,a1,al1,th2,a2,d3,th4,a4,al4},{d1_V,500,pi/2,th2_V,500,d3_V,th4_V,500,-pi/2}));
  55. T05n=double(subs(T05,{d1,a1,al1,th2,a2,d3,th4,a4,al4,th5,a5},{d1_V,500,pi/2,th2_V,500,d3_V,th4_V,500,-pi/2,th5_V,500}));
  56. K=[0 0 0 1];
  57.  
  58. T01c=T01n.*K;
  59. T02c=T02n.*K;
  60. T03c=T03n.*K;
  61. T04c=T04n.*K;
  62. T05c=T05n.*K;
  63. figure(1)
  64. grid on
  65. title('Manipulator')
  66. xlabel('X-axis')
  67. ylabel('Y-axis')
  68. zlabel('Z-axis')
  69. text(double(T01c(1,4)),double(T01c(2,4)),double(T01c(3,4)),'Origin')
  70. text(double(T04c(1,4)),double(T04c(2,4)),double(T04c(3,4)),'')
  71.  
  72. plot3([500 double(T01c(1,4))], [0 double(T01c(2,4))], [0 double(T01c(3,4))])
  73. hold on
  74. plot3([double(T01c(1,4)) double(T02c(1,4))],[double(T01c(2,4)) double(T02c(2,4))],[double(T01c(3,4)) double(T02c(3,4))])
  75. hold on
  76. plot3([double(T02c(1,4)) double(T03c(1,4))],[double(T02c(2,4)) double(T03c(2,4))],[double(T02c(3,4)) double(T03c(3,4))])
  77. hold on
  78. plot3([double(T03c(1,4)) double(T04c(1,4))],[double(T03c(2,4)) double(T04c(2,4))],[double(T03c(3,4)) double(T04c(3,4))])
  79. hold on
  80. plot3([double(T04c(1,4)) double(T05c(1,4))],[double(T04c(2,4)) double(T05c(2,4))],[double(T04c(3,4)) double(T05c(3,4))])
  81.  
  82. plot3(500, 0, 0,'-x')
  83. plot3(double(T01c(1,4)),double(T01c(2,4)),double(T01c(3,4)),'-o')
  84. plot3(double(T02c(1,4)),double(T02c(2,4)),double(T02c(3,4)),'-o')
  85. plot3(double(T03c(1,4)),double(T03c(2,4)),double(T03c(3,4)),'-o')
  86. plot3(double(T04c(1,4)),double(T04c(2,4)),double(T04c(3,4)),'-o')
  87. plot3(double(T05c(1,4)),double(T05c(2,4)),double(T05c(3,4)),'-d')
  88. axis([0 2000 -1000 1000 -1000 1000])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement