1 创建机器人的几种方法
1.1 方法1
>> L1=Link([0 1 0.5 0 0],'standard')
L1 =
Revolute(std): theta=q, d=1, a=0.5, alpha=0, offset=0
>> L2=Link([0 1 0 0 0],'standard')
L2 =
Revolute(std): theta=q, d=1, a=0, alpha=0, offset=0
>> R = SerialLink([L1 L2],'name','myrobot')
R =
myrobot:: 2 axis, RR, stdDH, slowRNE
+---+-----------+-----------+-----------+-----------+-----------+
| j | theta | d | a | alpha | offset |
+---+-----------+-----------+-----------+-----------+-----------+
| 1| q1| 1| 0.5| 0| 0|
| 2| q2| 1| 0| 0| 0|
+---+-----------+-----------+-----------+-----------+-----------+
1.2 方法2
d1 = 398;
d2 = -0.299;
d3 = 0;
d4 = 556.925;
d5 = 0;
d6 = 165;
a1 = 168.3;
a2 = 650.979;
a3 = 156.240;
a4 = 0;
a5 = 0;
a6 = 0;
alpha1 = pi/2;
alpha2 = 0;
alpha3 = pi/2;
alpha4 = -pi/2;
alpha5 = pi/2;
alpha6 = 0;
L1=Link([0 d1 a1 alpha1]);
L2=Link([0 d2 a2 alpha2]);L2.offset = pi/2;
L3=Link([0 d3 a3 alpha3]);
L4=Link([0 d4 a4 alpha4]);
L5=Link([0 d5 a5 alpha5]);
L6=Link([0 d6 a6 alpha6]);
L1.qlim = [(-165/180)*pi,(165/180)*pi];
L2.qlim = [(-95/180)*pi, (70/180)*pi];
L3.qlim = [(-85/180)*pi, (95/180)*pi];
L4.qlim = [(-180/180)*pi,(180/180)*pi];
L5.qlim = [(-115/180)*pi,(115/180)*pi];
L6.qlim = [(-360/180)*pi,(360/180)*pi];
robot=SerialLink([L1 L2 L3 L4 L5 L6],'name','myrobot');
robot =
myrobot:: 6 axis, RRRRRR, stdDH, slowRNE
+---+-----------+-----------+-----------+-----------+-----------+
| j | theta | d | a | alpha | offset |
+---+-----------+-----------+-----------+-----------+-----------+
| 1| q1| 398| 168.3| 1.5708| 0|
| 2| q2| -0.299| 650.979| 0| 1.5708|
| 3| q3| 0| 156.24| 1.5708| 0|
| 4| q4| 556.925| 0| -1.5708| 0|
| 5| q5| 0| 0| 1.5708| 0|
| 6| q6| 165| 0| 0| 0|
+---+-----------+-----------+-----------+-----------+-----------+
1.3 方法3
clc
clear all
close all
deg = pi/180;
L1= Revolute('d', 0, 'a', 0, 'alpha', 0,'modified', ...
'I', [0.1183 -0.0001 0.0001;
-0.0001 0.1182 0.0001;
0.0001 0.0001 0.0140], ...
'r', [0.0002 0.0002 0.1264], ...
'm', 5.6431, ...
'Jm', 2.2e-4, ...
'G', 81, ...
'B', 1.48e-3, ...
'Tc', [0.395 -0.435], ...
'qlim', [-180 180]*deg );
L2 = Revolute('d', 0.06, 'a', 0, 'alpha', -pi/2,'modified', ...
'I', [0.0723,0.0000,-0.0051;0.0000,0.0784,0.0000;-0.0051,0.0000,0.0169;], ...
'r', [-0.0062,0.0001,0.1080], ...
'm', 5.0478, ...
'Jm', 2.2e-4, ...
'G', 121, ...
'B', .817e-3, ...
'Tc', [0.126 -0.071], ...
'qlim', [-105 105]*deg );
L3 = Revolute('d', -0.004, 'a', 0.332, 'alpha', 0, 'modified', ...
'I', [0.4263,0.0000,-0.0072;
0.0000,0.4334,0.0001;
-0.0072,0.0001,0.0191], ...
'r', [-0.0131,0.0001,0.2402], ...
'm', 5.7542, ...
'Jm', 2.2e-4, ...
'G', 81, ...
'B', 1.38e-3, ...
'Tc', [0.132, -0.105], ...
'qlim', [-225 45]*deg );
L4 = Revolute('d', -0.056, 'a', 0, 'alpha', pi/2, 'modified', ...
'I', [0.0821,0.0000,-0.0314;0.0000,0.1257,0.0001;-0.0314,0.0001,0.0451], ...
'r', [-0.0850,0.0003,0.1540], ...
'm', 3.0870, ...
'Jm', 2.2e-4, ...
'G', 81, ...
'B', 71.2e-6, ...
'Tc', [11.2e-3, -16.9e-3], ...
'qlim', [-110 110]*deg);
L5 = Revolute('d', 0.050, 'a', 0, 'alpha', -pi/2, 'modified', ...
'I', [0.0235,0.0000,-0.0002;0.0000,0.0253,0.0000;-0.0002,0.0000,0.0045], ...
'r', [0.0001,0.0002,0.0982], ...
'm', 2.0459, ...
'Jm', 2.2e-4, ...
'G', 81, ...
'B', 82.6e-6, ...
'Tc', [9.26e-3, -14.5e-3], ...
'qlim', [-115 115]*deg );
L6 = Revolute('d', -0.050, 'a', 0, 'alpha', pi/2, 'modified', ...
'I', [0.0684,0.0000,0.0001;0.0000,0.0696,-0.0001;0.0001,-0.0001,0.0047], ...
'r', [-0.0111,-0.0003,0.1366], ...
'm', 2.6317, ...
'Jm', 2.2e-4, ...
'G', 51, ...
'B', 36.7e-6, ...
'Tc', [3.96e-3, -10.5e-3], ...
'qlim', [-180 180]*deg );
robot=SerialLink([L1,L2,L3,L4,L5,L6],'name','VIPER7','comment','LL');
robot =
VIPER7:: 6 axis, RRRRRR, modDH, slowRNE
- LL;
+---+-----------+-----------+-----------+-----------+-----------+
| j | theta | d | a | alpha | offset |
+---+-----------+-----------+-----------+-----------+-----------+
| 1| q1| 0| 0| 0| 0|
| 2| q2| 0.06| 0| -1.5708| 0|
| 3| q3| -0.004| 0.332| 0| 0|
| 4| q4| -0.056| 0| 1.5708| 0|
| 5| q5| 0.05| 0| -1.5708| 0|
| 6| q6| -0.05| 0| 1.5708| 0|
+---+-----------+-----------+-----------+-----------+-----------+
1.4 方法4
clear;
close all;
clc;
angle=pi/180;
theta1 = 0; D1 = 0.4; A1 = 0.025; alpha1 = pi/2; offset1 = 0;
theta2 = pi/2;D2 = 0; A2 = 0.56; alpha2 = 0; offset2 = 0;
theta3 = 0; D3 = 0; A3 = 0.035; alpha3 = pi/2; offset3 = 0;
theta4 = 0; D4 = 0.515; A4 = 0; alpha4 = pi/2; offset4 = 0;
theta5 = pi; D5 = 0; A5 = 0; alpha5 = pi/2; offset5 = 0;
theta6 = 0; D6 = 0.08; A6 = 0; alpha6 = 0; offset6 = 0;
L(1) = Link([theta1, D1, A1, alpha1, offset1], 'standard')
L(2) = Link([theta2, D2, A2, alpha2, offset2], 'standard')
L(3) = Link([theta3, D3, A3, alpha3, offset3], 'standard')
L(4) = Link([theta4, D4, A4, alpha4, offset4], 'standard')
L(5) = Link([theta5, D5, A5, alpha5, offset5], 'standard')
L(6) = Link([theta6, D6, A6, alpha6, offset6], 'standard')
L(1).qlim =[-180*angle, 180*angle];
L(2).qlim =[-180*angle, 180*angle];
L(3).qlim =[-180*angle, 180*angle];
L(4).qlim =[-180*angle, 180*angle];
L(5).qlim =[-180*angle, 180*angle];
L(6).qlim =[-180*angle, 180*angle];
robot0 = SerialLink(L,'name','six');
robot0 =
six:: 6 axis, RRRRRR, stdDH, slowRNE
+---+-----------+-----------+-----------+-----------+-----------+
| j | theta | d | a | alpha | offset |
+---+-----------+-----------+-----------+-----------+-----------+
| 1| q1| 0.4| 0.025| 1.5708| 0|
| 2| q2| 0| 0.56| 0| 0|
| 3| q3| 0| 0.035| 1.5708| 0|
| 4| q4| 0.515| 0| 1.5708| 0|
| 5| q5| 0| 0| 1.5708| 0|
| 6| q6| 0.08| 0| 0| 0|
+---+-----------+-----------+-----------+-----------+-----------+
1.5 方法5
clear;
clc;
L(1) = Link('standard','d', 100, 'a', 0, 'alpha', pi/2,'offset',0,'qlim',[0,0]/180*pi);
L(2) = Link('revolute','d', 0, 'a', 420, 'alpha', 0,'offset',pi/2,'qlim',[-90,90]/180*pi);
L(3) = Link('revolute','d', 0, 'a', 480, 'alpha', 0,'offset',-pi/2,'qlim',[-90,130]/180*pi);
L(4) = Link('revolute','d', 0, 'a', 840, 'alpha', 0,'offset',pi/2,'qlim',[-120,90]/180*pi);
bot = SerialLink(L, 'name', '4-dof');
bot =
4-dof:: 6 axis, RRRRRR, stdDH, slowRNE
+---+-----------+-----------+-----------+-----------+-----------+
| j | theta | d | a | alpha | offset |
+---+-----------+-----------+-----------+-----------+-----------+
| 1| q1| 100| 0| 1.5708| 0|
| 2| q2| 0| 420| 0| 1.5708|
| 3| q3| 0| 480| 0| -1.5708|
| 4| q4| 0| 840| 0| 1.5708|
| 5| q5| 0| 0| 1.5708| 0|
| 6| q6| 0.08| 0| 0| 0|
+---+-----------+-----------+-----------+-----------+-----------+
1.6 方法6
clear,clc,close all;
format compact
syms q1 q2 dq1 dq2 ddq1 ddq2 m1 m2 L1 Lc1 Lc2 Izz1 Izz2 g real
L(1)=RevoluteMDH('d',0,'a',0,'alpha',0);
L(2)=RevoluteMDH('d',0,'a',L1,'alpha',0,'offset',0);
twolink = SerialLink(L);
twolink =
noname:: 2 axis, RR, modDH, slowRNE
+---+-----------+-----------+-----------+-----------+-----------+
| j | theta | d | a | alpha | offset |
+---+-----------+-----------+-----------+-----------+-----------+
| 1| q1| 0| 0| 0| 0|
| 2| q2| 0| L1| 0| 0|
+---+-----------+-----------+-----------+-----------+-----------+
2 定义Link属性
L1=Link([0 1 0.5 0 0],'standard');
L2=Link([0 1 0 0 0],'standard');
R = SerialLink([L1 L2],'name','myrobot');
L1.a = 0.1;
L1.offset = 0.5;
L1.m = 2;
L1.Jm = 0.1;
L1.r = [1,0,0];
L1.I = [0,0,0;0,0,0;0,0,2];
L1.qlim = [(-165/180)*pi,(165/180)*pi];
R.base = transl(0,0,1);
3 查看Link属性
R.n;
R.display();
theta1=[0 -pi/2];
R.plot(theta1);
qplot(q(:,i));grid on;title('位置');
qplot(qd(:,i));grid on;title('速度');
qplot(qdd(:,i));grid on;title('加速度');
Q = robot.rne(q,qd,qdd);
t=[0:0.01:2];
qplot(t,Q);grid on;title('关节力矩');
R.teach();