# 机器人学回炉重造（1）：正运动学、标准D-H法与改进D-H法的区别与应用（附ABB机械臂运动学建模matlab代码）

## 实例

### 改进D-H参数表

iαi-1ai-1diθi
1000θ1
2pi/2L1=3200θ2
30L3=9750θ3
4pi/2L5=200L6=887θ4
5-pi/200θ5
6pi/200θ6

### Matlab仿真程序（Modified DH）

% Modified DH
% ABB robot
clear;
clc;
th(1) = 0; d(1) = 0; a(1) = 0; alp(1) = 0;
th(2) = 0; d(2) = 0; a(2) = 0.320; alp(2) = pi/2;
th(3) = 0; d(3) = 0; a(3) = 0.975; alp(3) = 0;
th(4) = 0; d(4) = 0.887; a(4) = 0.2; alp(4) = pi/2;
th(5) = 0; d(5) = 0; a(5) = 0; alp(5) = -pi/2;
th(6) = 0; d(6) = 0; a(6) = 0; alp(6) = pi/2;
% DH parameters  th     d    a    alpha  sigma
L1 = Link([th(1), d(1), a(1), alp(1), 0], 'modified');
L2 = Link([th(2), d(2), a(2), alp(2), 0], 'modified');
L3 = Link([th(3), d(3), a(3), alp(3), 0], 'modified');
L4 = Link([th(4), d(4), a(4), alp(4), 0], 'modified');
L5 = Link([th(5), d(5), a(5), alp(5), 0], 'modified');
L6 = Link([th(6), d(6), a(6), alp(6), 0], 'modified');
robot = SerialLink([L1, L2, L3, L4, L5, L6]);
robot.name='ABBRobot-6-dof';
robot.display()
% Forward Pose Kinematics
theta = [0, 120, -15, 0, 0, 0]*pi/180;
robot.teach();
robot.plot(theta);
t0 = robot.fkine(theta)    %末端执行器位姿


### 建立标准D-H坐标系

• 改进D-H参数法α和a的下标均为i-1，而标准D-H中两个参数的下标均为i；
• 改进D-H中Xi是Zi和Zi+1的公垂线，而在标准D-H中Xi是Zi-1和Zi的公垂线；
• 在使用两种方法时，一般先使各θi角为0进行建模；
• 标准D-H中各参数定义如下：
• ai distance ({i-1}, {i} origin) along Xi，因为建模时一般让theta=0，那么xi和xi-1实际上是一个方向
• di distance (Xi-1, Xi) along Zi-1
• θi angle (Xi-1, Xi) about Zi

### 标准D-H参数表

iαiaidiθi
1pi/20.3200.450θ1
200.9750θ2
3pi/20.2000θ3
4-pi/200.887θ4
5pi/200θ5
6000.200θ6

### Matlab仿真程序（Standard D-H）

% Standard DH
% ABB robot
clear;
clc;
th(1) = 0; d(1) = 0.450; a(1) = 0.320; alp(1) = pi/2;
th(2) = 0; d(2) = 0; a(2) = 0.975; alp(2) = 0;
th(3) = 0; d(3) = 0; a(3) = 0.200; alp(3) = pi/2;
th(4) = 0; d(4) = 0.887; a(4) = 0; alp(4) = -pi/2;
th(5) = 0; d(5) = 0; a(5) = 0; alp(5) = pi/2;
th(6) = 0; d(6) = 0.200; a(6) = 0; alp(6) = 0;
% DH parameters  th     d    a    alpha  sigma
L1 = Link([th(1), d(1), a(1), alp(1), 0]);
L2 = Link([th(2), d(2), a(2), alp(2), 0]);
L3 = Link([th(3), d(3), a(3), alp(3), 0]);
L4 = Link([th(4), d(4), a(4), alp(4), 0]);
L5 = Link([th(5), d(5), a(5), alp(5), 0]);
L6 = Link([th(6), d(6), a(6), alp(6), 0]);
robot = SerialLink([L1, L2, L3, L4, L5, L6]);
robot.name='ABBRobot-6-dof';
robot.display()
theta = [0, 120, -15, 0, 0, 0]*pi/180;
robot.teach();
robot.plot(theta);
t = robot.fkine(theta)    %末端执行器位姿


03-06 1万+
01-03 1万+
05-03 2万+
08-12 2万+
12-23 1854
03-11
04-15 2013
06-14 3547
05-26 9454