当前位置:   article > 正文

六自由度机械臂正向运动学与姿态绘制with matlab

六自由度机械臂正向运动学与姿态绘制with matlab

        如果不依赖机器人工具箱,希望自己通过作图显示机械臂某一时刻的工作姿态怎么来实现呢。首先我们知道原理是通过姿态的旋转变换以及平移变换来实现末端坐标的计算。计算完成后的将关节点连接起来便构成了机械臂在某一时刻的姿态位置。更进一步,可以通过旋转变换做出末端的坐标以方便分析。具体实现方式:


Code/matlab:

  1. function MyCoordinateComputeDrawing
  2. %工具:Matrix Compute
  3. %时间:2019/2/12
  4. %更新:easy_R
  5. %核算:compare with RobotToolBox
  6. %%
  7. %parameters of coordinate
  8. clear all;
  9. clc;
  10. d1=0.25; d4=0.25; %base and toolpoint transplante
  11. a2=0.21; a3=0.165; a4=0.21;
  12. alpha2=pi/2; alpha6=pi/2;
  13. %%
  14. %MDH Table of RobotToolBox
  15. %********************************************************
  16. % θ d a α offset
  17. % L(1)=Link([0 0 0 0 0 ],'modified');
  18. % L(2)=Link([0 0 0 alpha2 0 ],'modified');
  19. % L(3)=Link([0 0 a2 0 0 ],'modified');
  20. % L(4)=Link([0 0 a3 0 0 ],'modified');
  21. % L(5)=Link([0 0 a4 0 0 ],'modified');
  22. % L(6)=Link([0 0 0 alpha6 0 ],'modified');
  23. %%********************************************************
  24. %%
  25. %compute the TransformMatrix
  26. % syms theta1 theta2 theta3 theta4 theta5 theta6 real
  27. % q={theta1,theta2,theta3,theta4,theta5,theta6};
  28. theta1=0; theta2=pi/3; theta3=-pi/3; theta4=-pi/3; theta5=pi/3; theta6=0;
  29. T10=[ cos(theta1), -sin(theta1), 0, 0;
  30. sin(theta1)*cos(0),cos(theta1)*cos(0),-sin(0),-sin(0)*0;
  31. sin(theta1)*sin(0),cos(theta1)*sin(0), cos(0), cos(0)*0;
  32. 0, 0, 0, 1
  33. ];
  34. T21=[ cos(theta2), -sin(theta2), 0, 0;
  35. sin(theta2)*cos(pi/2),cos(theta2)*cos(pi/2),-sin(pi/2),-sin(pi/2)*0;
  36. sin(theta2)*sin(pi/2),cos(theta2)*sin(pi/2), cos(pi/2), cos(pi/2)*0;
  37. 0, 0, 0, 1
  38. ];
  39. T32=[ cos(theta3), -sin(theta3), 0, a2;
  40. sin(theta3)*cos(0),cos(theta3)*cos(0),-sin(0),-sin(0)*0;
  41. sin(theta3)*sin(0),cos(theta3)*sin(0), cos(0), cos(0)*0;
  42. 0, 0, 0, 1
  43. ];
  44. T43=[ cos(theta4), -sin(theta4), 0, a3;
  45. sin(theta4)*cos(0),cos(theta4)*cos(0),-sin(0),-sin(0)*0;
  46. sin(theta4)*sin(0),cos(theta4)*sin(0), cos(0), cos(0)*0;
  47. 0, 0, 0, 1
  48. ];
  49. T54=[ cos(theta5), -sin(theta5), 0, a4;
  50. sin(theta5)*cos(0),cos(theta5)*cos(0),-sin(0),-sin(0)*0;
  51. sin(theta5)*sin(0),cos(theta5)*sin(0), cos(0), cos(0)*0;
  52. 0, 0, 0, 1
  53. ];
  54. T65=[ cos(theta6), -sin(theta6), 0, 0;
  55. sin(theta6)*cos(pi/2),cos(theta6)*cos(pi/2),-sin(pi/2),-sin(pi/2)*0;
  56. sin(theta6)*sin(pi/2),cos(theta6)*sin(pi/2), cos(pi/2), cos(pi/2)*0;
  57. 0, 0, 0, 1
  58. ];
  59. %%
  60. %Matrix compute
  61. % Tb=[1,0,0,0;0,1,0,0;0,0,1,d1;0,0,0,1]; %respect to basement transform matrix
  62. % T10=Tb*T10;
  63. T20=T10*T21;T30=T20*T32;T40=T30*T43;T50=T40*T54;
  64. T10;
  65. T20;
  66. T30;
  67. T40;
  68. T50;
  69. T60=T50*T65;
  70. %%
  71. %number compute
  72. % qz={0,0,0,0,0,0}; %ready state
  73. % T6=vpa(subs(T60,q,qz),3) %compute simplify
  74. disp('output transform matrix of the endpoint respect to basement T6:')
  75. T60
  76. % qu={0 pi/3 -pi/3 -pi/3 pi/3 0};%standup state
  77. % T6=vpa(subs(T60,q,qz),3)
  78. %%
  79. %draw the posture of robot
  80. x = [T10(1,4) T20(1,4) T30(1,4) T40(1,4) T50(1,4) T60(1,4)];
  81. y = [T10(2,4) T20(2,4) T30(2,4) T40(2,4) T50(2,4) T60(2,4)];
  82. z = [T10(3,4) T20(3,4) T30(3,4) T40(3,4) T50(3,4) T60(3,4)];
  83. %draw the toolpoint coordinate
  84. px=T60*[0.05;0;0;1]; py=T60*[0;0.05;0;1]; pz=T60*[0;0;0.05;1]; %'50'is properties of coordinate
  85. px1=[T60(1,4),px(1,1)];py1=[T60(2,4),px(2,1)];pz1=[T60(3,4),px(3,1)];
  86. px2=[T60(1,4),py(1,1)];py2=[T60(2,4),py(2,1)];pz2=[T60(3,4),py(3,1)];
  87. px3=[T60(1,4),pz(1,1)];py3=[T60(2,4),pz(2,1)];pz3=[T60(3,4),pz(3,1)];
  88. %%
  89. %drawing figures
  90. plot3(x,y,z,'o','linewidth',8);
  91. hold on
  92. %set coordinate
  93. plot3(px1,py1,pz1,'r','LineWidth',3)
  94. hold on
  95. plot3(px2,py2,pz2,'g','LineWidth',3)
  96. hold on
  97. plot3(px3,py3,pz3,'b','LineWidth',3)
  98. title("Forward Kinematics")
  99. xlabel("x(m)")
  100. ylabel("y(m)")
  101. zlabel("z(m)")
  102. plot3(x,y,z, 'y','Linewidth',5);
  103. grid on;
  104. %%
  105. end

运行结果并运用RTB核算:

其中,第一部分为RTB计算结果,第二部分为计算结果。

计算及核算结果

在此刻机械臂的姿态显示:

机械臂此刻姿态

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Guff_9hys/article/detail/993317
推荐阅读
相关标签
  

闽ICP备14008679号