当前位置:   article > 正文

通用DH的逆运动学符号运算_dh矩阵求逆

dh矩阵求逆

通用HD的逆运动学符号运算

这里想说一个问题呀,初学东西还是应该首先看认可度高的书或者官方文档,至少要知道他们所用方法的思想是什么,不要动不动就上博客知乎,尤其csdn对于我是一个初学记录与分享平台,相信很多朋友和我一样,但是初学记录的东西不一定正确、全面或者方法不是最佳的,很可能误导小白。自己不爱看书做事急躁,科研习惯差,完全是这种坏习惯的受害者,还是应该在知道经典方法的前提下根据实际情况应用自己的方法

最近又有一个活:对我们自己设计的机械臂进行逆运动学推导( 这次是修正DH )

附上一个我认为的修正DH最强表述,来自B站台湾大学林沛群老师课程

在这里插入图片描述
对于修正DH
在这里插入图片描述

正运动学:
在这里插入图片描述
利用符号运算计算 Transformation Matrix

import sympy as sym
from sympy import sin,cos
import math
from sympy.matrices import Matrix 

pi=math.pi
#DH参数
a=[0,0,280,100,0,0]
alpha=[0,-pi/2 ,0,pi/2,-pi/2 ,pi/2]
d=[210,0,0,-220,0,180]

theta = sym.symbols('theta')


for i in range(6):
    
    cos_alpha=round(cos(alpha[i]), 4)
    sin_alpha=round(sin(alpha[i]), 4)
    theta = sym.symbols('theta'+chr(i+49))
    #除0外,di暂时用符号来表示
    if a[i]==0:
        ai=0
    else:
        a_i='a'+chr(i+49) 
        ai = sym.symbols(a_i)
    if d[i]==0:
        di=0
    else:
        d_i='d'+chr(i+49)  
        di = sym.symbols(d_i)
    T1=cos(theta)
    T2=-sin(theta)
    T3=0
    T4=ai
    T5=sin(theta)*cos_alpha
    T6=cos(theta)*cos_alpha
    T7=-sin_alpha
    T8=-sin_alpha*di
    T9=sin(theta)*sin_alpha
    T10=cos(theta)*sin_alpha
    T11=cos_alpha
    T12=cos_alpha*di
    T13=0
    T14=0
    T15=0
    T16=1

    m=Matrix([[T1,T2,T3,T4],[T5,T6,T7,T8],[T9,T10,T11,T12],[T3,T14,T15,T16]])
    print('\n') 
    print(sym.latex(m))
    print('\n') 

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52

1 0 T = [ cos ⁡ ( θ 1 ) − sin ⁡ ( θ 1 ) 0 0 sin ⁡ ( θ 1 ) cos ⁡ ( θ 1 ) 0 0 0 0 1 d 1 0 0 0 1 ] ^{0}_1T=\left[

cos(θ1)sin(θ1)00sin(θ1)cos(θ1)00001d10001
\right] 10T=cos(θ1)sin(θ1)00sin(θ1)cos(θ1)00001000d11

2 1 T = [ cos ⁡ ( θ 2 ) − sin ⁡ ( θ 2 ) 0 0 0 0 1.0 0 − 1.0 sin ⁡ ( θ 2 ) − 1.0 cos ⁡ ( θ 2 ) 0 0 0 0 0 1 ] ^{1}_2T=\left[

cos(θ2)sin(θ2)00001.001.0sin(θ2)1.0cos(θ2)000001
\right] 21T=cos(θ2)01.0sin(θ2)0sin(θ2)01.0cos(θ2)001.0000001

3 2 T = [ cos ⁡ ( θ 3 ) − sin ⁡ ( θ 3 ) 0 a 3 sin ⁡ ( θ 3 ) cos ⁡ ( θ 3 ) 0 0 0 0 1 0 0 0 0 1 ] ^{2}_3T=\left[

cos(θ3)sin(θ3)0a3sin(θ3)cos(θ3)0000100001
\right] 32T=cos(θ3)sin(θ3)00sin(θ3)cos(θ3)000010a3001

4 3 T = [ cos ⁡ ( θ 4 ) − sin ⁡ ( θ 4 ) 0 a 4 0 0 − 1.0 − 1.0 d 4 1.0 sin ⁡ ( θ 4 ) 1.0 cos ⁡ ( θ 4 ) 0 0 0 0 0 1 ] ^{3}_4T=\left[

cos(θ4)sin(θ4)0a4001.01.0d41.0sin(θ4)1.0cos(θ4)000001
\right] 43T=cos(θ4)01.0sin(θ4)0sin(θ4)01.0cos(θ4)001.000a41.0d401

5 4 T = [ cos ⁡ ( θ 5 ) − sin ⁡ ( θ 5 ) 0 0 0 0 1.0 0 − 1.0 sin ⁡ ( θ 5 ) − 1.0 cos ⁡ ( θ 5 ) 0 0 0 0 0 1 ] ^{4}_5T=\left[

cos(θ5)sin(θ5)00001.001.0sin(θ5)1.0cos(θ5)000001
\right] 54T=cos(θ5)01.0sin(θ5)0sin(θ5)01.0cos(θ5)001.0000001

6 5 T = [ cos ⁡ ( θ 6 ) − sin ⁡ ( θ 6 ) 0 0 0 0 − 1.0 − 1.0 d 6 1.0 sin ⁡ ( θ 6 ) 1.0 cos ⁡ ( θ 6 ) 0 0 0 0 0 1 ] ^{5}_6T=\left[

cos(θ6)sin(θ6)00001.01.0d61.0sin(θ6)1.0cos(θ6)000001
\right] 65T=cos(θ6)01.0sin(θ6)0sin(θ6)01.0cos(θ6)001.00001.0d601

T = 1 0 T 2 1 T 3 2 T 4 3 T 5 4 T 6 5 T = T=^{0}_1T^{1}_2T^{2}_3T^{3}_4T^{4}_5T^{5}_6T= T=10T21T32T43T54T65T= [ 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 ]

[nxoxaxpxnyoyaypynzozazpz0001]
nxnynz0oxoyoz0axayaz0pxpypz1

旋转矩阵连乘后的矩阵取每个元素:

for i in range(4):
    for j in range(4):
        print('\n') 
        print(i,j) 
        print('\n') 
        print(sym.latex(sym.simplify(m[i,j])))
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

(这里不知道simplfy是不是最简)得到:

n x = − ( ( 1.0 sin ⁡ ( θ 1 ) sin ⁡ ( θ 4 ) − cos ⁡ ( θ 1 ) cos ⁡ ( θ 4 ) cos ⁡ ( θ 2 + θ 3 ) ) cos ⁡ ( θ 5 ) + 1.0 sin ⁡ ( θ 5 ) sin ⁡ ( θ 2 + θ 3 ) cos ⁡ ( θ 1 ) ) cos ⁡ ( θ 6 ) − 1.0 ( sin ⁡ ( θ 1 ) cos ⁡ ( θ 4 ) + sin ⁡ ( θ 4 ) cos ⁡ ( θ 1 ) cos ⁡ ( θ 2 + θ 3 ) ) sin ⁡ ( θ 6 ) n_x=- \left(\left(1.0 \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{4} \right)} - \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{4} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)}\right) \cos{\left(\theta_{5} \right)} + 1.0 \sin{\left(\theta_{5} \right)} \sin{\left(\theta_{2} + \theta_{3} \right)} \cos{\left(\theta_{1} \right)}\right) \cos{\left(\theta_{6} \right)} - 1.0 \left(\sin{\left(\theta_{1} \right)} \cos{\left(\theta_{4} \right)} + \sin{\left(\theta_{4} \right)} \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)}\right) \sin{\left(\theta_{6} \right)} nx=((1.0sin(θ1)sin(θ4)cos(θ1)cos(θ4)cos(θ2+θ3))cos(θ5)+1.0sin(θ5)sin(θ2+θ3)cos(θ1))cos(θ6)1.0(sin(θ1)cos(θ4)+sin(θ4)cos(θ1)cos(θ2+θ3))sin(θ6)

o x = ( ( 1.0 sin ⁡ ( θ 1 ) sin ⁡ ( θ 4 ) − cos ⁡ ( θ 1 ) cos ⁡ ( θ 4 ) cos ⁡ ( θ 2 + θ 3 ) ) cos ⁡ ( θ 5 ) + 1.0 sin ⁡ ( θ 5 ) sin ⁡ ( θ 2 + θ 3 ) cos ⁡ ( θ 1 ) ) sin ⁡ ( θ 6 ) − 1.0 ( sin ⁡ ( θ 1 ) cos ⁡ ( θ 4 ) + sin ⁡ ( θ 4 ) cos ⁡ ( θ 1 ) cos ⁡ ( θ 2 + θ 3 ) ) cos ⁡ ( θ 6 ) o_x=\left(\left(1.0 \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{4} \right)} - \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{4} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)}\right) \cos{\left(\theta_{5} \right)} + 1.0 \sin{\left(\theta_{5} \right)} \sin{\left(\theta_{2} + \theta_{3} \right)} \cos{\left(\theta_{1} \right)}\right) \sin{\left(\theta_{6} \right)} - 1.0 \left(\sin{\left(\theta_{1} \right)} \cos{\left(\theta_{4} \right)} + \sin{\left(\theta_{4} \right)} \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)}\right) \cos{\left(\theta_{6} \right)} ox=((1.0sin(θ1)sin(θ4)cos(θ1)cos(θ4)cos(θ2+θ3))cos(θ5)+1.0sin(θ5)sin(θ2+θ3)cos(θ1))sin(θ6)1.0(sin(θ1)cos(θ4)+sin(θ4)cos(θ1)cos(θ2+θ3))cos(θ6)

a x = − 1.0 ⋅ ( 1.0 sin ⁡ ( θ 1 ) sin ⁡ ( θ 4 ) − cos ⁡ ( θ 1 ) cos ⁡ ( θ 4 ) cos ⁡ ( θ 2 + θ 3 ) ) sin ⁡ ( θ 5 ) + 1.0 sin ⁡ ( θ 2 + θ 3 ) cos ⁡ ( θ 1 ) cos ⁡ ( θ 5 ) a_x=- 1.0 \cdot \left(1.0 \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{4} \right)} - \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{4} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)}\right) \sin{\left(\theta_{5} \right)} + 1.0 \sin{\left(\theta_{2} + \theta_{3} \right)} \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{5} \right)} ax=1.0(1.0sin(θ1)sin(θ4)cos(θ1)cos(θ4)cos(θ2+θ3))sin(θ5)+1.0sin(θ2+θ3)cos(θ1)cos(θ5)

n y = 1.0 ( ( sin ⁡ ( θ 1 ) cos ⁡ ( θ 4 ) cos ⁡ ( θ 2 + θ 3 ) + sin ⁡ ( θ 4 ) cos ⁡ ( θ 1 ) ) cos ⁡ ( θ 5 ) − sin ⁡ ( θ 1 ) sin ⁡ ( θ 5 ) sin ⁡ ( θ 2 + θ 3 ) ) cos ⁡ ( θ 6 ) − 1.0 ( sin ⁡ ( θ 1 ) sin ⁡ ( θ 4 ) cos ⁡ ( θ 2 + θ 3 ) − cos ⁡ ( θ 1 ) cos ⁡ ( θ 4 ) ) sin ⁡ ( θ 6 ) n_y=1.0 \left(\left(\sin{\left(\theta_{1} \right)} \cos{\left(\theta_{4} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)} + \sin{\left(\theta_{4} \right)} \cos{\left(\theta_{1} \right)}\right) \cos{\left(\theta_{5} \right)} - \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{5} \right)} \sin{\left(\theta_{2} + \theta_{3} \right)}\right) \cos{\left(\theta_{6} \right)} - 1.0 \left(\sin{\left(\theta_{1} \right)} \sin{\left(\theta_{4} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)} - \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{4} \right)}\right) \sin{\left(\theta_{6} \right)} ny=1.0((sin(θ1)cos(θ4)cos(θ2+θ3)+sin(θ4)cos(θ1))cos(θ5)sin(θ1)sin(θ5)sin(θ2+θ3))cos(θ6)1.0(sin(θ1)sin(θ4)cos(θ2+θ3)cos(θ1)cos(θ4))sin(θ6)

o y = 1.0 ( − ( sin ⁡ ( θ 1 ) cos ⁡ ( θ 4 ) cos ⁡ ( θ 2 + θ 3 ) + sin ⁡ ( θ 4 ) cos ⁡ ( θ 1 ) ) cos ⁡ ( θ 5 ) + sin ⁡ ( θ 1 ) sin ⁡ ( θ 5 ) sin ⁡ ( θ 2 + θ 3 ) ) sin ⁡ ( θ 6 ) + 1.0 ( − sin ⁡ ( θ 1 ) sin ⁡ ( θ 4 ) cos ⁡ ( θ 2 + θ 3 ) + cos ⁡ ( θ 1 ) cos ⁡ ( θ 4 ) ) cos ⁡ ( θ 6 ) o_y=1.0 \left(- \left(\sin{\left(\theta_{1} \right)} \cos{\left(\theta_{4} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)} + \sin{\left(\theta_{4} \right)} \cos{\left(\theta_{1} \right)}\right) \cos{\left(\theta_{5} \right)} + \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{5} \right)} \sin{\left(\theta_{2} + \theta_{3} \right)}\right) \sin{\left(\theta_{6} \right)} + 1.0 \left(- \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{4} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)} + \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{4} \right)}\right) \cos{\left(\theta_{6} \right)} oy=1.0((sin(θ1)cos(θ4)cos(θ2+θ3)+sin(θ4)cos(θ1))cos(θ5)+sin(θ1)sin(θ5)sin(θ2+θ3))sin(θ6)+1.0(sin(θ1)sin(θ4)cos(θ2+θ3)+cos(θ1)cos(θ4))cos(θ6)

a y = 1.0 ( sin ⁡ ( θ 1 ) cos ⁡ ( θ 4 ) cos ⁡ ( θ 2 + θ 3 ) + sin ⁡ ( θ 4 ) cos ⁡ ( θ 1 ) ) sin ⁡ ( θ 5 ) + 1.0 sin ⁡ ( θ 1 ) sin ⁡ ( θ 2 + θ 3 ) cos ⁡ ( θ 5 ) a_y=1.0 \left(\sin{\left(\theta_{1} \right)} \cos{\left(\theta_{4} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)} + \sin{\left(\theta_{4} \right)} \cos{\left(\theta_{1} \right)}\right) \sin{\left(\theta_{5} \right)} + 1.0 \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{2} + \theta_{3} \right)} \cos{\left(\theta_{5} \right)} ay=1.0(sin(θ1)cos(θ4)cos(θ2+θ3)+sin(θ4)cos(θ1))sin(θ5)+1.0sin(θ1)sin(θ2+θ3)cos(θ5)

n z = − 1.0 ( sin ⁡ ( θ 5 ) cos ⁡ ( θ 2 + θ 3 ) + sin ⁡ ( θ 2 + θ 3 ) cos ⁡ ( θ 4 ) cos ⁡ ( θ 5 ) ) cos ⁡ ( θ 6 ) + 1.0 sin ⁡ ( θ 4 ) sin ⁡ ( θ 6 ) sin ⁡ ( θ 2 + θ 3 ) n_z=- 1.0 \left(\sin{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)} + \sin{\left(\theta_{2} + \theta_{3} \right)} \cos{\left(\theta_{4} \right)} \cos{\left(\theta_{5} \right)}\right) \cos{\left(\theta_{6} \right)} + 1.0 \sin{\left(\theta_{4} \right)} \sin{\left(\theta_{6} \right)} \sin{\left(\theta_{2} + \theta_{3} \right)} nz=1.0(sin(θ5)cos(θ2+θ3)+sin(θ2+θ3)cos(θ4)cos(θ5))cos(θ6)+1.0sin(θ4)sin(θ6)sin(θ2+θ3)

o z = 1.0 ( sin ⁡ ( θ 5 ) cos ⁡ ( θ 2 + θ 3 ) + sin ⁡ ( θ 2 + θ 3 ) cos ⁡ ( θ 4 ) cos ⁡ ( θ 5 ) ) sin ⁡ ( θ 6 ) + 1.0 sin ⁡ ( θ 4 ) sin ⁡ ( θ 2 + θ 3 ) cos ⁡ ( θ 6 ) o_z=1.0 \left(\sin{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)} + \sin{\left(\theta_{2} + \theta_{3} \right)} \cos{\left(\theta_{4} \right)} \cos{\left(\theta_{5} \right)}\right) \sin{\left(\theta_{6} \right)} + 1.0 \sin{\left(\theta_{4} \right)} \sin{\left(\theta_{2} + \theta_{3} \right)} \cos{\left(\theta_{6} \right)} oz=1.0(sin(θ5)cos(θ2+θ3)+sin(θ2+θ3)cos(θ4)cos(θ5))sin(θ6)+1.0sin(θ4)sin(θ2+θ3)cos(θ6)

a z = − 1.0 sin ⁡ ( θ 5 ) sin ⁡ ( θ 2 + θ 3 ) cos ⁡ ( θ 4 ) + 1.0 cos ⁡ ( θ 5 ) cos ⁡ ( θ 2 + θ 3 ) a_z=- 1.0 \sin{\left(\theta_{5} \right)} \sin{\left(\theta_{2} + \theta_{3} \right)} \cos{\left(\theta_{4} \right)} + 1.0 \cos{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)} az=1.0sin(θ5)sin(θ2+θ3)cos(θ4)+1.0cos(θ5)cos(θ2+θ3)

p x = a 3 cos ⁡ ( θ 1 ) cos ⁡ ( θ 2 ) + a 4 cos ⁡ ( θ 1 ) cos ⁡ ( θ 2 + θ 3 ) + 1.0 d 4 sin ⁡ ( θ 2 + θ 3 ) cos ⁡ ( θ 1 ) − 1.0 d 6 ( ( 1.0 sin ⁡ ( θ 1 ) sin ⁡ ( θ 4 ) − cos ⁡ ( θ 1 ) cos ⁡ ( θ 4 ) cos ⁡ ( θ 2 + θ 3 ) ) sin ⁡ ( θ 5 ) − 1.0 sin ⁡ ( θ 2 + θ 3 ) cos ⁡ ( θ 1 ) cos ⁡ ( θ 5 ) ) p_x=a_{3} \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{2} \right)} + a_{4} \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)} + 1.0 d_{4} \sin{\left(\theta_{2} + \theta_{3} \right)} \cos{\left(\theta_{1} \right)} - 1.0 d_{6} \left(\left(1.0 \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{4} \right)} - \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{4} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)}\right) \sin{\left(\theta_{5} \right)} - 1.0 \sin{\left(\theta_{2} + \theta_{3} \right)} \cos{\left(\theta_{1} \right)} \cos{\left(\theta_{5} \right)}\right) px=a3cos(θ1)cos(θ2)+a4cos(θ1)cos(θ2+θ3)+1.0d4sin(θ2+θ3)cos(θ1)1.0d6((1.0sin(θ1)sin(θ4)cos(θ1)cos(θ4)cos(θ2+θ3))sin(θ5)1.0sin(θ2+θ3)cos(θ1)cos(θ5))

p y = a 3 sin ⁡ ( θ 1 ) cos ⁡ ( θ 2 ) + a 4 sin ⁡ ( θ 1 ) cos ⁡ ( θ 2 + θ 3 ) + 1.0 d 4 sin ⁡ ( θ 1 ) sin ⁡ ( θ 2 + θ 3 ) + 1.0 d 6 ( ( sin ⁡ ( θ 1 ) cos ⁡ ( θ 4 ) cos ⁡ ( θ 2 + θ 3 ) + sin ⁡ ( θ 4 ) cos ⁡ ( θ 1 ) ) sin ⁡ ( θ 5 ) + sin ⁡ ( θ 1 ) sin ⁡ ( θ 2 + θ 3 ) cos ⁡ ( θ 5 ) ) p_y=a_{3} \sin{\left(\theta_{1} \right)} \cos{\left(\theta_{2} \right)} + a_{4} \sin{\left(\theta_{1} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)} + 1.0 d_{4} \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{2} + \theta_{3} \right)} + 1.0 d_{6} \left(\left(\sin{\left(\theta_{1} \right)} \cos{\left(\theta_{4} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)} + \sin{\left(\theta_{4} \right)} \cos{\left(\theta_{1} \right)}\right) \sin{\left(\theta_{5} \right)} + \sin{\left(\theta_{1} \right)} \sin{\left(\theta_{2} + \theta_{3} \right)} \cos{\left(\theta_{5} \right)}\right) py=a3sin(θ1)cos(θ2)+a4sin(θ1)cos(θ2+θ3)+1.0d4sin(θ1)sin(θ2+θ3)+1.0d6((sin(θ1)cos(θ4)cos(θ2+θ3)+sin(θ4)cos(θ1))sin(θ5)+sin(θ1)sin(θ2+θ3)cos(θ5))

p z = − 1.0 a 3 sin ⁡ ( θ 2 ) − 1.0 a 4 sin ⁡ ( θ 2 + θ 3 ) + 1.0 d 1 + 1.0 d 4 cos ⁡ ( θ 2 + θ 3 ) − 1.0 d 6 sin ⁡ ( θ 5 ) sin ⁡ ( θ 2 + θ 3 ) cos ⁡ ( θ 4 ) + 1.0 d 6 cos ⁡ ( θ 5 ) cos ⁡ ( θ 2 + θ 3 ) p_z=- 1.0 a_{3} \sin{\left(\theta_{2} \right)} - 1.0 a_{4} \sin{\left(\theta_{2} + \theta_{3} \right)} + 1.0 d_{1} + 1.0 d_{4} \cos{\left(\theta_{2} + \theta_{3} \right)} - 1.0 d_{6} \sin{\left(\theta_{5} \right)} \sin{\left(\theta_{2} + \theta_{3} \right)} \cos{\left(\theta_{4} \right)} + 1.0 d_{6} \cos{\left(\theta_{5} \right)} \cos{\left(\theta_{2} + \theta_{3} \right)} pz=1.0a3sin(θ2)1.0a4sin(θ2+θ3)+1.0d1+1.0d4cos(θ2+θ3)1.0d6sin(θ5)sin(θ2+θ3)cos(θ4)+1.0d6cos(θ5)cos(θ2+θ3)

正运动学

我们由末端位置与(ZYZ)姿态欧拉角和旋转矩阵的关系求解正运动学

T = [ c α c β c γ − s α s γ − c α c β s γ − s α c γ c α s β p x s α c β c γ + c α s γ − s α c β c γ + c α c γ s α s β p y − s β c γ s β s γ c β p z 0 0 0 1 ] T=

[cαcβcγsαsγcαcβsγsαcγcαsβpxsαcβcγ+cαsγsαcβcγ+cαcγsαsβpysβcγsβsγcβpz0001]
T=cαcβcγsαsγsαcβcγ+cαsγsβcγ0cαcβsγsαcγsαcβcγ+cαcγsβsγ0cαsβsαsβcβ0pxpypz1 = [ 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 ]
[nxoxaxpxnyoyaypynzozazpz0001]
nxnynz0oxoyoz0axayaz0pxpypz1

逆运动学

角度求解 θ 1 \theta_1 θ1:
由:

1 0 T − 1 T = 2 1 T 3 2 T 4 3 T 5 4 T 6 5 T ^{0}_1T^{-1}T=^{1}_2T ^{2}_3T^{3}_4T^{4}_5T^{5}_6T 10T1T=21T32T43T54T65T

= [ n x c 1 + n y s 1 o x c 1 + o y s 1 a x c 1 + a y s 1 p x c 1 + p y s 1 − n x s 1 + n y c 1 − o x s 1 + o y c 1 − a x s 1 + a y c 1 − p x s 1 + p y c 1 n z o z a z − d 1 + p z 0 0 0 1 ] = =

[nxc1+nys1oxc1+oys1axc1+ays1pxc1+pys1nxs1+nyc1oxs1+oyc1axs1+ayc1pxs1+pyc1nzozazd1+pz0001]
= =nxc1+nys1nxs1+nyc1nz0oxc1+oys1oxs1+oyc1oz0axc1+ays1axs1+ayc1az0pxc1+pys1pxs1+pyc1d1+pz1=

[ s 5 c 6 s 23 − c 4 c 5 c 6 c 23 − s 4 s 6 c 23 s 5 s 6 s 23 − c 4 c 5 s 6 c 23 − s 4 c 6 c 23 s 5 c 4 c 23 + s 23 c 5 a 3 c 2 + a 4 c 23 + d 4 s 23 + d 6 s 5 c 4 c 23 + d 6 s 23 c 5 s 4 c 5 c 6 + s 6 c 4 s 4 c 5 s 6 + c 6 c 4 s 4 s 5 d 6 s 4 s 5 s 5 c 6 c 23 + c 4 c 5 c 6 s 23 + s 4 s 6 s 23 s 5 s 6 c 23 + c 4 c 5 s 6 s 23 + s 4 c 6 s 23 s 5 c 4 s 23 + c 5 c 23 a 3 s 2 − a 4 s 23 + d 4 c 23 − d 6 s 5 c 4 s 23 + d 6 c 5 c 23 0 0 0 1 ]

[s5c6s23c4c5c6c23s4s6c23s5s6s23c4c5s6c23s4c6c23s5c4c23+s23c5a3c2+a4c23+d4s23+d6s5c4c23+d6s23c5s4c5c6+s6c4s4c5s6+c6c4s4s5d6s4s5s5c6c23+c4c5c6s23+s4s6s23s5s6c23+c4c5s6s23+s4c6s23s5c4s23+c5c23a3s2a4s23+d4c23d6s5c4s23+d6c5c230001]
s5c6s23c4c5c6c23s4s6c23s4c5c6+s6c4s5c6c23+c4c5c6s23+s4s6s230s5s6s23c4c5s6c23s4c6c23s4c5s6+c6c4s5s6c23+c4c5s6s23+s4c6s230s5c4c23+s23c5s4s5s5c4s23+c5c230a3c2+a4c23+d4s23+d6s5c4c23+d6s23c5d6s4s5a3s2a4s23+d4c23d6s5c4s23+d6c5c231

得:

d 6 ( − a x s 1 + a y c 1 ) = − p x s 1 + p y c 1 d_6(-a_xs_1+a_yc_1)=-p_xs_1+p_yc_1 d6(axs1+ayc1)=pxs1+pyc1

( − a x d 6 + p x ) s 1 − ( p y − d 6 a y ) c 1 = 0 (-a_xd_6+p_x)s_1-(p_y-d_6a_y)c_1=0 (axd6+px)s1(pyd6ay)c1=0

总能找到一个分母 m m m

s i n ϕ = − a x d 6 + p x m , c o s ϕ = p y − d 6 a y m sin{\phi}=\frac{-a_xd_6+p_x}{m},cos{\phi}=\frac{p_y-d_6a_y}{m} sinϕ=maxd6+pxcosϕ=mpyd6ay
s i n ( θ 1 − ϕ ) = 0 sin(\theta_1-\phi)=0 sin(θ1ϕ)=0
c o s ( θ 1 − ϕ ) = ± 1 cos(\theta_1-\phi)=±1 cos(θ1ϕ)=±1
θ 1 = a t a n 2 ( s i n ( ϕ ) , c o s ( ϕ ) ) + a t a n 2 ( 0 , ± 1 ) \theta_1=atan2(sin({\phi}),cos(\phi))+atan2(0,±1) θ1=atan2(sin(ϕ)cos(ϕ))+atan2(0±1)

角度求解 θ 2 \theta_2 θ2:


同理求解 θ 3 、 θ 4 . . . . . . . θ 6 \theta_3、\theta_4.......\theta_6 θ3θ4.......θ6

通用的代码的应用就到这里,感兴趣的同学可以尝试继续用smypy解出 θ \theta θ

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/96680
推荐阅读