自己前7篇帖子
链接: 搜狐的一个帖子.
链接: https://blog.csdn.net/UFv59to8/article/details/106152248.
链接: matlab 说明文档.
我使用的是aubo-i5的机器人模型,aubo的urdf模型和模型文件在git上:
链接: aubo_description.
在aubo_robot/aubo_description/里面有urdf和模型文件,如果用matlab读取urdf,需要把urdf中mesh filename属性修改,指到本地存mesh文件的地方。
通过“importrobot”函数读取机器人URDF模型
robot = importrobot('aubo_i5.urdf');
这部分有待优化,我摸索到的方法是,先使用“randomConfiguration”配置关节角度,之后获取配置后的各个参数。
q = [6.0513-pi -1.2767+pi/2 0.1328 -3.2572+pi/2 -0.0698 0.7795];%某一瞬时的关节的角度
s=randomConfiguration(robot);
JointName | JointPosition |
---|---|
-2.75567550260564 | ‘shoulder_joint’ |
-1.12044496526741 | ‘upperArm_joint’ |
1.72885852567960 | ‘foreArm_joint’ |
2.88164036424470 | ‘wrist1_joint’ |
0.527430892508071 | ‘wrist2_joint’ |
1.69606748061787 | ‘wrist3_joint’ |
之后对每个关节的角度进行修改
for k = 1:6
s(k).JointPosition = q(k);
end
show(robot,s)
或者
robot.show(s)
L{1} = robot.getBody('shoulder_Link');
L{2} = robot.getBody('upperArm_Link');
L{3} = robot.getBody('foreArm_Link');
L{4} = robot.getBody('wrist1_Link');
L{5} = robot.getBody('wrist2_Link');
L{6} = robot.getBody('wrist3_Link');
T1 = getTransform(robot,s,'shoulder_Link');
T2 = getTransform(robot,s,'upperArm_Link','shoulder_Link');
T3 = getTransform(robot,s,'foreArm_Link','upperArm_Link');
T4 = getTransform(robot,s,'wrist1_Link','foreArm_Link');
T5 = getTransform(robot,s,'wrist2_Link','wrist1_Link');
T6 = getTransform(robot,s,'wrist3_Link','wrist2_Link');
%注意此处的变换矩阵取转置,其实可以改变getTransform参数bodyName1和bodyName2到达变换效果
R{1}= T1(1:3,1:3)'; p{1} = T1(1:3,4);
R{2}= T2(1:3,1:3)'; p{2} = T2(1:3,4);
R{3}= T3(1:3,1:3)'; p{3} = T3(1:3,4);
R{4}= T4(1:3,1:3)'; p{4} = T4(1:3,4);
R{5}= T5(1:3,1:3)'; p{5} = T5(1:3,4);
R{6}= T6(1:3,1:3)'; p{6} = T6(1:3,4);
M1 = L{1}.Mass;
M2 = L{2}.Mass ;
M3 = L{3}.Mass ;
M4 = L{4}.Mass;
M5 = L{5}.Mass;
M6 = L{6}.Mass;
c{1} = L{1}.CenterOfMass;
c{2} = L{2}.CenterOfMass;
c{3} = L{3}.CenterOfMass;
c{4} = L{4}.CenterOfMass;
c{5} = L{5}.CenterOfMass;
c{6} = L{6}.CenterOfMass;
Inertia =L{i}.Inertia;
I=[Inertia(1),Inertia(6),Inertia(5);Inertia(6),Inertia(2),Inertia(4);Inertia(5),Inertia(4),Inertia(3)];