当前位置:   article > 正文

Matlab 机器人工具箱 创建机器人

Matlab 机器人工具箱 创建机器人

1 创建机器人的几种方法

1.1 方法1

%   theta   d   a   alpha  sigma
>> 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
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

1.2 方法2

%% STD-DH参数
%定义连杆的D-H参数
%连杆偏移
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;
%建立机器人模型
%       theta  d        a        alpha    
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];
%连接连杆,机器人取名为myrobot
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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53

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');  %SerialLink类函数
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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80

1.4 方法4

%% 参数定义
clear;
close all;
clc;
 
%角度转换
angle=pi/180;  %转化为角度制
 
%D-H参数表
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;
 
%% DH法建立模型,关节转角,关节距离,连杆长度,连杆转角,关节类型(0转动,1移动),'standard':建立标准型D-H参数
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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47

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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

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); %-pi/2
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|
+---+-----------+-----------+-----------+-----------+-----------+
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

2 定义Link属性

%   theta   d   a   alpha  sigma
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); %世界坐标系定为(0,0,1)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

3 查看Link属性

R.n; % 连杆数
R.display();    %Link类函数,显示建立机器人DH参数
theta1=[0 -pi/2];    %机器人伸直且垂直
R.plot(theta1);  %SerialLink类函数,显示机器人图像
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(); %可以自由拖动的关节角度
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/200187
推荐阅读
相关标签
  

闽ICP备14008679号