1. Matlab机器人工具箱

2. 创建MDH单机械臂

3. 创建MDH双臂机器人

UR构型双臂

4. MDH-双臂机器人

# 2. 创建MDH单机械臂

``````clear;
clc;
%建立机器人模型
%       theta    d        a        alpha     offset
% L1=Link([0       0.4      0.025    pi/2   0      -pi/2     ]); %定义连杆的D-H参数
% L2=Link([pi/2   0        0.56     0       0     pi/2     ]);
% L3=Link([0       0        0.035    pi/2   0   0     ]);
% L4=Link([0       0.515    0        pi/2   0   0     ]);
% L5=Link([pi      0        0        pi/2   0   0     ]);
% L6=Link([0       0.08     0        0      0   0     ]);

%   theta |         d |         a |     alpha |     type|   offset |
L(1)=Link([0       -72        150        0      0     pi/2  ],'modified'); % 关节1这里的最后一个量偏置
L(2)=Link([0       0          22        pi/2      0    -pi/2  ],'modified');
L(3)=Link([0       0           285        0          0    -pi/2 ],'modified');
L(4)=Link([0       220        3.5           -pi/2      0    0 ],'modified');

robot.plot([-pi/2,-10*pi/180,-12*pi/180,0]);%输出机器人模型，后面的角为输出时的theta姿态

``````

``````classdef Link < matlab.mixin.Copyable
properties
% kinematic parameters
theta % kinematic: link angle
d     % kinematic: link offset
alpha % kinematic: link twist
a     % kinematic: link length
jointtype  % revolute='R', prismatic='P' -- should be an enum
mdh   % standard DH=0, MDH=1
offset % joint coordinate offset
name   % joint coordinate name
flip   % joint moves in opposite direction

% dynamic parameters
m  % dynamic: link mass
r  % dynamic: position of COM with respect to link frame (3x1)
I  % dynamic: inertia of link with respect to COM (3x3)
Jm % dynamic: motor inertia
B  % dynamic: motor viscous friction (1x1 or 2x1)

Tc % dynamic: motor Coulomb friction (1x2 or 2x1)
G  % dynamic: gear ratio
qlim % joint coordinate limits (2x1)
end
``````

``````% Examples::
% A standard Denavit-Hartenberg link
%        L3 = Link('d', 0.15005, 'a', 0.0203, 'alpha', -pi/2);
% since 'theta' is not specified the joint is assumed to be revolute, and
% since the kinematic convention is not specified it is assumed 'standard'.
%
% Using the old syntax
%        L3 = Link([ 0, 0.15005, 0.0203, -pi/2], 'standard');
% the flag 'standard' is not strictly necessary but adds clarity.  Only 4 parameters
% are specified so sigma is assumed to be zero, ie. the joint is revolute.
%
%        L3 = Link([ 0, 0.15005, 0.0203, -pi/2, 0], 'standard');
% the flag 'standard' is not strictly necessary but adds clarity.  5 parameters
% are specified and sigma is set to zero, ie. the joint is revolute.
%
%        L3 = Link([ 0, 0.15005, 0.0203, -pi/2, 1], 'standard');
% the flag 'standard' is not strictly necessary but adds clarity.  5 parameters
% are specified and sigma is set to one, ie. the joint is prismatic.
%
% For a modified Denavit-Hartenberg revolute joint
%        L3 = Link([ 0, 0.15005, 0.0203, -pi/2, 0], 'modified');``````

# 4. MDH-双臂机器人

4轴双臂机器人MDH参数表格

代码示例

``````% 2021年9月9日
% 双臂飞行机器人，机械臂4Dof运动学模型及工作空间绘制
% haowanghk@gmail.com
clear all;
clc;
%   theta |         d |         a |     alpha |     type|   offset |
L(1)=Link([0       -0.072        0.150        0      0     pi/2  ],'modified'); % 关节1这里的最后一个量偏置
L(2)=Link([0       0          0.022        pi/2      0    -pi/2  ],'modified');
L(3)=Link([0       0           0.285        0          0    -pi/2 ],'modified');
L(4)=Link([0       0.22        0.0035           -pi/2      0    0 ],'modified');
% L(5)=Link([0       0           0           -pi/2       0     ],'modified');
% L(6)=Link([0       0            0           pi/2      0     ],'modified');
%                  0.262
p560L.tool=[0 -1 0 0;
1 0 0 0;
0 0 1 0 ;
0 0 0 1;];

R(1)=Link([0       -0.072        -0.15        0      0     pi/2  ],'modified'); % 关节1这里的最后一个量偏置
R(2)=Link([0       0          0.022        pi/2      0    -pi/2  ],'modified');
R(3)=Link([0       0           0.285        0          0    -pi/2 ],'modified');
R(4)=Link([0       0.22        0.0035           -pi/2      0    0 ],'modified');
% R(5)=Link([0       0           0           -pi/2       0     ],'modified');
% R(6)=Link([0       0           0           pi/2      0     ],'modified');
%                  0.262
p560R.tool=[0 -1 0 0;
1 0 0 0;
0 0 1 0 ;
0 0 0 1;];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   platform

platform=SerialLink([0 0 0 0],'name','platform','modified');%虚拟腰部关节
platform.base=[1 0 0 0;
0 1 0 0;
0 0 1 0 ;
0 0 0 1;]; %基座高度
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   R

pR.display();

view(3)
hold on
grid on
axis([-1.5, 1.5, -1.5, 1.5, -1.0, 1.5])

pR.plot([0 pi/4 pi/4 0 0]) % 第一个量固定为0，目的是为了模拟腰关节，左臂下同
hold on

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   L
pL.display();
pL.plot([0 -pi/4 pi/4 0  0])
hold on``````