第一次写,写的不周到的地方,希望大家谅解
本文链接:https://blog.csdn.net/mumapeople/article/details/106430795
目录
(一)手写正运动学函数(DH)
(二)主函数
(三)代码解释
(四)易错点
%function T=zhengDHdaican(s,base_e,p,d,a,alpha,beta,tool_e)
function T =zhengDHdaican(a1,a2,a3,d4,d6,theta1,theta2,theta3,theta4,theta5,theta6)
SDH=[theta1 0 a1 -pi/2;
theta2 0 a2 0;
theta3 0 a3 -pi/2;
theta4 d4 0 pi/2;
theta5 0 0 -pi/2;
theta6 d6 0 0];
for i = 1:1:6
A{1,i} = [cos(SDH(i,1)) -sin(SDH(i,1))*cos(SDH(i,4)) sin(SDH(i,4))*sin(SDH(i,1)) SDH(i,3)*cos(SDH(i,1));
sin(SDH(i,1)) cos(SDH(i,1))*cos(SDH(i,4)) -cos(SDH(i,1))*sin(SDH(i,4)) SDH(i,3)*sin(SDH(i,1));
0 sin(SDH(i,4)) cos(SDH(i,4)) SDH(i,2);
0 0 0 1 ];
end
T = A{1,1}*A{1,2}*A{1,3}*A{1,4}*A{1,5}*A{1,6};
end
stamyt06=zhengDHdaican(0.180,0.600 ,0.130 ,0.630 ,0.1075,0,0,pi/2,0,0,pi/2)
stamyt06 =
-0.0000 -0.0000 -1.0000 0.0425
-1.0000 -0.0000 0.0000 0.0000
-0.0000 1.0000 -0.0000 -0.1300
0 0 0 1.0000
function T =zhengDHdaican(a1,a2,a3,d4,d6,theta1,theta2,theta3,theta4,theta5,theta6)
创建函数名和变量
SDH=[theta1 0 a1 -pi/2;
theta2 0 a2 0;
theta3 0 a3 -pi/2;
theta4 d4 0 pi/2;
theta5 0 0 -pi/2;
theta6 d6 0 0];
标准DH模型参数列表
for i = 1:1:6
A{1,i} = [cos(SDH(i,1)) -sin(SDH(i,1))*cos(SDH(i,4)) sin(SDH(i,4))*sin(SDH(i,1)) SDH(i,3)*cos(SDH(i,1));
sin(SDH(i,1)) cos(SDH(i,1))*cos(SDH(i,4)) -cos(SDH(i,1))*sin(SDH(i,4)) SDH(i,3)*sin(SDH(i,1));
0 sin(SDH(i,4)) cos(SDH(i,4)) SDH(i,2);
0 0 0 1 ];
end
用for循环函数来创建变换矩阵
T = A{1,1}*A{1,2}*A{1,3}*A{1,4}*A{1,5}*A{1,6};
得到坐标系{6}相对于坐标系{0}的变换
function T =zhengDHdaican(a1,a2,a3,d4,d6,theta1,theta2,theta3,theta4,theta5,theta6)
function函数保存的.m文件名,一定要和zhengDHdaican同一个名字
文件保存路径一定要
链接: link.
:
出现图片上面错误,有两种原因,有可能同时存在
1、function T =zhengDHdaican(a1,a2,a3,d4,d6,theta1,theta2,theta3,theta4,theta5,theta6)
function函数保存的.m文件名,一定要和zhengDHdaican同一个名字Alt]
2、保存路径
(https://imgconvert.csdnimg.cn/aHR0cHM6Ly9hdmF0YXIuY3Nkbi5uZXQvNy83L0IvMV9yYWxmX2h4MTYzY29tLmpwZw)
本文链接:https://blog.csdn.net/mumapeople/article/details/106430795