RobWork机器人框架(4):手把手教你推导UR机器人的逆解算法

928 阅读1分钟

UR3机器人的DH参数表

Transformθ\thetaddaaα\alphaoffset
0~1θ1\theta_{1}d1=0.15190d_{1}=0.151900π/2\pi/20
1~2θ2\theta_{2}0a2=0.24365a_{2}=-0.2436500
2~3θ3\theta_{3}0a3=0.21325a_{3}=-0.2132500
3~4θ4\theta_{4}d4=0.11235d_{4}=0.112350π/2\pi/20
4~5θ5\theta_{5}d5=0.08535d_{5}=0.085350π/2-\pi/20
5~6θ6\theta_{6}d6=0.08190d_{6}=0.08190000

正向运动学

标准DH建模法下相邻坐标系之间的转换关系为:

ii1T=Rot(z,θ)×Trans(z,d)×Trans(x,a)×Rot(x,α)=[cosθisinθicosαisinθisinαiaicosθisinθicosθicosαicosθisinαiaisinθi0sinαicosαidi0001]\begin{aligned} ^{i-1}_{i}T &=Rot(z, \theta) \times Trans(z, d) \times Trans(x, a) \times Rot(x, \alpha) \\ &= \begin{bmatrix} cos\theta_{i} & -sin\theta_{i}cos\alpha_{i} & sin\theta_{i}sin\alpha_{i} & a_{i}cos\theta_{i}\\ sin\theta_{i} & cos\theta_{i}cos\alpha_{i} & -cos\theta_{i}sin\alpha_{i} & a_{i}sin\theta_{i}\\ 0 & sin\alpha_{i} & cos\alpha_{i} & d_{i}\\ 0 & 0 & 0 & 1 \end{bmatrix} \end{aligned}
60T=[nxoxaxpxnyoyaypynzozazpz0001]=10T21T32T43T54T65T^{0}_{6}T=\begin{bmatrix} n_x & o_x & a_x & p_x\\ n_y & o_y & a_y & p_y\\ n_z & o_z & a_z & p_z\\ 0 & 0 & 0 & 1 \end{bmatrix} ={{^{0}_{1}T}{^{1}_{2}T}{^2_{3}T}{^3_{4}T}{^4_{5}T}{^5_{6}T}}
10T=[cosθ10sinθ10sinθ10cosθ10010d10001](1) ^{0}_{1}T =\begin{bmatrix} cos\theta_{1} & 0 & sin\theta_{1} & 0\\ sin\theta_{1} & 0 & -cos\theta_{1} & 0\\ 0 & 1 & 0 &d_{1} \\ 0 & 0 & 0 & 1 \end{bmatrix} \tag{1}
21T=[cosθ2sinθ20a2cosθ2sinθ2cosθ20a2sinθ200100001](2)^{1}_{2}T =\begin{bmatrix} cos\theta_2 & -sin\theta_{2} & 0 & a_{2}cos\theta_{2}\\ sin\theta_{2} & cos\theta_{2} & 0 & a_{2}sin\theta_{2}\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} \tag{2}
32T=[cosθ3sinθ30a3cosθ3sinθ3cosθ30a3sinθ300100001](3)^{2}_{3}T=\begin{bmatrix} cos\theta_{3} & -sin\theta_{3} & 0 & a_{3}cos\theta_{3}\\ sin\theta_{3} & cos\theta_{3} & 0 & a_{3}sin\theta_{3}\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} \tag{3}
43T=[cosθ40sinθ40sinθ40cosθ40010d40001](4)^{3}_{4}T = \begin{bmatrix} cos\theta_{4} & 0 & sin\theta_{4} & 0\\ sin\theta_{4} & 0 & -cos\theta_{4} & 0\\ 0 & 1 & 0 & d_{4}\\ 0 & 0 & 0 & 1 \end{bmatrix} \tag{4}
54T=[cosθ50sinθ50sinθ50cosθ50010d50001](5)^{4}_{5}T =\begin{bmatrix} cos\theta_{5}& 0 & -sin\theta_{5} & 0\\ sin\theta_{5}& 0 & cos\theta_{5} & 0\\ 0& -1 & 0 & d_{5}\\ 0& 0 & 0 & 1 \end{bmatrix} \tag{5}
65T=[cosθ6sinθ600sinθ6cosθ600001d60001](6)^{5}_{6}T=\begin{bmatrix} cos\theta_{6} & -sin\theta_{6} & 0 & 0\\ sin\theta_{6} & cos\theta_{6} & 0 & 0\\ 0 & 0 & 1 & d_{6}\\ 0 & 0 & 0 & 1 \end{bmatrix} \tag{6}
60T=[r11r12r13pxr21r22r23pyr31r32r33pz0001]^{0}_{6}T=\left[\begin{matrix}r_{11} & r_{12} & r_{13} & p_{x}\\r_{21} & r_{22} & r_{23} & p_{y}\\r_{31} & r_{32} & r_{33} & p_{z}\\0 & 0 & 0 & 1\end{matrix}\right]

下面的三个公式无法完整显示,感觉掘金的公式渲染这一块存在bug,希望能尽快修复这个问题。

60T=10T21T32T43T54T65T=[(sin(θ1)sin(θ5)+cos(θ1)cos(θ5)cos(θ2+θ3+θ4))cos(θ6)sin(θ6)sin(θ2+θ3+θ4)cos(θ1)(sin(θ1)sin(θ5)+cos(θ1)cos(θ5)cos(θ2+θ3+θ4))sin(θ6)sin(θ2+θ3+θ4)cos(θ1)cos(θ6)sin(θ1)cos(θ5)sin(θ5)cos(θ1)cos(θ2+θ3+θ4)a2cos(θ1)cos(θ2)+a3cos(θ1)cos(θ2+θ3)+d4sin(θ1)+d5sin(θ2+θ3+θ4)cos(θ1)+d6sin(θ1)cos(θ5)d6sin(θ5)cos(θ1)cos(θ2+θ3+θ4)(sin(θ1)cos(θ5)cos(θ2+θ3+θ4)sin(θ5)cos(θ1))cos(θ6)sin(θ1)sin(θ6)sin(θ2+θ3+θ4)(sin(θ1)cos(θ5)cos(θ2+θ3+θ4)+sin(θ5)cos(θ1))sin(θ6)sin(θ1)sin(θ2+θ3+θ4)cos(θ6)sin(θ1)sin(θ5)cos(θ2+θ3+θ4)cos(θ1)cos(θ5)a2sin(θ1)cos(θ2)+a3sin(θ1)cos(θ2+θ3)d4cos(θ1)+d5sin(θ1)sin(θ2+θ3+θ4)d6sin(θ1)sin(θ5)cos(θ2+θ3+θ4)d6cos(θ1)cos(θ5)sin(θ6)cos(θ2+θ3+θ4)+sin(θ2+θ3+θ4)cos(θ5)cos(θ6)sin(θ6)sin(θ2+θ3+θ4)cos(θ5)+cos(θ6)cos(θ2+θ3+θ4)sin(θ5)sin(θ2+θ3+θ4)a2sin(θ2)+a3sin(θ2+θ3)+d1d5cos(θ2+θ3+θ4)d6sin(θ5)sin(θ2+θ3+θ4)0001]\begin{aligned} ^{0}_{6}T &={^{0}_{1}T}{^{1}_{2}T}{^2_{3}T}{^3_{4}T}{^4_{5}T}{^5_{6}T} \\ &=\left[\begin{matrix}\left(\sin{\left(\theta_{1} \right)} \sin{\left(\theta_{5} \right)} + \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)}\right) \cos{\left(\theta_{6} \right)} - \sin{\left(\theta_{6} \right)} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} \cos{\left(\theta_{1} \right)} & - \left(\sin{\left(\theta_{1} \right)} \sin{\left(\theta_{5} \right)} + \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)}\right) \sin{\left(\theta_{6} \right)} - \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{6} \right)} & \sin{\left(\theta_{1} \right)} \cos{\left(\theta_{5} \right)} - \sin{\left(\theta_{5} \right)} \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} & a_{2} \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{2} \right)} + a_{3} \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)} + d_{4} \sin{\left(\theta_{1} \right)} + d_{5} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} \cos{\left(\theta_{1} \right)} + d_{6} \sin{\left(\theta_{1} \right)} \cos{\left(\theta_{5} \right)} - d_{6} \sin{\left(\theta_{5} \right)} \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)}\\\left(\sin{\left(\theta_{1} \right)} \cos{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} - \sin{\left(\theta_{5} \right)} \cos{\left(\theta_{1} \right)}\right) \cos{\left(\theta_{6} \right)} - \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{6} \right)} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} & \left(- \sin{\left(\theta_{1} \right)} \cos{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} + \sin{\left(\theta_{5} \right)} \cos{\left(\theta_{1} \right)}\right) \sin{\left(\theta_{6} \right)} - \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} \cos{\left(\theta_{6} \right)} & - \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} - \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{5} \right)} & a_{2} \sin{\left(\theta_{1} \right)} \cos{\left(\theta_{2} \right)} + a_{3} \sin{\left(\theta_{1} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)} - d_{4} \cos{\left(\theta_{1} \right)} + d_{5} \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} - d_{6} \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} - d_{6} \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{5} \right)}\\\sin{\left(\theta_{6} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} + \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} \cos{\left(\theta_{5} \right)} \cos{\left(\theta_{6} \right)} & - \sin{\left(\theta_{6} \right)} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} \cos{\left(\theta_{5} \right)} + \cos{\left(\theta_{6} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} & - \sin{\left(\theta_{5} \right)} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} & a_{2} \sin{\left(\theta_{2} \right)} + a_{3} \sin{\left(\theta_{2} + \theta_{3} \right)} + d_{1} - d_{5} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} - d_{6} \sin{\left(\theta_{5} \right)} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)}\\0 & 0 & 0 & 1\end{matrix}\right] \end{aligned}
61Tleft=[r11cos(θ1)+r21sin(θ1)r12cos(θ1)+r22sin(θ1)r13cos(θ1)+r23sin(θ1)pxcos(θ1)+pysin(θ1)r31r32r33d1+pzr11sin(θ1)r21cos(θ1)r12sin(θ1)r22cos(θ1)r13sin(θ1)r23cos(θ1)pxsin(θ1)pycos(θ1)0001]^{1}_{6}T_{left}=\left[\begin{matrix}r_{11} \cos{\left(\theta_{1} \right)} + r_{21} \sin{\left(\theta_{1} \right)} & r_{12} \cos{\left(\theta_{1} \right)} + r_{22} \sin{\left(\theta_{1} \right)} & r_{13} \cos{\left(\theta_{1} \right)} + r_{23} \sin{\left(\theta_{1} \right)} & p_{x} \cos{\left(\theta_{1} \right)} + p_{y}sin(\theta_{1})\\r_{31} & r_{32} & r_{33} & - d_{1} + p_{z}\\r_{11} \sin{\left(\theta_{1} \right)} - r_{21} \cos{\left(\theta_{1} \right)} & r_{12} \sin{\left(\theta_{1} \right)} - r_{22} \cos{\left(\theta_{1} \right)} & r_{13} \sin{\left(\theta_{1} \right)} - r_{23} \cos{\left(\theta_{1} \right)} & p_{x} \sin{\left(\theta_{1} \right)} - p_{y} \cos{\left(\theta_{1} \right)}\\0 & 0 & 0 & 1\end{matrix}\right]
61Tright=[sin(θ6)sin(θ2+θ3+θ4)+cos(θ5)cos(θ6)cos(θ2+θ3+θ4)sin(θ6)cos(θ5)cos(θ2+θ3+θ4)sin(θ2+θ3+θ4)cos(θ6)sin(θ5)cos(θ2+θ3+θ4)a2cos(θ2)+a3cos(θ2+θ3)+d5sin(θ2+θ3+θ4)d6sin(θ5)cos(θ2+θ3+θ4)sin(θ6)cos(θ2+θ3+θ4)+sin(θ2+θ3+θ4)cos(θ5)cos(θ6)sin(θ6)sin(θ2+θ3+θ4)cos(θ5)+cos(θ6)cos(θ2+θ3+θ4)sin(θ5)sin(θ2+θ3+θ4)a2sin(θ2)+a3sin(θ2+θ3)d5cos(θ2+θ3+θ4)d6sin(θ5)sin(θ2+θ3+θ4)sin(θ5)cos(θ6)sin(θ5)sin(θ6)cos(θ5)d4+d6cos(θ5)0001]^{1}_{6}T_{right}=\left[\begin{matrix}- \sin{\left(\theta_{6} \right)} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} + \cos{\left(\theta_{5} \right)} \cos{\left(\theta_{6} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} & - \sin{\left(\theta_{6} \right)} \cos{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} - \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} \cos{\left(\theta_{6} \right)} & - \sin{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} & a_{2} \cos{\left(\theta_{2} \right)} + a_{3} \cos{\left(\theta_{2} + \theta_{3} \right)} + d_{5} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} - d_{6} \sin{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)}\\\sin{\left(\theta_{6} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} + \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} \cos{\left(\theta_{5} \right)} \cos{\left(\theta_{6} \right)} & - \sin{\left(\theta_{6} \right)} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} \cos{\left(\theta_{5} \right)} + \cos{\left(\theta_{6} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} & - \sin{\left(\theta_{5} \right)} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} & a_{2} \sin{\left(\theta_{2} \right)} + a_{3} \sin{\left(\theta_{2} + \theta_{3} \right)} - d_{5} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} - d_{6} \sin{\left(\theta_{5} \right)} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)}\\\sin{\left(\theta_{5} \right)} \cos{\left(\theta_{6} \right)} & - \sin{\left(\theta_{5} \right)} \sin{\left(\theta_{6} \right)} & \cos{\left(\theta_{5} \right)} & d_{4} + d_{6} \cos{\left(\theta_{5} \right)}\\0 & 0 & 0 & 1\end{matrix}\right]

求解第1个关节

联立公式61Tleft^{1}_{6}T_{left}61Tright^{1}_{6}T_{right}中的(3, 3)和(3, 4)元素分别相等,有

{r13sin(θ1)r23cos(θ1)=cos(θ5)d4d6cos(θ5)+pxsin(θ1)pycos(θ1)=0\left\{ \begin{matrix} \begin{aligned} r_{13} \sin{\left(\theta_{1} \right)} - r_{23} \cos{\left(\theta_{1} \right)} &= \cos{\left(\theta_{5} \right)} \\ - d_{4} - d_{6} \cos{\left(\theta_{5} \right)} + p_{x} \sin{\left(\theta_{1} \right)} - p_{y} \cos{\left(\theta_{1} \right)}&=0 \end{aligned} \end{matrix} \right .

消除θ5\theta_{5},有

(d6r23py)cos(θ1)+(pxd6r13)sin(θ1)=d4(d_{6}r_{23}-p_{y})cos(\theta_{1})+(p_{x}-d_{6}r_{13})sin(\theta_{1})=d_{4}

A1=d6r23pyA_{1}=d_{6}r_{23}-p_{y}B1=pxd6r13B_{1}=p_{x}-d_{6}r_{13}C1=d4C_{1}=d_{4}

即公式(9)为 A1cos(θ1)+B1sin(θ1)=C1A_{1}cos(\theta_{1})+B_{1}sin(\theta_{1})=C_{1}

由半角正切公式有

{A1=A12+B12sin(α)sin(α)=A1A12+B12B1=A12+B12cos(α)cos(α)=B1A12+B12\left\{ \begin{matrix} A_{1} &=\sqrt{A_{1}^{2}+B_{1}^{2}}sin(\alpha) \Rightarrow sin(\alpha)=\frac{A_{1}}{\sqrt{A_{1}^{2}+B_{1}^{2}}}\\ B_{1} &=\sqrt{A_{1}^{2}+B_{1}^{2}}cos(\alpha) \Rightarrow cos(\alpha)=\frac{B_{1}}{\sqrt{A_{1}^{2}+B_{1}^{2}}} \end{matrix} \right .

A12+B12sin(α)cos(θ1)+A12+B12cos(α)sin(θ1)=C1\sqrt{A_{1}^{2}+B_{1}^{2}}sin(\alpha)cos(\theta_{1})+\sqrt{A_{1}^{2}+B_{1}^{2}}cos(\alpha)sin(\theta_{1})=C_{1}

从而有

A12+B12sin(α+θ1)=C1sin(α+θ1)=C1A12+B12\sqrt{A_{1}^{2}+B_{1}^{2}}sin(\alpha+\theta_{1})=C_{1} \Rightarrow sin(\alpha+\theta_{1})=\frac{C_{1}}{\sqrt{A_{1}^{2}+B_{1}^{2}}}
cos(α+θ1)=±1sin(α+θ1)2=±A12+B12C12A12+B12cos(\alpha+\theta_{1})=\pm\sqrt{1-sin(\alpha+\theta_{1})^{2}}=\pm\sqrt{\frac{A_{1}^{2}+B_{1}^{2}-C_{1}^{2}}{A_{1}^{2}+B_{1}^{2}}}

综上所述,有

θ1=Atan2(sin(α+θ1),cos(α+θ1))Atan2(sin(α),cos(α))=Atan2(C1,±A12+B12C12)Atan2(A1,B1)(8)\begin{aligned} \theta_{1}&=Atan2(sin(\alpha+\theta_{1}), cos(\alpha+\theta_{1}))-Atan2(sin(\alpha), cos(\alpha)) \\ &=Atan2(C_{1}, \pm\sqrt{A_{1}^{2}+B_{1}^{2}-C_{1}^{2}})-Atan2(A_{1}, B_{1}) \tag{8} \end{aligned}

求解第5个关节

联立公式61Tleft^{1}_{6}T_{left}61Tright^{1}_{6}T_{right}中的(3, 3)元素相等,有

cos(θ5)=r13sin(θ1)r23cos(θ1)\cos{\left(\theta_{5} \right)}=r_{13} \sin{\left(\theta_{1} \right)} - r_{23} \cos{\left(\theta_{1} \right)}

A5=r13sin(θ1)r23cos(θ1)A_{5}=r_{13}sin(\theta_{1})-r_{23}cos(\theta_{1}),有

cos(θ5)=A5sin(θ5)=±1A52cos(\theta_{5})=A_{5} \Rightarrow sin(\theta_{5})=\pm\sqrt{1-A_{5}^{2}}

由半角正切公式,有

θ5=Atan2(sin(θ5),cos(θ5))=Atan2(±1A52,A5)(9)\theta_{5}=Atan2(sin(\theta_{5}), cos(\theta_{5}))=Atan2(\pm\sqrt{1-A_{5}^{2}}, A_{5}) \tag{9}

求解第6个关节

联立公式61Tleft^{1}_{6}T_{left}61Tright^{1}_{6}T_{right}中的(3, 1)和(3, 2)元素分别相等,有

{r11sin(θ1)r21cos(θ1)=sin(θ5)cos(θ6)r12sin(θ1)r22cos(θ1)=sin(θ5)sin(θ6)\left\{ \begin{matrix} \begin{aligned} r_{11} \sin{\left(\theta_{1} \right)} - r_{21} \cos{\left(\theta_{1} \right)} &=\sin{\left(\theta_{5} \right)} \cos{\left(\theta_{6} \right)} \\ r_{12} \sin{\left(\theta_{1} \right)} - r_{22} \cos{\left(\theta_{1} \right)}&=- \sin{\left(\theta_{5} \right)} \sin{\left(\theta_{6} \right)} \end{aligned} \end{matrix} \right.

θ50\theta_{5} \ne 0时,有

{A6=sin(θ6)=r12sin(θ1)+r22cos(θ1)sin(θ5)B6=cos(θ6)=r11sin(θ1)r21cos(θ1)sin(θ5)\left \{ \begin{matrix} \begin{aligned} A_{6}=sin(\theta_{6}) &= \frac{-r_{12}sin(\theta_{1})+r_{22}cos(\theta_{1})}{sin(\theta_{5})} \\ B_{6}=cos(\theta_{6}) &=\frac{r_{11}sin(\theta_{1})-r_{21}cos(\theta_{1})}{sin(\theta_{5})} \end{aligned} \end{matrix} \right.

由半角正切公式,有

θ6=Atan2(sin(θ6),cos(θ6))=Atan2(A6,B6)(10)\theta_{6}=Atan2(sin(\theta_{6}), cos(\theta_{6}))=Atan2(A_{6}, B_{6}) \tag{10}

sin(θ5)=0sin(\theta_{5})=0 时,机器人处于奇异位形,此时关节6轴与2, 3, 4关节轴平行,机器人存在无数组解。

求解第2个关节

联立公式61Tleft^{1}_{6}T_{left}61Tright^{1}_{6}T_{right}中的(1, 3)元素和(2, 3)元素分别相等,有

{r13cos(θ1)+r23sin(θ1)=sin(θ5)cos(θ2+θ3+θ4)r33=sin(θ5)sin(θ2+θ3+θ4)\left\{ \begin{matrix} \begin{aligned} r_{13} \cos{\left(\theta_{1} \right)} + r_{23} \sin{\left(\theta_{1} \right)} &=- \sin{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} \\ r_{33} &=- \sin{\left(\theta_{5} \right)} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} \end{aligned} \end{matrix} \right.

θ50\theta_{5} \ne 0时,有

{A234=sin(θ2+θ3+θ4)=r33sin(θ5)B234=cos(θ2+θ3+θ4)=r13cos(θ1)+r23sin(θ1)sin(θ5)\left\{ \begin{matrix} \begin{aligned} A_{234} &= sin(\theta_{2}+\theta_{3}+\theta_{4}) = -\frac{r_{33}}{sin(\theta_{5})} \\ B_{234} &= cos(\theta_{2}+\theta_{3}+\theta_{4}) =-\frac{r_{13}cos(\theta_{1})+r_{23}sin(\theta_{1})}{sin(\theta_{5})} \end{aligned} \end{matrix} \right.

由半角正切公式,有

θ2+θ3+θ4=Atan2(A234,B234)(11)\theta_{2}+\theta_{3}+\theta_{4}=Atan2(A_{234}, B_{234}) \tag{11}

联立公式61Tleft^{1}_{6}T_{left}61Tright^{1}_{6}T_{right}中的(1, 4)元素和(2, 4)元素分别相等,有

{pxcos(θ1)+pysin(θ1)=a2cos(θ2)+a3cos(θ2+θ3)+d5sin(θ2+θ3+θ4)d6sin(θ5)cos(θ2+θ3+θ4)d1+pz=a2sin(θ2)+a3sin(θ2+θ3)d5cos(θ2+θ3+θ4)d6sin(θ5)sin(θ2+θ3+θ4)\left\{ \begin{matrix} \begin{aligned} p_{x} \cos{\left(\theta_{1} \right)} + p_{y}sin(\theta_{1}) &=a_{2} \cos{\left(\theta_{2} \right)} + a_{3} \cos{\left(\theta_{2} + \theta_{3} \right)} + d_{5} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} - d_{6} \sin{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} \\ - d_{1} + p_{z} &=a_{2} \sin{\left(\theta_{2} \right)} + a_{3} \sin{\left(\theta_{2} + \theta_{3} \right)} - d_{5} \cos{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} - d_{6} \sin{\left(\theta_{5} \right)} \sin{\left(\theta_{2} + \theta_{3} + \theta_{4} \right)} \end{aligned} \end{matrix} \right.

接着,分别定义MMNN,即

{M=a2cos(θ2)+a3cos(θ2+θ3)=pxcos(θ1)+pysin(θ1)d5sin(θ2+θ3+θ4)+d6sin(θ5)cos(θ2+θ3+θ4)N=a2sin(θ2)+a3sin(θ2+θ3)=d1+pz+d5cos(θ2+θ3+θ4)+d6sin(θ5)sin(θ2+θ3+θ4)\left\{ \begin{matrix} \begin{aligned} M &= a_{2}cos(\theta_{2})+a_{3}cos(\theta_{2}+\theta_{3}) \\ &= p_{x}cos(\theta_{1})+p_{y}sin(\theta_{1})-d_{5}sin(\theta_{2}+\theta_{3}+\theta_{4})+d_{6}sin(\theta_{5})cos(\theta_{2}+\theta_{3}+\theta_{4})\\ N &= a_{2}sin(\theta_{2})+a_{3}sin(\theta_{2}+\theta_{3}) \\ &= -d_{1}+p_{z}+d_{5}cos(\theta_{2}+\theta_{3}+\theta_{4})+d_{6}sin(\theta_{5})sin(\theta_{2}+\theta_{3}+\theta_{4}) \end{aligned} \end{matrix} \right.

结合A234A_{234}B234B_{234},可以计算出MMNN的数值

{M2=a22cos(θ2)2+a32cos(θ2+θ3)2+2a2a3cos(θ2)cos(θ2+θ3)N2=a22sin(θ2)2+a32sin(θ2+θ3)2+2a2a3sin(θ2)sin(θ2+θ3)\left\{ \begin{matrix} \begin{aligned} M^{2} &= a_{2}^{2}cos(\theta_{2})^{2}+a_{3}^{2}cos(\theta_{2}+\theta_{3})^{2}+2a_{2}a_{3}cos(\theta_{2})cos(\theta_{2}+\theta_{3}) \\ N^{2} &= a_{2}^{2}sin(\theta_{2})^{2}+a_{3}^{2}sin(\theta_{2}+\theta_{3})^{2}+2a_{2}a_{3}sin(\theta_{2})sin(\theta_{2}+\theta_{3}) \end{aligned} \end{matrix} \right.
{L=Mcos(θ2)+Nsin(θ2)=a2cos(θ2)2+a3cos(θ2)cos(θ2+θ3)+a2sin(θ2)2+a3sin(θ2)sin(θ2+θ3)\left\{ \begin{matrix} \begin{aligned} L &= M cos(\theta_{2}) + N sin(\theta_{2}) \\ &= a_{2}cos(\theta_{2})^{2}+a_{3}cos(\theta_{2})cos(\theta_{2}+\theta_{3})+a_{2}sin(\theta_{2})^{2}+a_{3}sin(\theta_{2})sin(\theta_{2}+\theta_{3}) \end{aligned} \end{matrix} \right.

由于

M2+N2a22a32=2a2(La2)=2a2(Mcos(θ2)+Nsin(θ2)a2)\begin{aligned} M^{2}+N^{2}-a_{2}^{2}-a_{3}^{2}&=2a_{2}(L-a_{2}) \\ &=2a_{2}(Mcos(\theta_{2})+Nsin(\theta_{2})-a_{2}) \end{aligned}

代入LL,化简可得

L=Mcos(θ2)+Nsin(θ2)=M2+N2a22a322a2+a2=M2+N2+a22a322a2L = Mcos(\theta_{2})+Nsin(\theta_{2})=\frac{M^{2}+N^{2}-a_{2}^{2}-a_{3}^{2}}{2a_{2}}+a_{2} = \frac{M^{2}+N^{2}+a_{2}^{2}-a_{3}^{2}}{2a_{2}}

A2=MA_{2}=MB2=NB_{2}=NC2=L=M2+N2+a22a322a2C_{2}=L=\frac{M^{2}+N^{2}+a_{2}^{2}-a_{3}^{2}}{2a_{2}}

A2cos(θ2)+B2sin(θ2)=C2A_{2}cos(\theta_{2})+B_{2}sin(\theta_{2})=C_{2}

A2=A2+B2sin(α)sin(α)=A2A2+B2B2=A2+B2cos(α)cos(α)=B2A2+B2A_{2}=\sqrt{A_{2}+B_{2}}sin(\alpha) \Rightarrow sin(\alpha)=\frac{A_{2}}{\sqrt{A_{2}+B_{2}}}\\ B_{2}=\sqrt{A_{2}+B_{2}}cos(\alpha) \Rightarrow cos(\alpha)=\frac{B_{2}}{\sqrt{A_{2}+B_{2}}}

因此,有

α=Atan2(sin(α),cos(α))=Atan2(A2,B2)\alpha=Atan2(sin(\alpha), cos(\alpha))=Atan2(A_{2}, B_{2})
A2+B2sin(α)cos(θ2)+A2+B2cos(α)sin(θ2)=C2\sqrt{A_{2}+B_{2}}sin(\alpha)cos(\theta_{2})+\sqrt{A_{2}+B_{2}}cos(\alpha)sin(\theta_{2})=C_{2}

A2+B2sin(α+θ2)=C2\sqrt{A_{2}+B_{2}}sin(\alpha+\theta_{2})=C_{2}
sin(α+θ2)=C2A2+B2sin(\alpha+\theta_{2})=\frac{C_{2}}{\sqrt{A_{2}+B_{2}}}
cos(α+θ2)=±A2+B2C2A2+B2cos(\alpha+\theta_{2})=\pm\frac{\sqrt{A_{2}+B_{2}-C_{2}}}{\sqrt{A_{2}+B_{2}}}
θ2=Atan2(sin(α+θ2),cos(α+θ2))Atan2(sin(α),cos(α))=Atan2(C2,±A2+B2C2)Atan2(A2,B2)\begin{aligned} \theta_{2}&=Atan2(sin(\alpha+\theta_{2}), cos(\alpha+\theta_{2}))-Atan2(sin(\alpha), cos(\alpha))\\ &=Atan2(C_{2}, \pm\sqrt{A_{2}+B_{2}-C_{2}})-Atan2(A_{2}, B_{2}) \end{aligned}

求解第3个关节

由于

{M=a2cos(θ2)+a3cos(θ2+θ3)N=a2sin(θ2)+a3sin(θ2+θ3)\left\{ \begin{matrix} \begin{aligned} M &= a_{2}cos(\theta_{2})+a_{3}cos(\theta_{2}+\theta_{3}) \\ N &= a_{2}sin(\theta_{2})+a_{3}sin(\theta_{2}+\theta_{3}) \end{aligned} \end{matrix} \right.

{A23=sin(θ2+θ3)=Na2sin(θ2)a3B23=cos(θ2+θ3)=Ma2cos(θ2)a3\left\{ \begin{matrix} \begin{aligned} A_{23} &=sin(\theta_{2}+\theta_{3}) = \frac{N-a_{2}sin(\theta_{2})}{a_{3}} \\ B_{23} &=cos(\theta_{2}+\theta_{3}) = \frac{M-a_{2}cos(\theta_{2}) }{a_{3}} \end{aligned} \end{matrix} \right.

由半角正切公式,有

θ2+θ3=Atan2(sin(θ2+θ3),cos(θ2+θ3))=Atan2(A23,B23)\theta_{2}+\theta_{3}=Atan2(sin(\theta_{2}+\theta_{3}), cos(\theta_{2}+\theta_{3}))=Atan2(A_{23}, B_{23})

θ3=Atan2(A23,B23)θ2\theta_{3} = Atan2(A_{23}, B_{23}) - \theta_{2}

求解第4个关节

θ4=Atan2(A234,B234)Atan2(A23,B23)\theta_{4}=Atan2(A_{234}, B_{234}) -Atan2(A_{23}, B_{23})

至此,UR机器人的所有6个关节的求解公式推导完毕。下一篇文章,我将重点介绍如何基于本文推导的公式,使用C++编程实现UR机器人的封闭逆解算法。