Denavit–Hartenberg Parameters

The Denavit–Hartenberg parameters (also called DH parameters) is proposed by Denavit and Hartenberg in 1955. In mechanical engineering, the Denavit–Hartenberg parameters are the four parameters associated with a particular convention for attaching reference frames to the links of a spatial kinematic chain, or robot manipulator.

DH参数是机器人学里的一个重要的动力学参数,它用来表征机器人各关节点的参考系之间的关系。

20061602
多轴机械臂关节初始状态及参数示意图

比如上图所示的多轴机械臂,从惰性参考系0系到末端参考系E系,需要经过多关节的参考系变换,而DH参数就是用来表征其各个关节点的参考系之间的关系。所以建立DH参数之前,我们需要根据机械臂模型建立确定各节点的参考系。这里需要读者具有动力学的知识背景,建系过程省略。最终我们可以得到各节点的参考系如下图所示。

20061601
多轴机械臂关节参考系示意图

DH Parameters计算如下:

ia_{i-1}\alpha_{i-1}d_{i}q_{i}
100Aq_{1}+90\degree
2090\degree-Dq_{2}
30-90\degree-Cq_{3}
4E90\degree0q_{4}
E090\degreeF0

为了利用DH Parameters计算Transformation Matrix,我构建了一个简单的Matlab方法,可以计算Transformation Matrix(T-Matrix),同时也可以计算Rotation Matrix(R-Matrix).

%% Denavit–Hartenberg Parameters Calculator
% Script written by:
% Zhuo LI (toplizhuo@gmail.com)
% The University of Melbourne

%% Main Script

% store the parameters
syms q1 q2 q3 q4 qe A B C D E F

% call the function Rmatrix to calculate R-Matrix
R_01 = Rmatrix('Rx',0)*Rmatrix('Rz',q1+pi/2);
R_12 = Rmatrix('Rx',pi/2)*Rmatrix('Rz',q2);
R_23 = Rmatrix('Rx',-pi/2)*Rmatrix('Rz',q3);
R_34 = Rmatrix('Rx',pi/2)*Rmatrix('Rz',q4);
R_4E = Rmatrix('Rx',pi/2)*Rmatrix('Rz',0);
% the results of R-Matrix from frame{0} to frame{E}
R_0E = R_01*R_12*R_23*R_34*R_4E;
R_0E = simplify(R_0E);

% call the function DHmatrix to calculate T-Matrix
T_01 = DHmatrix('Dx',0)*DHmatrix('Rx',0)*DHmatrix('Dz',A)*DHmatrix('Rz',q1+pi/2);
T_12 = DHmatrix('Dx',0)*DHmatrix('Rx',pi/2)*DHmatrix('Dz',-D)*DHmatrix('Rz',q2);
T_23 = DHmatrix('Dx',0)*DHmatrix('Rx',-pi/2)*DHmatrix('Dz',-C)*DHmatrix('Rz',q3);
T_34 = DHmatrix('Dx',E)*DHmatrix('Rx',pi/2)*DHmatrix('Dz',0)*DHmatrix('Rz',q4);
T_4E = DHmatrix('Dx',0)*DHmatrix('Rx',pi/2)*DHmatrix('Dz',F)*DHmatrix('Rz',0);
% the results of T-Matrix from frame{0} to frame{E}
T_0E = T_01*T_12*T_23*T_34*T_4E;
T_0Es = simplify(T_0E);

%% Functions
% calculate for R-Matrix, the input value should be radian
function RM = Rmatrix(type,value)
    if type == 'Rx'
        RM = [1 0 0;0 cos(value) -sin(value); 0 sin(value) cos(value)];
    elseif type == 'Rz'
        RM = [cos(value) -sin(value) 0;sin(value) cos(value) 0; 0 0 1];
    end
end
% calculate for T-Matrix, the input value should be radian
function DHM = DHmatrix(type,value)
    if type == 'Dx'
        DHM = [eye(3) [value;0;0];0 0 0 1];
    elseif type == 'Dz'
        DHM = [eye(3) [0;0;value];0 0 0 1];
    elseif type == 'Rx'
        DHM = [[1 0 0;0 cos(value) -sin(value); 0 sin(value) cos(value)] [0;0;0];0 0 0 1];
    elseif type == 'Rz'
        DHM = [[cos(value) -sin(value) 0;sin(value) cos(value) 0; 0 0 1] [0;0;0];0 0 0 1];
    else
        DHM = eye(4);
    end
end