空间任意两个坐标系的变换关系确实需要6个参数来表示,然而,在建立各个连杆的坐标系时,我们可以拟定一些规则,使得坐标系满足某些约束,从而只需4个参数则可以表示两个坐标系的变换关系。 若坐标轴 x i x_i xi与坐标轴 z i − 1 z_{i-1} zi−1垂直相交(示例如下图),则只需4个参数(杆件长度 a i a_i ai,杆件扭角 α i alpha_i αi,关节距离 d i d_i di,关节转角 θ i heta_i θi)就可以表示两个坐标系的变换关系。下面的证明来于书籍:Robot Modeling and Control(First Edition),by Mark W. Spong, Seth Hutchinson, and M. Vidyasagar.
若坐标系 { x 1 y 1 z 1 } {x_1y_1z_1} {x1y1z1}与坐标系 { x 0 y 0 z 0 } {x_0y_0z_0} {x0y0z0}垂直相交,则坐标系 { x 1 y 1 z 1 } {x_1y_1z_1} {x1y1z1}到坐标系 { x 0 y 0 z 0 } {x_0y_0z_0} {x0y0z0}的齐次变换矩阵为: A = R o t z , θ T r a n s z , d T r a n s x , a R o t x , α (1) A=Rot_{z, heta} Trans_{z,d}Trans_{x,a}Rot_{x,alpha} ag{1} A=Rotz,θTransz,dTransx,aRotx,α(1) (1)式可以写成: A = [ R 1 0 O 1 0 0 1 ] (2) A=left[ egin{matrix} R_1^0 & O_1^0\ 0 & 1 \ end{matrix} ight] ag{2} A=[R100O101](2) 因为 x 1 x_1 x1垂直于 z 0 z_0 z0,故有: 0 = x 1 0 ⋅ z 0 0 = [ r 11 r 21 r 31 ] [ 0 0 1 ] = r 31 (3) 0=x_1^0 cdot z_0^0=left[ egin{matrix} r_{11} & r_{21} & r_{31}\ end{matrix} ight] left[ egin{matrix} 0 \ 0 \ 1 \ end{matrix} ight] =r_{31} ag{3} 0=x10⋅z00=[r11r21r31]⎣⎡001⎦⎤=r31(3) 由于 r 31 = 0 r_{31}=0 r31=0,只要证明存在唯一的杆件扭角 α alpha α,关节转角 θ heta θ,使得: R 1 0 = R o t z , θ R o t x , α = [ c θ − s θ c α s θ s α s θ c θ c α − c θ s α 0 s α c α ] (4) R_1^0=Rot_{z, heta}Rot_{x,alpha}= left[ egin{matrix} c_ heta & -s_ heta c_alpha & s_ heta s_alpha \ s_ heta & c_ heta c_alpha & -c_ heta s_alpha \ 0 & s_alpha & c_alpha end{matrix} ight] ag{4} R10=Rotz,θRotx,α=⎣⎡cθsθ0−sθcαcθcαsαsθsα−cθsαcα⎦⎤(4)
因此,存在唯一的 θ , α heta,alpha θ,α满足: { ( r 11 , r 21 ) = ( c θ , s θ ) ( r 32 , r 33 ) = ( c α , s α ) (5) left { egin{array}{c} (r_{11},r_{21})=(c_ heta,s_ heta) \ (r_{32},r_{33})=(c_alpha,s_alpha) end{array} ight. ag 5 {(r11,r21)=(cθ,sθ)(r32,r33)=(cα,sα)(5) 易得: { θ = a t a n 2 ( r 21 , r 11 ) α = a t a n 2 ( r 32 , r 33 ) (6) left { egin{array}{c} heta=atan2(r_{21},r_{11}) \ alpha=atan2(r_{32},r_{33}) end{array} ight. ag 6 {θ=atan2(r21,r11)α=atan2(r32,r33)(6) 根据旋转矩阵的性质,可以推导得到: { − s θ c α = r 12 s θ s α = r 13 c θ c α = r 22 − c θ s α = r 23 (7) left { egin{array}{c} -s_ heta c_alpha=r_{12} \ s_ heta s_alpha=r_{13} \ c_ heta c_alpha=r_{22} \ -c_ heta s_alpha=r_{23} \ end{array} ight. ag 7 ⎩⎪⎪⎨⎪⎪⎧−sθcα=r12sθsα=r13cθcα=r22−cθsα=r23(7) 可见,坐标系 { x 1 y 1 z 1 } {x_1y_1z_1} {x1y1z1}到坐标系 { x 0 y 0 z 0 } {x_0y_0z_0} {x0y0z0}的旋转变换关系用 θ , α heta,alpha θ,α来表达就足够了。 若 x 1 x_1 x1与 z 0 z_0 z0相交,坐标系 { x 1 y 1 z 1 } {x_1y_1z_1} {x1y1z1}的原点在坐标系 { x 0 y 0 z 0 } {x_0y_0z_0} {x0y0z0}下的坐标(或平移向量)为:
O 1 0 = O 0 0 + d z 0 0 + a x 1 0 = [ 0 0 0 ] + d [ 0 0 1 ] + a [ c θ s θ 0 ] = [ a c θ a s θ d ] (8) O_1^0=O_0^0+dz_0^0+ax_1^0= left[ egin{matrix} 0 \ 0 \ 0 \ end{matrix} ight] +dleft[ egin{matrix} 0 \ 0 \ 1 \ end{matrix} ight] +aleft[ egin{matrix} c_{ heta} \ s_{ heta} \ 0 \ end{matrix} ight] = left[ egin{matrix} ac_{ heta} \ as_{ heta} \ d \ end{matrix} ight] ag{8} O10=O00+dz00+ax10=⎣⎡000⎦⎤+d⎣⎡001⎦⎤+a⎣⎡cθsθ0⎦⎤=⎣⎡acθasθd⎦⎤(8) 综上,坐标系 { x 1 y 1 z 1 } {x_1y_1z_1} {x1y1z1}到坐标系 { x 0 y 0 z 0 } {x_0y_0z_0} {x0y0z0}的齐次变换关系用杆件长度 a a a,杆件扭角 α alpha α,关节距离 d d d,关节转角 θ heta θ 这4个参数就够了。
2、利用DH参数建模时,各个连杆坐标系的建立是唯一的吗?利用DH参数建模时,各个连杆坐标系的建立不是唯一的。只要在建立坐标系时,坐标轴 x i x_i xi与坐标轴 z i − 1 z_{i-1} zi−1垂直相交即可。
3、DH参数表是唯一的吗?DH参数表不是唯一的。因为各个连杆坐标系的建立不是唯一的,导致DH参数不同,但是最终计算得到末端工具坐标系到机器人基坐标系下的齐次变换矩阵是唯一的。(前提是机器人基坐标系与末端工具坐标系的建立保持不变)
4、标准DH参数与修正DH参数有何异同?祥见参考资料2,3。 (1)标准DH参数坐标系建立在传动轴上,而修正DH参数坐标系建立在驱动轴上。 (2)由于坐标系建立位置发生了变化,连杆之间的坐标系变换关系自然也发生变化。 标准DH相邻连杆之间坐标系的变换关系为: i − 1 A i = R o t z , θ i T r a n s z , d i T r a n s x , a i R o t x , α i (9) ^{i-1}A_i=Rot_{z, heta_i} Trans_{z,d_i}Trans_{x,a_i}Rot_{x,alpha_i} ag{9} i−1Ai=Rotz,θiTransz,diTransx,aiRotx,αi(9) 修正DH相邻连杆之间坐标系的变换关系为: i − 1 A i = R o t x , α i − 1 T r a n s x , a i − 1 R o t z , θ i T r a n s z , d i (10) ^{i-1}A_i=Rot_{x,alpha_{i-1}}Trans_{x,a_{i-1}}Rot_{z, heta_i}Trans_{z,d_i} ag{10} i−1Ai=Rotx,αi−1Transx,ai−1Rotz,θiTransz,di(10) (3)修正DH参数中各个参数的物理意义与标准DH参数是一样的。 (4)对于传统的串联机器人而言,两者的表现能力是一样的,没有优劣之分,我们可以选择其中一种方法进行建模。然而,由于修正DH参数坐标系建立在驱动轴上,对于树状结构的机器人,其表现能力更强,可以简化问题。 (5)对于标准DH参数,根据DH参数表,并对式(9) 连乘得到的是末端工具坐标系到机器人基坐标系的齐次变换矩阵;对于修正DH参数,根据DH参数表,并对式(10) 连乘得到的是最后一个驱动关节上的坐标系到机器人基坐标系的齐次变换矩阵,变换到末端工具坐标系还需增加一个变换(通常为平移变换)。
二、标准DH参数 1、DH四个参数的定义(1) d i d_i di :坐标轴 x i − 1 x_{i-1} xi−1与坐标轴 x i x_{i} xi沿着坐标轴 z i − 1 z_{i-1} zi−1的有向距离。 (2) a i a_i ai:坐标轴 z i − 1 z_{i-1} zi−1与坐标轴 z i z_{i} zi沿着坐标轴 x i x_{i} xi的有向距离。 (3) α i alpha_i αi:坐标轴 z i − 1 z_{i-1} zi−1与坐标轴 z i z_{i} zi的夹角,方向定义如下:
(4) θ i heta_i θi:坐标轴 x i − 1 x_{i-1} xi−1与坐标轴 x i x_{i} xi的夹角,方向定义如下:
2、DH连杆坐标系的约定(1)坐标轴 x i x_{i} xi与坐标轴 z i − 1 z_{i-1} zi−1垂直。 (2)坐标轴 x i x_{i} xi与坐标轴 z i − 1 z_{i-1} zi−1相交。
3、根据DH连杆坐标系约定,建立各个连杆坐标系 4、根据DH四个参数的定义,创建DH参数表 三、六轴机器人实例(standard DH)这里以六轴机器人为例,通过建立3种不同的连杆坐标系,创建对应的DH表,比较最终运动学正解最终结果是否一致。其中, d 1 = 0.3991 , a 2 = 0.448 , a 3 = 0.042 , d 4 = 0.451 , d 6 = 0.082 d_1 = 0.3991,a_2 = 0.448,a_3 = 0.042, d_4 = 0.451, d_6 = 0.082 d1=0.3991,a2=0.448,a3=0.042,d4=0.451,d6=0.082,以米为单位。两种不同的连杆坐标系的建立方法得到不同的DH参数表,但最终的机器人运动学正解完全一样!
1、第一种连杆坐标系建立方法连杆坐标系建立如下:
DH参数表如下:
Link d i d_i di a i a_i ai α i alpha_i αi θ i heta_i θi1 d 1 d_1 d10 − π / 2 -pi/2 −π/2 θ 1 heta_1 θ120 a 2 a_2 a20 θ 2 − π / 2 heta_2-pi/2 θ2−π/230 a 3 a_3 a3 − π / 2 -pi/2 −π/2 θ 3 heta_3 θ34 d 4 d_4 d40 π / 2 pi/2 π/2 θ 4 heta_4 θ4500 − π / 2 -pi/2 −π/2 θ 5 heta_5 θ56 d 6 d_6 d600 θ 6 + π heta_6+pi θ6+π 2、第二种连杆坐标系建立方法连杆坐标系建立如下:
DH参数表如下:
Link d i d_i di a i a_i ai α i alpha_i αi θ i heta_i θi1 d 1 d_1 d10 − π / 2 -pi/2 −π/2 θ 1 heta_1 θ120 − a 2 -a_2 −a20 θ 2 + π / 2 heta_2+pi/2 θ2+π/230 − a 3 -a_3 −a3 π / 2 pi/2 π/2 θ 3 heta_3 θ34 d 4 d_4 d40 − π / 2 -pi/2 −π/2 θ 4 heta_4 θ4500 π / 2 pi/2 π/2 θ 5 heta_5 θ56 d 6 d_6 d600 θ 6 heta_6 θ6 四、MATLAB代码 clc;clear;syms d1 d2 d3 d4 d5 d6 a1 a2 a3 a4 a5 a6 realsyms alpha1 alpha2 alpha3 alpha4 alpha5 alpha6 realsyms theta1 theta2 theta3 theta4 theta5 theta6 real;%% (1)a1 = sym(0);alpha1 = sym(-pi/2);A1 = simplify([cos(theta1), -sin(theta1)*cos(alpha1), sin(theta1)*sin(alpha1), a1*cos(theta1) sin(theta1), cos(theta1)*cos(alpha1), -cos(theta1)*sin(alpha1), a1*sin(theta1) 0, sin(alpha1), cos(alpha1), d1 0, 0, 0, 1]);d2 = sym(0);alpha2 = sym(0);A2 = simplify([cos(theta2 - pi/2), -sin(theta2 - pi/2)*cos(alpha2), sin(theta2 - pi/2)*sin(alpha2), a2*cos(theta2 - pi/2) sin(theta2 - pi/2), cos(theta2 - pi/2)*cos(alpha2), -cos(theta2 - pi/2)*sin(alpha2), a2*sin(theta2 - pi/2) 0, sin(alpha2), cos(alpha2), d2 0, 0, 0, 1]);d3 = sym(0);alpha3 = sym(-pi/2);A3 = simplify([cos(theta3), -sin(theta3)*cos(alpha3), sin(theta3)*sin(alpha3), a3*cos(theta3) sin(theta3), cos(theta3)*cos(alpha3), -cos(theta3)*sin(alpha3), a3*sin(theta3) 0, sin(alpha3), cos(alpha3), d3 0, 0, 0, 1]);a4 = sym(0);alpha4 = sym(pi/2);A4 = simplify([cos(theta4), -sin(theta4)*cos(alpha4), sin(theta4)*sin(alpha4), a4*cos(theta4) sin(theta4), cos(theta4)*cos(alpha4), -cos(theta4)*sin(alpha4), a4*sin(theta4) 0, sin(alpha4), cos(alpha4), d4 0, 0, 0, 1]);a5 = sym(0);d5 = sym(0);alpha5 = sym(-pi/2);A5 = simplify([cos(theta5), -sin(theta5)*cos(alpha5), sin(theta5)*sin(alpha5), a5*cos(theta5) sin(theta5), cos(theta5)*cos(alpha5), -cos(theta5)*sin(alpha5), a5*sin(theta5) 0, sin(alpha5), cos(alpha5), d5 0, 0, 0, 1]);a6 = sym(0);alpha6 = sym(0);A6 = simplify([cos(theta6+pi), -sin(theta6+pi)*cos(alpha6), sin(theta6+pi)*sin(alpha6), a6*cos(theta6+pi) sin(theta6+pi), cos(theta6+pi)*cos(alpha6), -cos(theta6+pi)*sin(alpha6), a6*sin(theta6+pi) 0, sin(alpha6), cos(alpha6), d6 0, 0, 0, 1]);T1 = simplify(A1*A2*A3*A4*A5*A6);%% (2)a1 = sym(0);alpha1 = sym(-pi/2);A1 = simplify([cos(theta1), -sin(theta1)*cos(alpha1), sin(theta1)*sin(alpha1), a1*cos(theta1) sin(theta1), cos(theta1)*cos(alpha1), -cos(theta1)*sin(alpha1), a1*sin(theta1) 0, sin(alpha1), cos(alpha1), d1 0, 0, 0, 1]);d2 = sym(0);alpha2 = sym(0);A2 = simplify([cos(theta2 + pi/2), -sin(theta2 + pi/2)*cos(alpha2), sin(theta2 + pi/2)*sin(alpha2), (-a2)*cos(theta2 + pi/2) sin(theta2 + pi/2), cos(theta2 + pi/2)*cos(alpha2), -cos(theta2 + pi/2)*sin(alpha2), (-a2)*sin(theta2 + pi/2) 0, sin(alpha2), cos(alpha2), d2 0, 0, 0, 1]);d3 = sym(0);alpha3 = sym(pi/2);A3 = simplify([cos(theta3), -sin(theta3)*cos(alpha3), sin(theta3)*sin(alpha3), (-a3)*cos(theta3) sin(theta3), cos(theta3)*cos(alpha3), -cos(theta3)*sin(alpha3), (-a3)*sin(theta3) 0, sin(alpha3), cos(alpha3), d3 0, 0, 0, 1]);a4 = sym(0);alpha4 = sym(-pi/2);A4 = simplify([cos(theta4), -sin(theta4)*cos(alpha4), sin(theta4)*sin(alpha4), a4*cos(theta4) sin(theta4), cos(theta4)*cos(alpha4), -cos(theta4)*sin(alpha4), a4*sin(theta4) 0, sin(alpha4), cos(alpha4), d4 0, 0, 0, 1]);a5 = sym(0);d5 = sym(0);alpha5 = sym(pi/2);A5 = simplify([cos(theta5), -sin(theta5)*cos(alpha5), sin(theta5)*sin(alpha5), a5*cos(theta5) sin(theta5), cos(theta5)*cos(alpha5), -cos(theta5)*sin(alpha5), a5*sin(theta5) 0, sin(alpha5), cos(alpha5), d5 0, 0, 0, 1]);a6 = sym(0);alpha6 = sym(0);A6 = simplify([cos(theta6), -sin(theta6)*cos(alpha6), sin(theta6)*sin(alpha6), a6*cos(theta6) sin(theta6), cos(theta6)*cos(alpha6), -cos(theta6)*sin(alpha6), a6*sin(theta6) 0, sin(alpha6), cos(alpha6), d6 0, 0, 0, 1]); T2 = simplify(A1*A2*A3*A4*A5*A6);err = simplify(T1 - T2) 五、参考资料1.Robot Modeling and Control(First Edition),by Mark W. Spong, Seth Hutchinson, and M. Vidyasagar 2.https://blog.csdn.net/hitgavin/article/details/105018983 3.https://blog.csdn.net/jldemanman/article/details/80508683