Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 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. T01n=double(subs(T01,{d1,a1,al1},{500,200,pi/2}))
  45. T02n=double(subs(T02,{d1,a1,al1,th2,a2},{500,200,pi/2,0,500}))
  46. T03n=double(subs(T03,{d1,a1,al1,th2,a2,d3},{500,200,pi/2,0,500,500}))
  47. T04n=double(subs(T04,{d1,a1,al1,th2,a2,d3,th4,a4,al4},{500,200,pi/2,0,500,500,0,500,-pi/2}))
  48. T05n=double(subs(T05,{d1,a1,al1,th2,a2,d3,th4,a4,al4,th5,a5},{500,200,pi/2,0,500,500,0,500,-pi/2,0,500}))
  49. K=[0 0 0 1];
  50.  
  51.  
  52. %%
  53. for i=(1:50:499)
  54.  
  55. d11=(1:1:1+i);
  56. d33=(1:1:1+i);
  57. th22=(0:-0.002093333:-i*0.002093333);
  58. th44=(0:0.00157:i*0.00157);
  59. th55=(0:0.002093333:i*0.002093333);
  60.  
  61. T01n=double(subs(T01,{d1,a1,al1},{d11(1,i),200,pi/2}))
  62. T02n=double(subs(T02,{d1,a1,al1,th2,a2},{d11(1,i),200,pi/2,th22(1,i),500}))
  63. T03n=double(subs(T03,{d1,a1,al1,th2,a2,d3},{d11(1,i),200,pi/2,th22(1,i),500,d33(1,i)}))
  64. T04n=double(subs(T04,{d1,a1,al1,th2,a2,d3,th4,a4,al4},{d11(1,i),200,pi/2,th22(1,i),500,d33(1,i),th44(1,i),500,-pi/2}))
  65. T05n=double(subs(T05,{d1,a1,al1,th2,a2,d3,th4,a4,al4,th5,a5},{d11(1,i),200,pi/2,th22(1,i),500,d33(1,i),th44(1,i),500,-pi/2,th55(1,i),500}))
  66. K=[0 0 0 1];
  67.  
  68. T01c=T01n.*K
  69. T02c=T02n.*K
  70. T03c=T03n.*K
  71. T04c=T04n.*K
  72. T05c=T05n.*K
  73. figure(1)
  74. grid on
  75. title('Manipulator')
  76. xlabel('X-axis')
  77. ylabel('Y-axis')
  78. zlabel('Z-axis')
  79. text(double(T04c(1,4)),double(T04c(2,4)),double(T04c(3,4)),'')
  80.  
  81. 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))])
  82. hold on
  83. 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))])
  84. hold on
  85. 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))])
  86. hold on
  87. 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))])
  88. hold on
  89.  
  90. plot3(double(T01c(1,4)),double(T01c(2,4)),double(T01c(3,4)),'-o')
  91.  
  92. plot3(double(T02c(1,4)),double(T02c(2,4)),double(T02c(3,4)),'-o')
  93.  
  94. plot3(double(T03c(1,4)),double(T03c(2,4)),double(T03c(3,4)),'-o')
  95.  
  96. plot3(double(T04c(1,4)),double(T04c(2,4)),double(T04c(3,4)),'-o')
  97.  
  98. plot3(double(T05c(1,4)),double(T05c(2,4)),double(T05c(3,4)),'-d')
  99. hold off
  100. axis([-2000 2000 -2000 2000 -2000 2000])
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement