0


【Matlab 六自由度机器人】运动学逆解(附MATLAB机器人逆解代码)

【Matlab 六自由度机器人】求运动学逆解

往期回顾

【汇总】

相关资源:

  1. Matlab 六自由度机器人】系列文章汇总
  2. \fcolorbox{green}{aqua}{【Matlab 六自由度机器人】系列文章汇总 }
  3. Matlab 六自由度机器人】系列文章汇总

【主线】

  1. 定义标准型及改进型D-H参数,建立机器人模型。
  2. 运动学正解
  3. 基于蒙特卡罗方法(Monte Carlo Method)构建机器人工作空间

【补充说明】

  1. 关于灵活工作空间与可达工作空间的理解
  2. 关于改进型D-H参数(modified Denavit-Hartenberg)的详细建立步骤
  3. 关于旋转的参数化(欧拉角、姿态角、四元数)的相关问题
  4. 关于双变量函数atan2(x,y)的解释
  5. 关于机器人运动学反解的有关问题

前言

本篇介绍机器人逆运动学及逆解的求解方法,首先介绍如何理解逆向运动学,并利用D-H参数及正向运动学的齐次变换矩阵对机器人运动学逆解进行求解。

在博主读研期间,刚开始对机器人运动学逆解不甚了解,但在经历一次自己完全去钻研、尝试,独立写出属于自己的运动学逆解后,对机器人的结构有更加深刻的理解。因此希望初学机器人的朋友们也能够尝试独立去编写、尝试出自己的逆解代码,我相信,当你看到逆解解出的角度完全符合预期,也能够产生相当的成就感。


下面是运动学逆解的正文内容,主要讲述运动学逆解的方式和公式推算,最后进行代码的实现。

正文

一、运动学逆解

首先我们已经建立起了一个六自由度的机器人,在 D-H 参数 及机器人的 期望位姿 已知的情况下,求解机器人满足该期望位姿的各个关节变量,这种求解过程叫做机器人运动学逆解过程。求解机器人的逆运动学解法分为封闭解法和数值解法两种,其中封闭解法是指具有解析形式的解法,其求解速度比数值解法更快。

本文所研究的六自由度机器人,是具有六个旋转关节的串联型六自由度机器人,即RRR型的机器人。六自由度机器人的逆解封闭解法具体又可分为代数解法和几何解法,代数解法推导解析解的过程复杂,运算量较大,几何解法根据直观的几何关系获得关节变量的解析表达式,计算量较小。

本文主要讲解两种机器人运动学逆解的两种方法:
1. Pieper法
2. 常规法

1. Pieper 法

根据Pieper’s Solution的研究,如果六自由度机器人具有三个连续的轴交在同一点的情况,则手臂具有解析解。即六个关节均为旋转关节且后三个关节轴相交于一点的串联型机器人,其逆解具有封闭解。可以通过如下代数解法求解逆运动学的封闭解,该解法称为“三轴相交的 Pieper 解法”。下面进行各轴转角角度的公式推导。
我们知道,当后3个关节轴相交时,连杆坐标系

  1. {
  2. 4
  3. }
  4. ,
  5. {
  6. 5
  7. }
  8. ,
  9. {
  10. 6
  11. }
  12. \{4\},\{5\},\{6\}
  13. {4},{5},{6} 的原点位于该交点,该交点在基坐标系
  14. {
  15. 0
  16. }
  17. \{0\}
  18. {0} 中的坐标如下:
  19. 0
  20. P
  21. 4
  22. =
  23. 0
  24. T
  25. 1
  26. 2
  27. T
  28. 3
  29. 2
  30. T
  31. 3
  32. P
  33. 4
  34. =
  35. [
  36. x
  37. y
  38. z
  39. 1
  40. ]
  41. T
  42. { }^{0} \boldsymbol{P}_{4}={ }^{0} \boldsymbol{T}^{1}{ }_{2} \boldsymbol{T}_{3}^{2} \boldsymbol{T}^{3} \boldsymbol{P}_{4}=\left[\begin{array}{llll} x & y & z & 1 \end{array}\right]^{\mathrm{T}}
  43. 0P4​=0T12T32T3P4​=[xyz1​]T

对于齐次变换矩阵的变换通式的理解请参阅【Matlab 六自由度机器人】运动学正解(附MATLAB机器人正解完整代码)
由改进D-H参数的连杆齐次变换矩阵式,应用齐次变换矩阵的变换通式

  1. i
  2. 1
  3. T
  4. i
  5. =
  6. [
  7. c
  8. o
  9. s
  10. θ
  11. i
  12. s
  13. i
  14. n
  15. θ
  16. i
  17. 0
  18. a
  19. i
  20. 1
  21. s
  22. i
  23. n
  24. θ
  25. i
  26. c
  27. o
  28. s
  29. α
  30. i
  31. 1
  32. c
  33. o
  34. s
  35. θ
  36. i
  37. c
  38. o
  39. s
  40. α
  41. i
  42. 1
  43. s
  44. i
  45. n
  46. α
  47. i
  48. 1
  49. s
  50. i
  51. n
  52. α
  53. i
  54. 1
  55. d
  56. i
  57. s
  58. i
  59. n
  60. θ
  61. i
  62. s
  63. i
  64. n
  65. α
  66. i
  67. 1
  68. c
  69. o
  70. s
  71. θ
  72. i
  73. s
  74. i
  75. n
  76. α
  77. i
  78. 1
  79. c
  80. o
  81. s
  82. α
  83. i
  84. 1
  85. c
  86. o
  87. s
  88. α
  89. i
  90. 1
  91. d
  92. i
  93. 0
  94. 0
  95. 0
  96. 1
  97. ]
  98. ^{i-1}T_i =\left[ \begin{matrix} cosθ_i&-sinθ_i&0&a_{i-1} \\ sinθ_icosα_{i-1}&cosθ_icosα_{i-1}&-sinα_{i-1}&-sinα_{i-1}d_{i} \\ sinθ_isinα_{i-1}&cosθ_isinα_{i-1}&cosα_{i-1}&cosα_{i-1}d_{i} \\ 0&0&0&1 \end{matrix} \right]
  99. i1Ti​=⎣⎢⎢⎡​cosθisinθicosαi1sinθisinαi10​−sinθicosθicosαi1cosθisinαi100sinαi1cosαi10ai1​−sinαi1dicosαi1di1​⎦⎥⎥⎤​

可知当

  1. i
  2. =
  3. 4
  4. i=4
  5. i=4 时,
  6. 0
  7. P
  8. 4
  9. =
  10. 1
  11. 0
  12. T
  13. 2
  14. 1
  15. T
  16. (
  17. 3
  18. 2
  19. T
  20. 3
  21. P
  22. 4
  23. )
  24. =
  25. 1
  26. 0
  27. T
  28. 2
  29. 1
  30. T
  31. (
  32. 3
  33. 2
  34. T
  35. [
  36. a
  37. 3
  38. d
  39. 4
  40. s
  41. α
  42. 3
  43. d
  44. 4
  45. c
  46. α
  47. 3
  48. 1
  49. ]
  50. )
  51. =
  52. 1
  53. 0
  54. T
  55. 2
  56. 1
  57. T
  58. [
  59. f
  60. 1
  61. (
  62. θ
  63. 3
  64. )
  65. f
  66. 2
  67. (
  68. θ
  69. 3
  70. )
  71. f
  72. 3
  73. (
  74. θ
  75. 3
  76. )
  77. 1
  78. ]
  79. { }^{0} \boldsymbol{P}_{4}={ }_{1}^{0} \boldsymbol{T}{ }_{2}^{1} \boldsymbol{T}\left({ }_{3}^{2} \boldsymbol{T}^{3} \boldsymbol{P}_{4}\right)={ }_{1}^{0} \boldsymbol{T}{ }_{2}^{1} \boldsymbol{T}\left({ }_{3}^{2} \boldsymbol{T}\left[\begin{array}{c} a_{3} \\ -d_{4} s \alpha_{3} \\ d_{4} c \alpha_{3} \\ 1 \end{array}\right]\right)={ }_{1}^{0} \boldsymbol{T}{ }_{2}^{1} \boldsymbol{T}\left[\begin{array}{c} f_{1}\left(\theta_{3}\right) \\ f_{2}\left(\theta_{3}\right) \\ f_{3}\left(\theta_{3}\right) \\ 1 \end{array}\right]
  80. 0P4​=10T21T(32T3P4​)=10T21T⎝⎜⎜⎛​32T⎣⎢⎢⎡​a3​−d4sα3d4cα31​⎦⎥⎥⎤​⎠⎟⎟⎞​=10T21T⎣⎢⎢⎡​f1​(θ3​)f2​(θ3​)f3​(θ3​)1​⎦⎥⎥⎤​

应用齐次变换矩阵对于

  1. 3
  2. 2
  3. T
  4. { }_{3}^{2} \boldsymbol{T}
  5. 32T 可以得到
  6. f
  7. i
  8. f_{i}
  9. fi 的表达式:
  10. f
  11. 1
  12. =
  13. a
  14. 3
  15. c
  16. 3
  17. +
  18. d
  19. 4
  20. s
  21. α
  22. 3
  23. s
  24. 3
  25. +
  26. a
  27. 2
  28. f
  29. 2
  30. =
  31. a
  32. 3
  33. c
  34. α
  35. 2
  36. s
  37. 3
  38. d
  39. 4
  40. s
  41. α
  42. 3
  43. c
  44. α
  45. 2
  46. c
  47. 3
  48. d
  49. 4
  50. s
  51. α
  52. 2
  53. c
  54. α
  55. 3
  56. d
  57. 3
  58. s
  59. α
  60. 2
  61. f
  62. 3
  63. =
  64. a
  65. 3
  66. s
  67. α
  68. 2
  69. s
  70. 3
  71. d
  72. 4
  73. s
  74. α
  75. 3
  76. s
  77. α
  78. 2
  79. c
  80. 3
  81. +
  82. d
  83. 4
  84. c
  85. α
  86. 2
  87. c
  88. α
  89. 3
  90. +
  91. d
  92. 3
  93. c
  94. α
  95. 2
  96. \begin{aligned} &f_{1}=a_{3} c_{3}+d_{4} s \alpha_{3} s_{3}+a_{2} \\ &f_{2}=a_{3} c \alpha_{2} s_{3}-d_{4} s \alpha_{3} c \alpha_{2} c_{3}-d_{4} s \alpha_{2} c \alpha_{3}-d_{3} s \alpha_{2} \\ &f_{3}=a_{3} s \alpha_{2} s_{3}-d_{4} s \alpha_{3} s \alpha_{2} c_{3}+d_{4} c \alpha_{2} c \alpha_{3}+d_{3} c \alpha_{2} \end{aligned}
  97. f1​=a3c3​+d4sα3s3​+a2f2​=a3cα2s3​−d4sα3cα2c3​−d4sα2cα3​−d3sα2f3​=a3sα2s3​−d4sα3sα2c3​+d4cα2cα3​+d3cα2​​

  1. 1
  2. 0
  3. T
  4. { }_{1}^{0} \boldsymbol{T}
  5. 10T
  6. 2
  7. 1
  8. T
  9. { }_{2}^{1} \boldsymbol{T}
  10. 21T 应用齐次变换矩阵得到
  11. 0
  12. P
  13. 4
  14. =
  15. [
  16. c
  17. 1
  18. g
  19. 1
  20. s
  21. 1
  22. g
  23. 2
  24. s
  25. 1
  26. g
  27. 1
  28. +
  29. c
  30. 1
  31. g
  32. 2
  33. g
  34. 3
  35. 1
  36. ]
  37. T
  38. { }^{0} \boldsymbol{P}_{4}=\left[\begin{array}{llll} c_{1} g_{1}-s_{1} g_{2} & s_{1} g_{1}+c_{1} g_{2} & g_{3} & 1 \end{array}\right]^{\mathrm{T}}
  39. 0P4​=[c1g1​−s1g2​​s1g1​+c1g2​​g3​​1​]T
  40. g
  41. 1
  42. g
  43. 2
  44. g
  45. 3
  46. g_{1} g_{2} g_{3}
  47. g1​、g2​、g3 计算过程如下:
  48. g
  49. 1
  50. =
  51. c
  52. 2
  53. f
  54. 1
  55. s
  56. 2
  57. f
  58. 2
  59. +
  60. a
  61. 1
  62. g
  63. 2
  64. =
  65. s
  66. 2
  67. c
  68. α
  69. 1
  70. f
  71. 1
  72. +
  73. c
  74. 2
  75. c
  76. α
  77. 1
  78. f
  79. 2
  80. s
  81. α
  82. 1
  83. f
  84. 3
  85. d
  86. 2
  87. s
  88. α
  89. 1
  90. g
  91. 3
  92. =
  93. s
  94. 2
  95. s
  96. α
  97. 1
  98. f
  99. 1
  100. +
  101. c
  102. 2
  103. s
  104. α
  105. 1
  106. f
  107. 2
  108. +
  109. c
  110. α
  111. 1
  112. f
  113. 3
  114. +
  115. d
  116. 2
  117. c
  118. α
  119. 1
  120. \begin{aligned} &g_{1}=c_{2} f_{1}-s_{2} f_{2}+a_{1} \\ &g_{2}=s_{2} c \alpha_{1} f_{1}+c_{2} c \alpha_{1} f_{2}-s \alpha_{1} f_{3}-d_{2} s \alpha_{1} \\ &g_{3}=s_{2} s \alpha_{1} f_{1}+c_{2} s \alpha_{1} f_{2}+c \alpha_{1} f_{3}+d_{2} c \alpha_{1} \end{aligned}
  121. g1​=c2f1​−s2f2​+a1g2​=s2cα1f1​+c2cα1f2​−sα1f3​−d2sα1g3​=s2sα1f1​+c2sα1f2​+cα1f3​+d2cα1​​

  1. r
  2. =
  3. x
  4. 2
  5. +
  6. y
  7. 2
  8. +
  9. z
  10. 2
  11. r=x^{2}+y^{2}+z^{2}
  12. r=x2+y2+z2,由上式可知
  13. r
  14. =
  15. g
  16. 1
  17. 2
  18. +
  19. g
  20. 2
  21. 2
  22. +
  23. g
  24. 2
  25. 2
  26. =
  27. f
  28. 1
  29. 2
  30. +
  31. f
  32. 2
  33. 2
  34. +
  35. f
  36. 2
  37. 2
  38. +
  39. a
  40. 1
  41. 2
  42. +
  43. d
  44. 2
  45. 2
  46. +
  47. 2
  48. d
  49. 2
  50. f
  51. 3
  52. +
  53. 2
  54. a
  55. 1
  56. (
  57. c
  58. 2
  59. f
  60. 1
  61. s
  62. 2
  63. f
  64. 2
  65. )
  66. \begin{aligned} r &=g_{1}^{2}+g_{2}^{2}+g_{2}^{2} \\ &=f_{1}^{2}+f_{2}^{2}+f_{2}^{2}+a_{1}^{2}+d_{2}^{2}+2 d_{2} f_{3}+2 a_{1}\left(c_{2} f_{1}-s_{2} f_{2}\right) \end{aligned}
  67. r​=g12​+g22​+g22​=f12​+f22​+f22​+a12​+d22​+2d2f3​+2a1​(c2f1​−s2f2​)​

由上式写出

  1. Z
  2. \mathrm{Z}
  3. Z 轴分量的方程,可得系统的两个方程:
  4. r
  5. =
  6. (
  7. k
  8. 1
  9. c
  10. 2
  11. +
  12. k
  13. 2
  14. s
  15. 2
  16. )
  17. 2
  18. a
  19. 1
  20. +
  21. k
  22. 3
  23. z
  24. =
  25. (
  26. k
  27. 1
  28. s
  29. 2
  30. k
  31. 2
  32. c
  33. 2
  34. )
  35. s
  36. α
  37. 2
  38. +
  39. k
  40. 4
  41. \begin{aligned} &r=\left(k_{1} c_{2}+k_{2} s_{2}\right) 2 a_{1}+k_{3} \\ &z=\left(k_{1} s_{2}-k_{2} c_{2}\right) s \alpha_{2}+k_{4} \end{aligned}
  42. r=(k1c2​+k2s2​)2a1​+k3z=(k1s2​−k2c2​)sα2​+k4​​

对于

  1. k
  2. 1
  3. k
  4. 2
  5. k
  6. 3
  7. k
  8. 4
  9. k_{1} k_{2} k_{3} k_{4}
  10. k1​、k2​、k3​、k4​,其计算如下:
  11. k
  12. 1
  13. =
  14. f
  15. 1
  16. k
  17. 2
  18. =
  19. f
  20. 2
  21. k
  22. 3
  23. =
  24. f
  25. 1
  26. 2
  27. +
  28. f
  29. 2
  30. 2
  31. +
  32. f
  33. 3
  34. 2
  35. +
  36. a
  37. 1
  38. 2
  39. +
  40. d
  41. 2
  42. 2
  43. +
  44. 2
  45. d
  46. 2
  47. f
  48. 3
  49. k
  50. 4
  51. =
  52. f
  53. 3
  54. c
  55. α
  56. 1
  57. +
  58. d
  59. 2
  60. c
  61. α
  62. 1
  63. \begin{aligned} &k_{1}=f_{1} \\ &k_{2}=-f_{2} \\ &k_{3}=f_{1}^{2}+f_{2}^{2}+f_{3}^{2}+a_{1}^{2}+d_{2}^{2}+2 d_{2} f_{3} \\ &k_{4}=f_{3} c \alpha_{1}+d_{2} c \alpha_{1} \end{aligned}
  64. k1​=f1k2​=−f2k3​=f12​+f22​+f32​+a12​+d22​+2d2f3k4​=f3cα1​+d2cα1​​

之后求解

  1. θ
  2. 3
  3. \theta_{3}
  4. θ3​,分三种情况:

(1) 若

  1. a
  2. 1
  3. =
  4. 0
  5. a_{1}=0
  6. a1​=0,则
  7. r
  8. =
  9. k
  10. 3
  11. r=k_{3}
  12. r=k3​,此时
  13. r
  14. r
  15. r 已知。
  16. k
  17. 3
  18. k_{3}
  19. k3 的右边是关于
  20. θ
  21. 3
  22. \theta_{3}
  23. θ3 的函数。代入下式后,由包含
  24. tan
  25. (
  26. θ
  27. 3
  28. /
  29. 2
  30. )
  31. \tan \left(\theta_{3} / 2\right)
  32. tan3​/2) 的一元二次方程可以解出
  33. θ
  34. 3
  35. \theta_{3}
  36. θ3​;
  37. u
  38. =
  39. tan
  40. θ
  41. 2
  42. ,
  43. cos
  44. θ
  45. =
  46. 1
  47. u
  48. 2
  49. 1
  50. +
  51. u
  52. 2
  53. ,
  54. sin
  55. θ
  56. =
  57. 2
  58. u
  59. 1
  60. +
  61. u
  62. 2
  63. u=\tan \frac{\theta}{2}, \cos \theta=\frac{1-u^{2}}{1+u^{2}}, \sin \theta=\frac{2 u}{1+u^{2}}
  64. u=tan2θ​,cosθ=1+u21u2​,sinθ=1+u22u

(2) 若

  1. s
  2. α
  3. 1
  4. =
  5. 0
  6. s \alpha_{1}=0
  7. sα1​=0,则
  8. z
  9. =
  10. k
  11. 4
  12. z=k_{4}
  13. z=k4​,此时
  14. z
  15. z
  16. z 已知。代入上式后,利用上面的一元 二次方程解出
  17. θ
  18. 3
  19. \theta_{3}
  20. θ3

(3) 否则,从式

  1. r
  2. =
  3. (
  4. k
  5. 1
  6. c
  7. 2
  8. +
  9. k
  10. 2
  11. s
  12. 2
  13. )
  14. 2
  15. a
  16. 1
  17. +
  18. k
  19. 3
  20. z
  21. =
  22. (
  23. k
  24. 1
  25. s
  26. 2
  27. k
  28. 2
  29. c
  30. 2
  31. )
  32. s
  33. α
  34. 2
  35. +
  36. k
  37. 4
  38. \begin{aligned} &r=\left(k_{1} c_{2}+k_{2} s_{2}\right) 2 a_{1}+k_{3} \\ &z=\left(k_{1} s_{2}-k_{2} c_{2}\right) s \alpha_{2}+k_{4} \end{aligned}
  39. r=(k1c2​+k2s2​)2a1​+k3z=(k1s2​−k2c2​)sα2​+k4​​中消去
  40. s
  41. 2
  42. s_{2}
  43. s2
  44. c
  45. 2
  46. c_{2}
  47. c2​,得到
  48. (
  49. r
  50. k
  51. 3
  52. )
  53. 2
  54. 4
  55. a
  56. 1
  57. 2
  58. +
  59. (
  60. z
  61. k
  62. 4
  63. )
  64. 2
  65. s
  66. 2
  67. α
  68. 1
  69. =
  70. k
  71. 1
  72. 2
  73. +
  74. k
  75. 2
  76. 2
  77. \frac{\left(r-k_{3}\right)^{2}}{4 a_{1}^{2}}+\frac{\left(z-k_{4}\right)^{2}}{s^{2} \alpha_{1}}=k_{1}^{2}+k_{2}^{2}
  78. 4a12​(rk3​)2​+s2α1​(zk4​)2​=k12​+k22

代入

  1. u
  2. =
  3. tan
  4. θ
  5. 2
  6. ,
  7. cos
  8. θ
  9. =
  10. 1
  11. u
  12. 2
  13. 1
  14. +
  15. u
  16. 2
  17. ,
  18. sin
  19. θ
  20. =
  21. 2
  22. u
  23. 1
  24. +
  25. u
  26. 2
  27. u=\tan \frac{\theta}{2}, \cos \theta=\frac{1-u^{2}}{1+u^{2}}, \sin \theta=\frac{2 u}{1+u^{2}}
  28. u=tan2θ​,cosθ=1+u21u2​,sinθ=1+u22u​解出
  29. θ
  30. 3
  31. \theta_{3}
  32. θ3 后,可得到一个一元四次方程,由此可解出
  33. θ
  34. 3
  35. \theta_{3}
  36. θ3 解出
  37. θ
  38. 3
  39. \theta_{3}
  40. θ3 后,再解出
  41. θ
  42. 2
  43. \theta_{2}
  44. θ2​,再根据
  45. 0
  46. P
  47. 4
  48. =
  49. [
  50. c
  51. 1
  52. g
  53. 1
  54. s
  55. 1
  56. g
  57. 2
  58. s
  59. 1
  60. g
  61. 1
  62. +
  63. c
  64. 1
  65. g
  66. 2
  67. g
  68. 3
  69. 1
  70. ]
  71. T
  72. { }^{0} \boldsymbol{P}_{4}=\left[\begin{array}{llll} c_{1} g_{1}-s_{1} g_{2} & s_{1} g_{1}+c_{1} g_{2} & g_{3} & 1 \end{array}\right]^{\mathrm{T}}
  73. 0P4​=[c1g1​−s1g2​​s1g1​+c1g2​​g3​​1​]T解出
  74. θ
  75. 1
  76. \theta_{1}
  77. θ1

Pieper 解法求解出了前三轴的关节变量,该解通常具有4组解或8组。由于后三轴的关节角只影响工具坐标系的方位,因此可以通过欧拉角解法求出后三轴的关节变量。

六自由度机器人工具坐标系的姿态,可以使用一组欧拉角

  1. (
  2. ψ
  3. ,
  4. θ
  5. ,
  6. φ
  7. )
  8. (\psi, \theta, \varphi)
  9. (ψ,θ,φ) 来表示,该转角序列表示绕
  10. x
  11. x
  12. x 轴,
  13. y
  14. y
  15. y 轴和
  16. z
  17. z
  18. z 轴的旋转序列:先绕
  19. z
  20. z
  21. z 轴旋转
  22. ψ
  23. \psi
  24. ψ 角,再绕新坐标系的
  25. y
  26. y
  27. y 轴旋转
  28. θ
  29. \theta
  30. θ 角,最后绕新坐标系
  31. z
  32. z
  33. z 轴旋转
  34. φ
  35. \varphi
  36. φ 角。欧拉角变换 Euler
  37. (
  38. ψ
  39. ,
  40. θ
  41. ,
  42. φ
  43. )
  44. (\psi, \theta, \varphi)
  45. (ψ,θ,φ) 可以通过三个旋转矩阵相乘表示
  46. Euler
  47. (
  48. ψ
  49. ,
  50. θ
  51. ,
  52. φ
  53. )
  54. =
  55. Rot
  56. (
  57. z
  58. ,
  59. ψ
  60. )
  61. Rot
  62. (
  63. y
  64. ,
  65. θ
  66. )
  67. Rot
  68. (
  69. z
  70. ,
  71. φ
  72. )
  73. =
  74. [
  75. c
  76. ψ
  77. c
  78. θ
  79. c
  80. φ
  81. s
  82. ψ
  83. s
  84. φ
  85. c
  86. ψ
  87. c
  88. θ
  89. s
  90. φ
  91. s
  92. ψ
  93. c
  94. φ
  95. c
  96. ψ
  97. s
  98. θ
  99. 0
  100. s
  101. ψ
  102. c
  103. θ
  104. c
  105. φ
  106. +
  107. c
  108. ψ
  109. s
  110. φ
  111. s
  112. ψ
  113. c
  114. θ
  115. s
  116. φ
  117. +
  118. c
  119. ψ
  120. c
  121. φ
  122. s
  123. ψ
  124. s
  125. θ
  126. 0
  127. s
  128. θ
  129. c
  130. φ
  131. s
  132. θ
  133. s
  134. φ
  135. c
  136. θ
  137. 0
  138. 0
  139. 0
  140. 0
  141. 1
  142. ]
  143. \begin{aligned} \operatorname{Euler}(\psi, \theta, \varphi) &=\operatorname{Rot}(z, \psi) \operatorname{Rot}(y, \theta) \operatorname{Rot}(z, \varphi) \\ &=\left[\begin{array}{cccc} c \psi c \theta c \varphi-s \psi s \varphi & -c \psi c \theta s \varphi-s \psi c \varphi & c \psi s \theta & 0 \\ s \psi c \theta c \varphi+c \psi s \varphi & -s \psi c \theta s \varphi+c \psi c \varphi & s \psi s \theta & 0 \\ -s \theta c \varphi & s \theta s \varphi & c \theta & 0 \\ 0 & 0 & 0 & 1 \end{array}\right] \end{aligned}
  144. Euler(ψ,θ,φ)​=Rot(z,ψ)Rot(y,θ)Rot(z,φ)=⎣⎢⎢⎡​cψcθcφ−sψsφsψcθcφ+cψsφ−sθcφ0​−cψcθsφ−sψcφ−sψcθsφ+cψcφsθsφ0cψsθsψsθcθ00001​⎦⎥⎥⎤​​

如果已知一个表示任意旋转的齐次变换, 即已知姿态矩阵

  1. R
  2. \boldsymbol{R}
  3. R
  4. R
  5. =
  6. [
  7. n
  8. x
  9. o
  10. x
  11. a
  12. x
  13. n
  14. y
  15. o
  16. y
  17. a
  18. y
  19. n
  20. z
  21. o
  22. z
  23. a
  24. z
  25. ]
  26. \boldsymbol{R}=\left[\begin{array}{lll} n_{x} & o_{x} & a_{x} \\ n_{y} & o_{y} & a_{y} \\ n_{z} & o_{z} & a_{z} \end{array}\right]
  27. R=⎣⎡​nxnynz​​oxoyoz​​axayaz​​⎦⎤​

则根据姿态矩阵

  1. R
  2. \boldsymbol{R}
  3. R 可求出其对应的欧拉角:
  4. ψ
  5. =
  6. atan
  7. 2
  8. (
  9. a
  10. x
  11. ,
  12. a
  13. y
  14. )
  15. +
  16. 18
  17. 0
  18. θ
  19. =
  20. atan
  21. 2
  22. (
  23. c
  24. ψ
  25. a
  26. x
  27. +
  28. s
  29. ψ
  30. a
  31. y
  32. ,
  33. a
  34. z
  35. )
  36. φ
  37. =
  38. atan
  39. 2
  40. (
  41. s
  42. ψ
  43. n
  44. x
  45. +
  46. c
  47. ψ
  48. n
  49. y
  50. ,
  51. s
  52. ψ
  53. o
  54. x
  55. +
  56. c
  57. ψ
  58. o
  59. y
  60. )
  61. \begin{aligned} &\psi=\operatorname{atan} 2\left(a_{x}, a_{y}\right)+180^{\circ} \\ &\theta=\operatorname{atan} 2\left(c \psi a_{x}+s \psi a_{y}, a_{z}\right) \\ &\varphi=\operatorname{atan} 2\left(-s \psi n_{x}+c \psi n_{y},-s \psi o_{x}+c \psi o_{y}\right) \end{aligned}
  62. ​ψ=atan2(ax​,ay​)+180∘θ=atan2(cψax​+sψay​,az​)φ=atan2(−sψnx​+cψny​,−sψox​+cψoy​)​对于6R型六自由度机器人,已经求得前三轴的关节变量,即可求出齐次变换矩
  63. 3
  64. 0
  65. T
  66. { }_{3}^{0} \boldsymbol{T}
  67. 30T
  68. 3
  69. 0
  70. T
  71. =
  72. 1
  73. 0
  74. T
  75. (
  76. θ
  77. 1
  78. )
  79. 2
  80. 1
  81. T
  82. (
  83. θ
  84. 2
  85. )
  86. 3
  87. 2
  88. T
  89. (
  90. θ
  91. 3
  92. )
  93. { }_{3}^{0} \boldsymbol{T}={ }_{1}^{0} \boldsymbol{T}\left(\theta_{1}\right){ }_{2}^{1} \boldsymbol{T}\left(\theta_{2}\right){ }_{3}^{2} \boldsymbol{T}\left(\theta_{3}\right)
  94. 30T=10T1​)21T2​)32T3​)假设建立欧拉角 Euler
  95. (
  96. ψ
  97. ,
  98. θ
  99. ,
  100. φ
  101. )
  102. (\psi, \theta, \varphi)
  103. (ψ,θ,φ) 的坐标系为
  104. {
  105. E
  106. }
  107. \{\mathrm{E}\}
  108. {E},则从基座标系
  109. {
  110. 0
  111. }
  112. \{0\}
  113. {0} 到坐标系
  114. {
  115. E
  116. }
  117. \{E\}
  118. {E} 的齐次变换矩阵为:
  119. E
  120. 0
  121. T
  122. =
  123. 3
  124. 0
  125. T
  126. Rot
  127. (
  128. x
  129. ,
  130. α
  131. 3
  132. )
  133. { }_{E}^{0} \boldsymbol{T}={ }_{3}^{0} \boldsymbol{T} \operatorname{Rot}\left(x, \alpha_{3}\right)
  134. E0T=30TRot(x3​)式中,
  135. α
  136. 3
  137. \alpha_{3}
  138. α3 一表示改进 DH参数表中的第四轴的连杆扭角。 欧拉角表示的资态矩阵的计算方法如式(2-21)所示:
  139. R
  140. =
  141. E
  142. 0
  143. R
  144. 6
  145. T
  146. R
  147. \boldsymbol{R}={ }_{\mathrm{E}}^{{ }_{\mathrm{0}}} \boldsymbol{R}*{ }_{6}^{\mathrm{T}} \boldsymbol{R}
  148. R=E0​​R6TR其中
  149. E
  150. 0
  151. R
  152. T
  153. { }_{E}^{0} R^{\mathrm{T}}
  154. E0RT 一表示齐次变换矩阵
  155. E
  156. 0
  157. T
  158. { }_{E}^{0} \boldsymbol{T}
  159. E0T 中的旋转矩阵的转置;
  160. 6
  161. 0
  162. R
  163. { }_{6}^{0} R
  164. 60R 一表示齐次变换矩阵
  165. 6
  166. 0
  167. T
  168. { }_{6}^{0} \boldsymbol{T}
  169. 60T 中的旋转矩阵。

求出欧拉角姿态矩阵后,可通过

  1. ψ
  2. =
  3. atan
  4. 2
  5. (
  6. a
  7. x
  8. ,
  9. a
  10. y
  11. )
  12. +
  13. 18
  14. 0
  15. θ
  16. =
  17. atan
  18. 2
  19. (
  20. c
  21. ψ
  22. a
  23. x
  24. +
  25. s
  26. ψ
  27. a
  28. y
  29. ,
  30. a
  31. z
  32. )
  33. φ
  34. =
  35. atan
  36. 2
  37. (
  38. s
  39. ψ
  40. n
  41. x
  42. +
  43. c
  44. ψ
  45. n
  46. y
  47. ,
  48. s
  49. ψ
  50. o
  51. x
  52. +
  53. c
  54. ψ
  55. o
  56. y
  57. )
  58. \begin{aligned} &\psi=\operatorname{atan} 2\left(a_{x}, a_{y}\right)+180^{\circ} \\ &\theta=\operatorname{atan} 2\left(c \psi a_{x}+s \psi a_{y}, a_{z}\right) \\ &\varphi=\operatorname{atan} 2\left(-s \psi n_{x}+c \psi n_{y},-s \psi o_{x}+c \psi o_{y}\right) \end{aligned}
  59. ​ψ=atan2(ax​,ay​)+180∘θ=atan2(cψax​+sψay​,az​)φ=atan2(−sψnx​+cψny​,−sψox​+cψoy​)​求出相应的欧拉角。所求得的欧 拉角与后三轴的关苖变量的关系为:
  60. θ
  61. 4
  62. =
  63. ψ
  64. ,
  65. θ
  66. 5
  67. =
  68. θ
  69. ,
  70. θ
  71. 6
  72. =
  73. φ
  74. \theta_{4}=\psi, \theta_{5}=-\theta, \theta_{6}=\varphi
  75. θ4​=ψ,θ5​=−θ,θ6​=φ

由于机器人腕关节翻转,可以得到后三轴的另外一组解:

  1. θ
  2. 4
  3. =
  4. θ
  5. 4
  6. +
  7. 18
  8. 0
  9. ,
  10. θ
  11. 5
  12. =
  13. θ
  14. 5
  15. ,
  16. θ
  17. 6
  18. =
  19. θ
  20. 6
  21. +
  22. 18
  23. 0
  24. \theta_{4}^{\prime}=\theta_{4}+180^{\circ}, \theta_{5}^{\prime}=-\theta_{5}, \theta_{6}^{\prime}=\theta_{6}+180^{\circ}
  25. θ4′​=θ4​+180∘,θ5′​=−θ5​,θ6′​=θ6​+180

上述算法可计算出的多组解,根据关节运动范围的限制可以舍弃一部分解,在余下的有效解中,通常选择最接近机器人当前位姿的“最短行程解”。

2. 《机器人学》常规求解

在求解运动学逆解前,我们先掌握运动学正解的知识,具体过程请参阅:【Matlab 六自由度机器人】运动学正解(附MATLAB机器人正解完整代码)
如前所述,矩阵右式的元素,或为零,或为常数,或者为第

  1. i
  2. i
  3. i至第
  4. 6
  5. 6
  6. 6个关节变量的函数。矩阵相等表明其对应元素分别相等,并可从每一矩阵方程得到
  7. 12
  8. 12
  9. 12个方程式,每个方程式对应于
  10. 4
  11. 4
  12. 4个矢量
  13. n
  14. ,
  15. o
  16. ,
  17. a
  18. ,
  19. p
  20. n,o,a,p
  21. n,o,a,p的每一分量。我们先以之前建立过的 六自由度机器人 为例来阐述这些方程的求解。

该机器人的运动方程(设为方程式1)如下:

  1. 0
  2. T
  3. 6
  4. =
  5. [
  6. n
  7. x
  8. o
  9. x
  10. a
  11. x
  12. p
  13. x
  14. n
  15. y
  16. o
  17. y
  18. a
  19. y
  20. p
  21. y
  22. n
  23. x
  24. o
  25. x
  26. a
  27. z
  28. p
  29. z
  30. 0
  31. 0
  32. 0
  33. 1
  34. ]
  35. =
  36. 0
  37. T
  38. 1
  39. (
  40. θ
  41. 1
  42. )
  43. 1
  44. T
  45. 2
  46. (
  47. θ
  48. 2
  49. )
  50. 2
  51. T
  52. 3
  53. (
  54. θ
  55. 3
  56. )
  57. 3
  58. T
  59. 4
  60. (
  61. θ
  62. 4
  63. )
  64. 4
  65. T
  66. 5
  67. (
  68. θ
  69. 5
  70. )
  71. 5
  72. T
  73. 6
  74. (
  75. θ
  76. 6
  77. )
  78. { }^{0} \boldsymbol{T}_{6}=\left[\begin{array}{cccc} n_{x} & o_{x} & a_{x} & p_{x} \\ n_{y} & o_{y} & a_{y} & p_{y} \\ n_{x} & o_{x} & a_{z} & p_{z} \\ 0 & 0 & 0 & 1 \end{array}\right]={ }^{0} \boldsymbol{T}_{1}\left(\theta_{1}\right)^{1} \boldsymbol{T}_{2}\left(\theta_{2}\right)^{2} \boldsymbol{T}_{3}\left(\theta_{3}\right)^{3} \boldsymbol{T}_{4}\left(\theta_{4}\right)^{4} \boldsymbol{T}_{5}\left(\theta_{5}\right)^{5} \boldsymbol{T}_{6}\left(\theta_{6}\right)
  79. 0T6​=⎣⎢⎢⎡​nxnynx0oxoyox0axayaz0pxpypz1​⎦⎥⎥⎤​=0T1​(θ1​)1T2​(θ2​)2T3​(θ3​)3T4​(θ4​)4T5​(θ5​)5T6​(θ6​)末端连杆的位姿已经给定,即
  80. n
  81. ,
  82. o
  83. ,
  84. a
  85. n,o,a
  86. n,o,a
  87. p
  88. p
  89. p 为已知,则求关节变量
  90. θ
  91. 1
  92. ,
  93. θ
  94. 2
  95. ,
  96. ,
  97. θ
  98. 6
  99. \theta_{1}, \theta_{2}, \cdots, \theta_{6}
  100. θ1​,θ2​,⋯,θ6 的值称为运动反解。用末知的连杆逆变换左乘方程式1两边,把关节变量分离出来,从而求解。具体步骤如下:
    1. θ
    2. 1
    3. \theta_{1}

    θ1​

可用逆变换

  1. 0
  2. T
  3. 1
  4. 1
  5. (
  6. θ
  7. 1
  8. )
  9. { }^{0} \boldsymbol{T}_{1}^{-1}\left(\theta_{1}\right)
  10. 0T11​(θ1​) 左乘方程式1两边
  11. 0
  12. T
  13. 1
  14. 1
  15. (
  16. θ
  17. 1
  18. )
  19. 0
  20. T
  21. 6
  22. =
  23. 1
  24. T
  25. 2
  26. (
  27. θ
  28. 2
  29. )
  30. 2
  31. T
  32. 3
  33. (
  34. θ
  35. 3
  36. )
  37. 3
  38. T
  39. 4
  40. (
  41. θ
  42. 4
  43. )
  44. 4
  45. T
  46. 5
  47. (
  48. θ
  49. 5
  50. )
  51. 5
  52. T
  53. 6
  54. (
  55. θ
  56. 6
  57. )
  58. { }^{0} \boldsymbol{T}_{1}^{-1}\left(\theta_{1}\right)^{0} \boldsymbol{T}_{6}={ }^{1} \boldsymbol{T}_{2}\left(\theta_{2}\right)^{2} \boldsymbol{T}_{3}\left(\theta_{3}\right)^{3} \boldsymbol{T}_{4}\left(\theta_{4}\right)^{4} \boldsymbol{T}_{5}\left(\theta_{5}\right)^{5} \boldsymbol{T}_{6}\left(\theta_{6}\right)
  59. 0T11​(θ1​)0T6​=1T2​(θ2​)2T3​(θ3​)3T4​(θ4​)4T5​(θ5​)5T6​(θ6​)
  60. [
  61. c
  62. 1
  63. s
  64. 1
  65. 0
  66. 0
  67. s
  68. 1
  69. c
  70. 1
  71. 0
  72. 0
  73. 0
  74. 0
  75. 1
  76. 0
  77. 0
  78. 0
  79. 0
  80. 1
  81. ]
  82. [
  83. n
  84. x
  85. o
  86. x
  87. a
  88. x
  89. p
  90. x
  91. n
  92. y
  93. o
  94. y
  95. a
  96. y
  97. p
  98. y
  99. n
  100. z
  101. o
  102. x
  103. a
  104. z
  105. p
  106. x
  107. 0
  108. 0
  109. 0
  110. 1
  111. ]
  112. =
  113. 1
  114. T
  115. 6
  116. \left[\begin{array}{rrrr} c_{1} & s_{1} & 0 & 0 \\ -s_{1} & c_{1} & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{array}\right]\left[\begin{array}{cccc} n_{x} & o_{x} & a_{x} & p_{x} \\ n_{y} & o_{y} & a_{y} & p_{y} \\ n_{z} & o_{x} & a_{z} & p_{x} \\ 0 & 0 & 0 & 1 \end{array}\right]={ }^{1} \boldsymbol{T}_{6}
  117. ⎣⎢⎢⎡​c1​−s100s1c10000100001​⎦⎥⎥⎤​⎣⎢⎢⎡​nxnynz0oxoyox0axayaz0pxpypx1​⎦⎥⎥⎤​=1T6

令上式矩阵方程两瑞的元素

  1. (
  2. 2
  3. ,
  4. 4
  5. )
  6. (2,4)
  7. (2,4) 对应相等,可得
  8. s
  9. 1
  10. p
  11. x
  12. +
  13. c
  14. 1
  15. p
  16. y
  17. =
  18. d
  19. 2
  20. -s_{1} p_{x}+c_{1} p_{y}=d_{2}
  21. s1px​+c1py​=d2

利用三角代换

  1. p
  2. x
  3. =
  4. ρ
  5. cos
  6. ϕ
  7. ;
  8. p
  9. y
  10. =
  11. ρ
  12. sin
  13. ϕ
  14. p_{x}=\rho \cos \phi ; \quad p_{y}=\rho \sin \phi
  15. px​=ρcosϕ;py​=ρsinϕ

式中,

  1. ρ
  2. =
  3. p
  4. x
  5. 2
  6. +
  7. p
  8. y
  9. 2
  10. ;
  11. ϕ
  12. =
  13. atan2
  14. (
  15. p
  16. y
  17. ,
  18. p
  19. x
  20. )
  21. \rho=\sqrt{p_{x}^{2}+p_{y}^{2}} ; \phi=\operatorname{atan2}\left(p_{y}, p_{x}\right)
  22. ρ=px2​+py2​​;ϕ=atan2(py​,px​) ,通过代换得到
  23. θ
  24. 1
  25. \theta_{1}
  26. θ1 的解。
  27. sin
  28. (
  29. ϕ
  30. θ
  31. 1
  32. )
  33. =
  34. d
  35. 2
  36. /
  37. ρ
  38. ;
  39. cos
  40. (
  41. ϕ
  42. θ
  43. 1
  44. )
  45. =
  46. ±
  47. 1
  48. (
  49. d
  50. 2
  51. /
  52. ρ
  53. )
  54. 2
  55. ϕ
  56. θ
  57. 1
  58. =
  59. atan
  60. 2
  61. [
  62. d
  63. 2
  64. ρ
  65. ,
  66. ±
  67. 1
  68. (
  69. d
  70. 2
  71. ρ
  72. )
  73. 2
  74. ]
  75. θ
  76. 1
  77. =
  78. atan
  79. 2
  80. (
  81. p
  82. y
  83. ,
  84. p
  85. x
  86. )
  87. atan
  88. 2
  89. (
  90. d
  91. 2
  92. ,
  93. ±
  94. p
  95. x
  96. 2
  97. +
  98. p
  99. y
  100. 2
  101. d
  102. 2
  103. 2
  104. )
  105. }
  106. \left.\begin{array}{l} \sin \left(\phi-\theta_{1}\right)=d_{2} / \rho ; \cos \left(\phi-\theta_{1}\right)=\pm \sqrt{1-\left(d_{2} / \rho\right)^{2}} \\ \phi-\theta_{1}=\operatorname{atan} 2\left[\frac{d_{2}}{\rho}, \pm \sqrt{1-\left(\frac{d_{2}}{\rho}\right)^{2}}\right] \\ \theta_{1}=\operatorname{atan} 2\left(p_{y}, p_{x}\right)-\operatorname{atan} 2\left(d_{2}, \pm \sqrt{p_{x}^{2}+p_{y}^{2}-d_{2}^{2}}\right) \end{array}\right\}
  107. sin(ϕ−θ1​)=d2​/ρ;cos(ϕ−θ1​)=±1−(d2​/ρ)2​ϕ−θ1​=atan2d2​​,±1−(ρd2​​)2​]θ1​=atan2(py​,px​)−atan2(d2​,±px2​+py2​−d22​​)​⎭⎪⎪⎪⎪⎪⎬⎪⎪⎪⎪⎪⎫​

式中,正、负号对应于

  1. θ
  2. 1
  3. \theta_{1}
  4. θ1 的两个可能解。
    1. θ
    2. 3
    3. \theta_{3}

    θ3​

在选定

  1. θ
  2. 1
  3. \theta_{1}
  4. θ1 的一个解之后,再令矩阵方程
  5. 1
  6. T
  7. 6
  8. { }^{1} \boldsymbol{T}_{6}
  9. 1T6​两端的元素的
  10. (
  11. 1
  12. ,
  13. 4
  14. )
  15. (1,4)
  16. (1,4)
  17. (
  18. 3
  19. ,
  20. 4
  21. )
  22. (3,4)
  23. (3,4) 分别对应相等,即得两方程
  24. c
  25. 1
  26. p
  27. x
  28. +
  29. s
  30. 1
  31. p
  32. y
  33. =
  34. a
  35. 3
  36. c
  37. 23
  38. d
  39. 4
  40. s
  41. 23
  42. +
  43. a
  44. 2
  45. c
  46. 2
  47. p
  48. x
  49. =
  50. a
  51. 3
  52. s
  53. 23
  54. +
  55. d
  56. 4
  57. c
  58. 23
  59. +
  60. a
  61. 2
  62. s
  63. 2
  64. }
  65. \left.\begin{array}{l} c_{1} p_{x}+s_{1} p_{y}=a_{3} c_{23}-d_{4} s_{23}+a_{2} c_{2} \\ -p_{x}=a_{3} s_{23}+d_{4} c_{23}+a_{2} s_{2} \end{array}\right\}
  66. c1px​+s1py​=a3c23​−d4s23​+a2c2​−px​=a3s23​+d4c23​+a2s2​​}

  1. s
  2. 1
  3. p
  4. x
  5. +
  6. c
  7. 1
  8. p
  9. y
  10. =
  11. d
  12. 2
  13. -s_{1} p_{x}+c_{1} p_{y}=d_{2}
  14. s1px​+c1py​=d2​与
  15. c
  16. 1
  17. p
  18. x
  19. +
  20. s
  21. 1
  22. p
  23. y
  24. =
  25. a
  26. 3
  27. c
  28. 23
  29. d
  30. 4
  31. s
  32. 23
  33. +
  34. a
  35. 2
  36. c
  37. 2
  38. p
  39. x
  40. =
  41. a
  42. 3
  43. s
  44. 23
  45. +
  46. d
  47. 4
  48. c
  49. 23
  50. +
  51. a
  52. 2
  53. s
  54. 2
  55. }
  56. \left.\begin{array}{l} c_{1} p_{x}+s_{1} p_{y}=a_{3} c_{23}-d_{4} s_{23}+a_{2} c_{2} \\ -p_{x}=a_{3} s_{23}+d_{4} c_{23}+a_{2} s_{2} \end{array}\right\}
  57. c1px​+s1py​=a3c23​−d4s23​+a2c2​−px​=a3s23​+d4c23​+a2s2​​}的平方和为
  58. a
  59. 3
  60. c
  61. 3
  62. d
  63. 4
  64. s
  65. 3
  66. =
  67. k
  68. a_{3} c_{3}-d_{4} s_{3}=k
  69. a3c3​−d4s3​=k

式中,

  1. k
  2. =
  3. p
  4. x
  5. 2
  6. +
  7. p
  8. y
  9. 2
  10. +
  11. p
  12. x
  13. 2
  14. a
  15. 2
  16. 2
  17. a
  18. 3
  19. 2
  20. d
  21. 2
  22. 2
  23. d
  24. 4
  25. 2
  26. 2
  27. a
  28. 2
  29. k=\frac{p_{x}^{2}+p_{y}^{2}+p_{x}^{2}-a_{2}^{2}-a_{3}^{2}-d_{2}^{2}-d_{4}^{2}}{2 a_{2}}
  30. k=2a2px2​+py2​+px2​−a22​−a32​−d22​−d42​​

方程

  1. a
  2. 3
  3. c
  4. 3
  5. d
  6. 4
  7. s
  8. 3
  9. =
  10. k
  11. a_{3} c_{3}-d_{4} s_{3}=k
  12. a3c3​−d4s3​=k中已经消去
  13. θ
  14. 2
  15. \theta_{2}
  16. θ2​,且方程
  17. a
  18. 3
  19. c
  20. 3
  21. d
  22. 4
  23. s
  24. 3
  25. =
  26. k
  27. a_{3} c_{3}-d_{4} s_{3}=k
  28. a3c3​−d4s3​=k
  29. s
  30. 1
  31. p
  32. x
  33. +
  34. c
  35. 1
  36. p
  37. y
  38. =
  39. d
  40. 2
  41. -s_{1} p_{x}+c_{1} p_{y}=d_{2}
  42. s1px​+c1py​=d2​具有相同形式,因而可由三角代换求解得到
  43. θ
  44. 3
  45. \theta_{3}
  46. θ3
  47. θ
  48. 3
  49. =
  50. atan
  51. 2
  52. (
  53. a
  54. 3
  55. ,
  56. d
  57. 4
  58. )
  59. atan
  60. 2
  61. (
  62. k
  63. ,
  64. ±
  65. a
  66. 3
  67. 2
  68. +
  69. d
  70. 4
  71. 2
  72. k
  73. 2
  74. )
  75. \theta_{3}=\operatorname{atan} 2\left(a_{3}, d_{4}\right)-\operatorname{atan} 2\left(k, \pm \sqrt{a_{3}^{2}+d_{4}^{2}-k^{2}}\right)
  76. θ3​=atan2(a3​,d4​)−atan2(ka32​+d42​−k2​)

式中,正、负号对应

  1. θ
  2. 3
  3. \theta_{3}
  4. θ3 的两种可能解。
    1. θ
    2. 2
    3. \theta_{2}

    θ2​

为求解

  1. θ
  2. 2
  3. \theta_{2}
  4. θ2​,在矩阵方程1两边左乘逆变换
  5. 0
  6. T
  7. 3
  8. 1
  9. { }^{0} \boldsymbol{T}_{3}^{-1}
  10. 0T31
  11. [
  12. 0
  13. T
  14. 3
  15. 1
  16. (
  17. θ
  18. 1
  19. ,
  20. θ
  21. 2
  22. ,
  23. θ
  24. 3
  25. )
  26. 0
  27. T
  28. 6
  29. 3
  30. 3
  31. T
  32. 4
  33. (
  34. θ
  35. 4
  36. )
  37. 4
  38. T
  39. 5
  40. (
  41. θ
  42. 5
  43. )
  44. 5
  45. T
  46. 6
  47. (
  48. θ
  49. 6
  50. )
  51. c
  52. 1
  53. s
  54. 23
  55. s
  56. 1
  57. s
  58. 23
  59. s
  60. 23
  61. a
  62. 23
  63. c
  64. 3
  65. s
  66. 1
  67. c
  68. 1
  69. 0
  70. a
  71. 2
  72. s
  73. 3
  74. 0
  75. 0
  76. 0
  77. 1
  78. ]
  79. [
  80. n
  81. x
  82. o
  83. x
  84. a
  85. x
  86. p
  87. x
  88. n
  89. y
  90. o
  91. y
  92. a
  93. y
  94. p
  95. y
  96. n
  97. z
  98. v
  99. z
  100. a
  101. z
  102. p
  103. z
  104. 0
  105. 0
  106. 0
  107. 1
  108. ]
  109. =
  110. 3
  111. T
  112. 6
  113. \left[\begin{array}{cccc} { }^{0} \boldsymbol{T}_{3}^{-1}\left(\theta_{1}, \theta_{2}, \theta_{3}\right)^{0} \boldsymbol{T}_{6} & { }^{3}{ }^{3} \boldsymbol{T}_{4}\left(\theta_{4}\right){ }^{4} \boldsymbol{T}_{5}\left(\theta_{5}\right)^{5} \boldsymbol{T}_{6}\left(\theta_{6}\right) \\ -c_{1} s_{23} & -s_{1} s_{23} & -s_{23} & -a_{23} c_{3} \\ -s_{1} & c_{1} & 0 & -a_{2} s_{3} \\ 0 & 0 & 0 & 1 \end{array}\right]\left[\begin{array}{cccc} n_{x} & o_{x} & a_{x} & p_{x} \\ n_{y} & o_{y} & a_{y} & p_{y} \\ n_{z} & v_{z} & a_{z} & p_{z} \\ 0 & 0 & 0 & 1 \end{array}\right]={ }^{3} \boldsymbol{T}_{6}
  114. ⎣⎢⎢⎡​0T31​(θ1​,θ2​,θ3​)0T6​−c1s23​−s1033T4​(θ4​)4T5​(θ5​)5T6​(θ6​)−s1s23c10​−s2300​−a23c3​−a2s31​⎦⎥⎥⎤​⎣⎢⎢⎡​nxnynz0oxoyvz0axayaz0pxpypz1​⎦⎥⎥⎤​=3T6

式中,变换

  1. 3
  2. T
  3. 6
  4. { }^{3} \boldsymbol{T}_{6}
  5. 3T6 由正解出来的矩阵推出。令上式矩阵方程两边的元素
  6. (
  7. 1
  8. ,
  9. 4
  10. )
  11. (1,4)
  12. (1,4) (2.4) 分别对应 相等可得
  13. c
  14. 1
  15. c
  16. 23
  17. p
  18. x
  19. +
  20. s
  21. 1
  22. c
  23. 23
  24. p
  25. y
  26. s
  27. 23
  28. p
  29. z
  30. a
  31. 2
  32. c
  33. 3
  34. =
  35. a
  36. 3
  37. c
  38. 1
  39. s
  40. 23
  41. p
  42. z
  43. s
  44. 1
  45. s
  46. 23
  47. p
  48. y
  49. c
  50. 23
  51. p
  52. z
  53. +
  54. a
  55. 2
  56. s
  57. 3
  58. =
  59. d
  60. 4
  61. }
  62. \left.\begin{array}{l} c_{1} c_{23} p_{x}+s_{1} c_{23} p_{y}-s_{23} p_{z}-a_{2} c_{3}=a_{3} \\ -c_{1} s_{23} p_{z}-s_{1} s_{23} p_{y}-c_{23} p_{z}+a_{2} s_{3}=d_{4} \end{array}\right\}
  63. c1c23px​+s1c23py​−s23pz​−a2c3​=a3​−c1s23pz​−s1s23py​−c23pz​+a2s3​=d4​​}联立求解得
  64. s
  65. 23
  66. s_{23}
  67. s23
  68. c
  69. 23
  70. c_{23}
  71. c23
  72. {
  73. s
  74. 23
  75. =
  76. (
  77. a
  78. 3
  79. a
  80. 2
  81. c
  82. 3
  83. )
  84. p
  85. z
  86. +
  87. (
  88. c
  89. 1
  90. p
  91. x
  92. +
  93. s
  94. 1
  95. p
  96. y
  97. )
  98. (
  99. a
  100. 2
  101. s
  102. 3
  103. d
  104. 4
  105. )
  106. p
  107. 2
  108. 2
  109. +
  110. (
  111. c
  112. 1
  113. p
  114. x
  115. +
  116. s
  117. 1
  118. p
  119. y
  120. )
  121. 2
  122. c
  123. 23
  124. =
  125. (
  126. d
  127. 4
  128. +
  129. a
  130. 2
  131. s
  132. 3
  133. )
  134. p
  135. z
  136. (
  137. c
  138. 1
  139. p
  140. x
  141. +
  142. s
  143. 1
  144. p
  145. y
  146. )
  147. (
  148. a
  149. 2
  150. c
  151. 3
  152. a
  153. 4
  154. )
  155. p
  156. z
  157. 2
  158. +
  159. (
  160. c
  161. 1
  162. p
  163. x
  164. +
  165. s
  166. 1
  167. p
  168. y
  169. )
  170. 2
  171. \left\{\begin{array}{l} s_{23}=\frac{\left(-a_{3}-a_{2} c_{3}\right) p_{z}+\left(c_{1} p_{x}+s_{1} p_{y}\right)\left(a_{2} s_{3}-d_{4}\right)}{p_{2}^{2}+\left(c_{1} p_{x}+s_{1} p_{y}\right)^{2}} \\ c_{23}=\frac{\left(-d_{4}+a_{2} s_{3}\right) p_{z}-\left(c_{1} p_{x}+s_{1} p_{y}\right)\left(-a_{2} c_{3}-a_{4}\right)}{p_{z}^{2}+\left(c_{1} p_{x}+s_{1} p_{y}\right)^{2}} \end{array}\right.
  172. {s23​=p22​+(c1px​+s1py​)2(−a3​−a2c3​)pz​+(c1px​+s1py​)(a2s3​−d4​)​c23​=pz2​+(c1px​+s1py​)2(−d4​+a2s3​)pz​−(c1px​+s1py​)(−a2c3​−a4​)​​
  173. s
  174. 23
  175. s_{23}
  176. s23
  177. c
  178. 23
  179. c_{23}
  180. c23 表达式的分母相等,且为正。于是
  181. θ
  182. 23
  183. =
  184. θ
  185. 2
  186. +
  187. θ
  188. 3
  189. =
  190. atan2
  191. [
  192. (
  193. a
  194. 3
  195. +
  196. a
  197. 2
  198. c
  199. 3
  200. )
  201. p
  202. z
  203. +
  204. (
  205. c
  206. 1
  207. p
  208. x
  209. +
  210. s
  211. 1
  212. p
  213. y
  214. )
  215. (
  216. a
  217. 2
  218. s
  219. 3
  220. d
  221. 4
  222. )
  223. ,
  224. (
  225. d
  226. 4
  227. +
  228. a
  229. 2
  230. s
  231. 3
  232. )
  233. p
  234. x
  235. +
  236. (
  237. c
  238. 1
  239. p
  240. x
  241. +
  242. s
  243. 1
  244. p
  245. y
  246. )
  247. (
  248. a
  249. 2
  250. c
  251. 3
  252. +
  253. a
  254. 3
  255. )
  256. ]
  257. \begin{aligned} \theta_{23}=\theta_{2}+\theta_{3}=& \operatorname{atan2}\left[-\left(a_{3}+a_{2} c_{3}\right) p_{z}+\left(c_{1} p_{x}+s_{1} p_{y}\right)\left(a_{2} s_{3}-d_{4}\right),\left(-d_{4}+a_{2} s_{3}\right) p_{x}\right.\\ &\left.+\left(c_{1} p_{x}+s_{1} p_{y}\right)\left(a_{2} c_{3}+a_{3}\right)\right] \end{aligned}
  258. θ23​=θ2​+θ3​=​atan2[−(a3​+a2c3​)pz​+(c1px​+s1py​)(a2s3​−d4​),(−d4​+a2s3​)px​+(c1px​+s1py​)(a2c3​+a3​)]​

根据

  1. θ
  2. 1
  3. \theta_{1}
  4. θ1
  5. θ
  6. 3
  7. \theta_{3}
  8. θ3 解的四种可能组合,由上式可以得到相应的四种可能值
  9. θ
  10. 23
  11. \theta_{23}
  12. θ23​,于是可得到
  13. θ
  14. 2
  15. \theta_{2}
  16. θ2 的四种可能解
  17. θ
  18. 2
  19. =
  20. θ
  21. 23
  22. θ
  23. 3
  24. \theta_{2}=\theta_{23}-\theta_{3}
  25. θ2​=θ23​−θ3

式中,

  1. θ
  2. 2
  3. \theta_{2}
  4. θ2 取与
  5. θ
  6. 3
  7. \theta_{3}
  8. θ3 相对应的值。
    1. θ
    2. 4
    3. \theta_{4}

    θ4​

因为式 (3.75) 的左边均为已知,令两边元素

  1. (
  2. 1
  3. ,
  4. 3
  5. )
  6. (1,3)
  7. (1,3)
  8. (
  9. 3
  10. ,
  11. 3
  12. )
  13. (3,3)
  14. (3,3) 分别对应相等,则可得
  15. {
  16. a
  17. x
  18. c
  19. 1
  20. c
  21. 23
  22. +
  23. a
  24. y
  25. s
  26. 1
  27. c
  28. 23
  29. a
  30. x
  31. s
  32. 23
  33. =
  34. c
  35. 4
  36. s
  37. 5
  38. a
  39. x
  40. s
  41. y
  42. +
  43. a
  44. y
  45. c
  46. 1
  47. =
  48. s
  49. 4
  50. s
  51. 5
  52. \left\{\begin{array}{l} a_{x} c_{1} c_{23}+a_{y} s_{1} c_{23}-a_{x} s_{23}=-c_{4} s_{5} \\ -a_{x} s_{y}+a_{y} c_{1}=s_{4} s_{5} \end{array}\right.
  53. {axc1c23​+ays1c23​−axs23​=−c4s5​−axsy​+ayc1​=s4s5​​

只要

  1. s
  2. 5
  3. 0
  4. s_{5} \neq 0
  5. s5​​=0,便可求出
  6. θ
  7. 4
  8. \theta_{4}
  9. θ4
  10. θ
  11. 4
  12. =
  13. atan
  14. 2
  15. (
  16. a
  17. 4
  18. s
  19. 1
  20. +
  21. a
  22. y
  23. c
  24. 1
  25. ,
  26. a
  27. x
  28. c
  29. 1
  30. c
  31. 23
  32. a
  33. y
  34. s
  35. 1
  36. c
  37. 23
  38. +
  39. a
  40. x
  41. s
  42. 23
  43. )
  44. \theta_{4}=\operatorname{atan} 2\left(-a_{4} s_{1}+a_{y} c_{1},-a_{x} c_{1} c_{23}-a_{y} s_{1} c_{23}+a_{x} s_{23}\right)
  45. θ4​=atan2(−a4s1​+ayc1​,−axc1c23​−ays1c23​+axs23​)

  1. s
  2. 5
  3. =
  4. 0
  5. s_{5}=0
  6. s5​=0 时,机械手处于奇㫒形位。此时,关节轴 4 6 重合,只能解出
  7. θ
  8. 4
  9. \theta_{4}
  10. θ4
  11. θ
  12. 6
  13. \theta_{6}
  14. θ6 的和或 差。奇异形位可以由式 (3.79)中
  15. atan
  16. 2
  17. \operatorname{atan} 2
  18. atan2 的两个变量是否都接近零来判别。若都接近零,则为奇异形位,否则,不是奇异形位。在奇异形位时,可任意选取
  19. θ
  20. 4
  21. \theta_{4}
  22. θ4 的值,再计箅相应的
  23. θ
  24. 6
  25. \theta_{6}
  26. θ6 值。
    1. θ
    2. 5
    3. \theta_{5}

    θ5​

据求出的

  1. θ
  2. 4
  3. \theta_{4}
  4. θ4​,可进一步解出
  5. θ
  6. 5
  7. \theta_{5}
  8. θ5​,将方程1两端左乘逆变换
  9. 0
  10. T
  11. 4
  12. (
  13. θ
  14. 1
  15. ,
  16. θ
  17. 2
  18. ,
  19. θ
  20. 3
  21. ,
  22. θ
  23. 4
  24. )
  25. { }^{0} \boldsymbol{T}_{4}{ }^{}\left(\theta_{1}, \theta_{2}, \theta_{3}, \theta_{4}\right)
  26. 0T4​(θ1​,θ2​,θ3​,θ4​),
  27. 0
  28. T
  29. 4
  30. 1
  31. (
  32. θ
  33. 1
  34. ,
  35. θ
  36. 2
  37. ,
  38. θ
  39. 3
  40. ,
  41. θ
  42. 4
  43. )
  44. 0
  45. T
  46. 6
  47. =
  48. 4
  49. T
  50. 5
  51. (
  52. θ
  53. 5
  54. )
  55. 5
  56. T
  57. 6
  58. (
  59. θ
  60. 6
  61. )
  62. { }^{0} \boldsymbol{T}_{4}^{-1}\left(\theta_{1}, \theta_{2}, \theta_{3}, \theta_{4}\right){ }^{0} \boldsymbol{T}_{6}={ }^{4} \boldsymbol{T}_{5}\left(\theta_{5}\right)^{5} \boldsymbol{T}_{6}\left(\theta_{6}\right)
  63. 0T41​(θ1​,θ2​,θ3​,θ4​)0T6​=4T5​(θ5​)5T6​(θ6​)

因下面方程式的左边

  1. θ
  2. 1
  3. ,
  4. θ
  5. 2
  6. ,
  7. θ
  8. 3
  9. \theta_{1}, \theta_{2}, \theta_{3}
  10. θ1​,θ2​,θ3
  11. θ
  12. 4
  13. \theta_{4}
  14. θ4 均已解出, 逆变换
  15. 0
  16. T
  17. 4
  18. 1
  19. (
  20. θ
  21. 1
  22. ,
  23. θ
  24. 2
  25. ,
  26. θ
  27. 3
  28. ,
  29. θ
  30. 4
  31. )
  32. { }^{0} T_{4}^{-1}\left(\theta_{1}, \theta_{2}, \theta_{3}, \theta_{4}\right)
  33. 0T41​(θ1​,θ2​,θ3​,θ4​)
  34. [
  35. c
  36. 1
  37. c
  38. 23
  39. c
  40. 4
  41. +
  42. s
  43. 1
  44. s
  45. 4
  46. s
  47. 1
  48. c
  49. 23
  50. c
  51. 4
  52. c
  53. 1
  54. s
  55. 4
  56. s
  57. 23
  58. c
  59. 4
  60. a
  61. 2
  62. c
  63. 3
  64. c
  65. 4
  66. +
  67. d
  68. 2
  69. s
  70. 4
  71. a
  72. 3
  73. c
  74. 4
  75. c
  76. 1
  77. c
  78. 23
  79. s
  80. 4
  81. +
  82. s
  83. 1
  84. c
  85. 4
  86. s
  87. 1
  88. c
  89. 23
  90. s
  91. 4
  92. c
  93. 1
  94. c
  95. 4
  96. s
  97. 23
  98. s
  99. 4
  100. a
  101. 2
  102. c
  103. 3
  104. s
  105. 4
  106. +
  107. d
  108. 2
  109. c
  110. 4
  111. +
  112. a
  113. 3
  114. s
  115. 4
  116. c
  117. 1
  118. s
  119. 23
  120. s
  121. 1
  122. s
  123. 23
  124. c
  125. 23
  126. a
  127. 2
  128. s
  129. 3
  130. d
  131. 4
  132. 0
  133. 0
  134. 0
  135. 1
  136. ]
  137. \left[\begin{array}{cccc} c_{1} c_{23} c_{4}+s_{1} s_{4} & s_{1} c_{23} c_{4}-c_{1} s_{4} & -s_{23} c_{4} & -a_{2} c_{3} c_{4}+d_{2} s_{4}-a_{3} c_{4} \\ -c_{1} c_{23} s_{4}+s_{1} c_{4} & -s_{1} c_{23} s_{4}-c_{1} c_{4} & s_{23} s_{4} & a_{2} c_{3} s_{4}+d_{2} c_{4}+a_{3} s_{4} \\ -c_{1} s_{23} & -s_{1} s_{23} & -c_{23} & a_{2} s_{3}-d_{4} \\ 0 & 0 & 0 & 1 \end{array}\right]
  138. ⎣⎢⎢⎡​c1c23c4​+s1s4​−c1c23s4​+s1c4​−c1s230s1c23c4​−c1s4​−s1c23s4​−c1c4​−s1s230​−s23c4s23s4​−c230​−a2c3c4​+d2s4​−a3c4a2c3s4​+d2c4​+a3s4a2s3​−d41​⎦⎥⎥⎤​

上式方程式的右边

  1. 4
  2. T
  3. 6
  4. (
  5. θ
  6. 5
  7. ,
  8. θ
  9. 6
  10. )
  11. =
  12. 4
  13. T
  14. 5
  15. (
  16. θ
  17. 5
  18. )
  19. 5
  20. T
  21. 6
  22. (
  23. θ
  24. 6
  25. )
  26. { }^{4} \boldsymbol{T}_{6}\left(\theta_{5}, \theta_{6}\right)={ }^{4} \boldsymbol{T}_{5 } \left(\theta_{5}\right){ }^{5} \boldsymbol{T}_{6}\left(\theta_{6}\right)
  27. 4T6​(θ5​,θ6​)=4T5​(θ5​)5T6​(θ6​),由正解得到的
  28. 4
  29. T
  30. 6
  31. { }^{4} \boldsymbol{T}_{6}
  32. 4T6​给出。据矩阵两边元素
  33. (
  34. 1
  35. ,
  36. 3
  37. )
  38. (1,3)
  39. (1,3)
  40. (
  41. 3
  42. ,
  43. 3
  44. )
  45. (3,3)
  46. (3,3) 分别对应相等,可得
  47. a
  48. x
  49. (
  50. c
  51. 1
  52. c
  53. 23
  54. c
  55. 4
  56. +
  57. s
  58. 1
  59. s
  60. 4
  61. )
  62. +
  63. a
  64. y
  65. (
  66. s
  67. 1
  68. c
  69. 23
  70. c
  71. 4
  72. c
  73. 1
  74. s
  75. 4
  76. )
  77. a
  78. z
  79. (
  80. s
  81. 23
  82. c
  83. 4
  84. )
  85. =
  86. s
  87. 5
  88. a
  89. x
  90. (
  91. c
  92. 1
  93. s
  94. 23
  95. )
  96. +
  97. a
  98. y
  99. (
  100. s
  101. i
  102. s
  103. 23
  104. )
  105. +
  106. a
  107. z
  108. (
  109. c
  110. 23
  111. )
  112. =
  113. c
  114. 5
  115. }
  116. \left.\begin{array}{l} a_{x}\left(c_{1} c_{23} c_{4}+s_{1} s_{4}\right)+a_{y}\left(s_{1} c_{23} c_{4}-c_{1} s_{4}\right)-a_{z}\left(s_{23} c_{4}\right)&=-s_{5} \\ a_{x}\left(-c_{1} s_{23}\right)+a_{y}\left(-s_{i} s_{23}\right)+a_{z}\left(-c_{23}\right)&=c_{5} \end{array}\right\}
  117. ax​(c1c23c4​+s1s4​)+ay​(s1c23c4​−c1s4​)−az​(s23c4​)ax​(−c1s23​)+ay​(−sis23​)+az​(−c23​)​=−s5​=c5​​}

由此得到

  1. θ
  2. 5
  3. \theta_{5}
  4. θ5 的封闭解
  5. θ
  6. 5
  7. =
  8. atan
  9. 2
  10. (
  11. s
  12. 5
  13. ,
  14. c
  15. 5
  16. )
  17. \theta_{5}=\operatorname{atan} 2\left(s_{5}, c_{5}\right)
  18. θ5​=atan2(s5​,c5​)
    1. θ
    2. 6
    3. \theta_{6}

    θ6​

将方程式1改写为

  1. 0
  2. T
  3. 5
  4. 1
  5. (
  6. θ
  7. 1
  8. ,
  9. θ
  10. 2
  11. ,
  12. ,
  13. θ
  14. 5
  15. )
  16. 0
  17. T
  18. 6
  19. =
  20. 5
  21. T
  22. 6
  23. (
  24. θ
  25. 6
  26. )
  27. { }^{0} \boldsymbol{T}_{5}{ }^{1}\left(\theta_{1}, \theta_{2}, \cdots, \theta_{5}\right)^{0} \boldsymbol{T}_{6}={ }^{5} \boldsymbol{T}_{6}\left(\theta_{6}\right)
  28. 0T511​,θ2​,⋯,θ5​)0T6​=5T6​(θ6​)

令上式的矩阵方程两边元素

  1. (
  2. 3
  3. ,
  4. 1
  5. )
  6. (3,1)
  7. (3,1)
  8. (
  9. 1
  10. ,
  11. 1
  12. )
  13. (1,1)
  14. (1,1) 分别对应相等,可得
  15. n
  16. x
  17. (
  18. c
  19. 1
  20. c
  21. 23
  22. s
  23. 4
  24. s
  25. 1
  26. c
  27. 4
  28. )
  29. n
  30. y
  31. (
  32. s
  33. 1
  34. c
  35. 23
  36. s
  37. 4
  38. +
  39. c
  40. 1
  41. c
  42. 4
  43. )
  44. +
  45. n
  46. z
  47. (
  48. s
  49. 23
  50. s
  51. 4
  52. )
  53. =
  54. s
  55. 6
  56. n
  57. z
  58. [
  59. (
  60. c
  61. 1
  62. c
  63. 23
  64. c
  65. +
  66. +
  67. s
  68. 1
  69. s
  70. 4
  71. )
  72. c
  73. 5
  74. c
  75. s
  76. 23
  77. s
  78. 5
  79. ]
  80. +
  81. n
  82. y
  83. [
  84. (
  85. s
  86. 1
  87. c
  88. 23
  89. c
  90. 4
  91. c
  92. 1
  93. s
  94. 4
  95. )
  96. c
  97. 5
  98. s
  99. 1
  100. s
  101. 23
  102. s
  103. 5
  104. ]
  105. n
  106. z
  107. (
  108. s
  109. 23
  110. c
  111. 4
  112. c
  113. 5
  114. +
  115. c
  116. 23
  117. s
  118. 5
  119. )
  120. =
  121. c
  122. 6
  123. \begin{aligned} -n_{x}\left(c_{1} c_{23} s_{4}-s_{1} c_{4}\right)-n_{y}\left(s_{1} c_{23} s_{4}+c_{1} c_{4}\right)+n_{z}\left(s_{23} s_{4}\right)&=s_{6} \\ n_{z}\left[\left(c_{1} c_{23} c_{+}+s_{1} s_{4}\right) c_{5}-c s_{23} s_{5}\right]+n_{y}\left[\left(s_{1} c_{23} c_{4}-c_{1} s_{4}\right) c_{5}-s_{1} s_{23} s_{5}\right] &-n_{z}\left(s_{23} c_{4} c_{5}+c_{23} s_{5}\right)&=c_{6} \end{aligned}
  124. nx​(c1c23s4​−s1c4​)−ny​(s1c23s4​+c1c4​)+nz​(s23s4​)nz​[(c1c23c+​+s1s4​)c5​−cs23s5​]+ny​[(s1c23c4​−c1s4​)c5​−s1s23s5​]​=s6​−nz​(s23c4c5​+c23s5​)​=c6​​

从而可求出

  1. θ
  2. 6
  3. \theta_{6}
  4. θ6 的封闭解
  5. θ
  6. 6
  7. =
  8. atan
  9. 2
  10. (
  11. s
  12. 6
  13. ,
  14. c
  15. 6
  16. )
  17. \theta_{6}=\operatorname{atan} 2\left(s_{6}, c_{6}\right)
  18. θ6​=atan2(s6​,c6​)六自由度机器人的运动学反解可能存在
  19. 8
  20. 8
  21. 8种解。但是,由于结构的限制,例如各关节变量不 能在全部
  22. 36
  23. 0
  24. 360^{\circ}
  25. 360 范围内运动,有些解不能实现。在机器人存在多种解的情况下,应选取其中满意的一组解,以满足机器人的工作要求。

后续更新简单理解的步骤

二、代码实现

1. 机器人模型的建立

根据往期文章,对六自由度机器人具体建模方法可参阅以下文章:

  • 定义标准型及改进型D-H参数建立机器人模型(附MATLAB建模代码)
  • 【Matlab 六自由度机器人】关于改进型D-H参数(modified Denavit-Hartenberg)的详细建立步骤

2. Pieper 法求六自由度机器人逆解

建立好机器人模型后,已知期望位姿的矩阵

  1. a
  2. a
  3. a。将所求解的机器人的模型放入逆解脚本中,脚本的输入为期望位姿矩阵
  4. a
  5. a
  6. a,输出为角度
  7. J
  8. J
  9. J

代码如下:

  1. function [J]= MODikine(a)%% MOD-DH参数
  2. %定义连杆的D-H参数
  3. %连杆偏移
  4. d1 =398;
  5. d2 =-0.299;
  6. d3 =0;
  7. d4 =556.925;
  8. d5 =0;
  9. d6 =165;%连杆长度
  10. a1 =0;
  11. a2 =168.3;
  12. a3 =650.979;
  13. a4 =156.240;
  14. a5 =0;
  15. a6 =0;%连杆扭角
  16. alpha1 =0;
  17. alpha2 = pi/2;
  18. alpha3 =0;
  19. alpha4 = pi/2;
  20. alpha5 =-pi/2;
  21. alpha6 = pi/2;%%
  22. nx=a(1,1);ox=a(1,2);ax=a(1,3);px=a(1,4);
  23. ny=a(2,1);oy=a(2,2);ay=a(2,3);py=a(2,4);
  24. nz=a(3,1);oz=a(3,2);az=a(3,3);pz=a(3,4);% 求解关节角1
  25. theta1_1 = atan2(py,px)-atan2(d2,sqrt(px^2+py^2-d2^2));
  26. theta1_2 = atan2(py,px)-atan2(d2,-sqrt(px^2+py^2-d2^2));% 求解关节角3
  27. m3_1 =(px^2+py^2+pz^2-a2^2-a3^2-d2^2-d4^2)/(2*a2);
  28. theta3_1 = atan2(a3,d4)-atan2(m3_1,sqrt(a3^2+d4^2-m3_1^2));
  29. theta3_2 = atan2(a3,d4)-atan2(m3_1,-sqrt(a3^2+d4^2-m3_1^2));% 求解关节角2
  30. ms2_1 =-((a3+a2*cos(theta3_1))*pz)+(cos(theta1_1)*px+sin(theta1_1)*py)*(a2*sin(theta3_1)-d4);
  31. mc2_1 =(-d4+a2*sin(theta3_1))*pz+(cos(theta1_1)*px+sin(theta1_1)*py)*(a2*cos(theta3_1)+a3);
  32. theta23_1 = atan2(ms2_1,mc2_1);
  33. theta2_1 = theta23_1 - theta3_1;
  34. ms2_2 =-((a3+a2*cos(theta3_1))*pz)+(cos(theta1_2)*px+sin(theta1_2)*py)*(a2*sin(theta3_1)-d4);
  35. mc2_2 =(-d4+a2*sin(theta3_1))*pz+(cos(theta1_2)*px+sin(theta1_2)*py)*(a2*cos(theta3_1)+a3);
  36. theta23_2 = atan2(ms2_2,mc2_2);
  37. theta2_2 = theta23_2 - theta3_1;
  38. ms2_3 =-((a3+a2*cos(theta3_2))*pz)+(cos(theta1_1)*px+sin(theta1_1)*py)*(a2*sin(theta3_2)-d4);
  39. mc2_3 =(-d4+a2*sin(theta3_2))*pz+(cos(theta1_1)*px+sin(theta1_1)*py)*(a2*cos(theta3_2)+a3);
  40. theta23_3 = atan2(ms2_3,mc2_3);
  41. theta2_3 = theta23_3 - theta3_2;
  42. ms2_4 =-((a3+a2*cos(theta3_2))*pz)+(cos(theta1_2)*px+sin(theta1_2)*py)*(a2*sin(theta3_2)-d4);
  43. mc2_4 =(-d4+a2*sin(theta3_2))*pz+(cos(theta1_2)*px+sin(theta1_2)*py)*(a2*cos(theta3_2)+a3);
  44. theta23_4 = atan2(ms2_4,mc2_4);
  45. theta2_4 = theta23_4 - theta3_2;% 求解关节角4
  46. ms4_1=-ax*sin(theta1_1)+ay*cos(theta1_1);
  47. mc4_1=-ax*cos(theta1_1)*cos(theta23_1)-ay*sin(theta1_1)*cos(theta23_1)+az*sin(theta23_1);
  48. theta4_1=atan2(ms4_1,mc4_1);
  49. ms4_2=-ax*sin(theta1_2)+ay*cos(theta1_2);
  50. mc4_2=-ax*cos(theta1_2)*cos(theta23_2)-ay*sin(theta1_2)*cos(theta23_2)+az*sin(theta23_2);
  51. theta4_2=atan2(ms4_2,mc4_2);
  52. ms4_3=-ax*sin(theta1_1)+ay*cos(theta1_1);
  53. mc4_3=-ax*cos(theta1_1)*cos(theta23_3)-ay*sin(theta1_1)*cos(theta23_3)+az*sin(theta23_3);
  54. theta4_3=atan2(ms4_3,mc4_3);
  55. ms4_4=-ax*sin(theta1_2)+ay*cos(theta1_2);
  56. mc4_4=-ax*cos(theta1_2)*cos(theta23_4)-ay*sin(theta1_2)*cos(theta23_4)+az*sin(theta23_4);
  57. theta4_4=atan2(ms4_4,mc4_4);% 求解关节角5
  58. ms5_1=-ax*(cos(theta1_1)*cos(theta23_1)*cos(theta4_1)+sin(theta1_1)*sin(theta4_1))-ay*(sin(theta1_1)*cos(theta23_1)*cos(theta4_1)-cos(theta1_1)*sin(theta4_1))+az*(sin(theta23_1)*cos(theta4_1));
  59. mc5_1= ax*(-cos(theta1_1)*sin(theta23_1))+ay*(-sin(theta1_1)*sin(theta23_1))+az*(-cos(theta23_1));
  60. theta5_1=atan2(ms5_1,mc5_1);
  61. ms5_2=-ax*(cos(theta1_2)*cos(theta23_2)*cos(theta4_2)+sin(theta1_2)*sin(theta4_2))-ay*(sin(theta1_2)*cos(theta23_2)*cos(theta4_2)-cos(theta1_2)*sin(theta4_2))+az*(sin(theta23_2)*cos(theta4_2));
  62. mc5_2= ax*(-cos(theta1_2)*sin(theta23_2))+ay*(-sin(theta1_2)*sin(theta23_2))+az*(-cos(theta23_2));
  63. theta5_2=atan2(ms5_2,mc5_2);
  64. ms5_3=-ax*(cos(theta1_1)*cos(theta23_3)*cos(theta4_3)+sin(theta1_1)*sin(theta4_3))-ay*(sin(theta1_1)*cos(theta23_3)*cos(theta4_3)-cos(theta1_1)*sin(theta4_3))+az*(sin(theta23_3)*cos(theta4_3));
  65. mc5_3= ax*(-cos(theta1_1)*sin(theta23_3))+ay*(-sin(theta1_1)*sin(theta23_3))+az*(-cos(theta23_3));
  66. theta5_3=atan2(ms5_3,mc5_3);
  67. ms5_4=-ax*(cos(theta1_2)*cos(theta23_4)*cos(theta4_4)+sin(theta1_2)*sin(theta4_4))-ay*(sin(theta1_2)*cos(theta23_4)*cos(theta4_4)-cos(theta1_2)*sin(theta4_4))+az*(sin(theta23_4)*cos(theta4_4));
  68. mc5_4= ax*(-cos(theta1_2)*sin(theta23_4))+ay*(-sin(theta1_2)*sin(theta23_4))+az*(-cos(theta23_4));
  69. theta5_4=atan2(ms5_4,mc5_4);% 求解关节角6
  70. ms6_1=-nx*(cos(theta1_1)*cos(theta23_1)*sin(theta4_1)-sin(theta1_1)*cos(theta4_1))-ny*(sin(theta1_1)*cos(theta23_1)*sin(theta4_1)+cos(theta1_1)*cos(theta4_1))+nz*(sin(theta23_1)*sin(theta4_1));
  71. mc6_1= nx*(cos(theta1_1)*cos(theta23_1)*cos(theta4_1)+sin(theta1_1)*sin(theta4_1))*cos(theta5_1)-nx*cos(theta1_1)*sin(theta23_1)*sin(theta4_1)+ny*(sin(theta1_1)*cos(theta23_1)*cos(theta4_1)+cos(theta1_1)*sin(theta4_1))*cos(theta5_1)-ny*sin(theta1_1)*sin(theta23_1)*sin(theta5_1)-nz*(sin(theta23_1)*cos(theta4_1)*cos(theta5_1)+cos(theta23_1)*sin(theta5_1));
  72. theta6_1=atan2(ms6_1,mc6_1);
  73. ms6_2=-nx*(cos(theta1_2)*cos(theta23_2)*sin(theta4_2)-sin(theta1_2)*cos(theta4_2))-ny*(sin(theta1_2)*cos(theta23_2)*sin(theta4_2)+cos(theta1_2)*cos(theta4_2))+nz*(sin(theta23_2)*sin(theta4_2));
  74. mc6_2= nx*(cos(theta1_2)*cos(theta23_2)*cos(theta4_2)+sin(theta1_2)*sin(theta4_2))*cos(theta5_2)-nx*cos(theta1_2)*sin(theta23_2)*sin(theta4_2)+ny*(sin(theta1_2)*cos(theta23_2)*cos(theta4_2)+cos(theta1_2)*sin(theta4_2))*cos(theta5_2)-ny*sin(theta1_2)*sin(theta23_2)*sin(theta5_2)-nz*(sin(theta23_2)*cos(theta4_2)*cos(theta5_2)+cos(theta23_2)*sin(theta5_2));
  75. theta6_2=atan2(ms6_2,mc6_2);
  76. ms6_3=-nx*(cos(theta1_1)*cos(theta23_3)*sin(theta4_3)-sin(theta1_1)*cos(theta4_3))-ny*(sin(theta1_1)*cos(theta23_3)*sin(theta4_3)+cos(theta1_1)*cos(theta4_3))+nz*(sin(theta23_3)*sin(theta4_3));
  77. mc6_3= nx*(cos(theta1_1)*cos(theta23_3)*cos(theta4_3)+sin(theta1_1)*sin(theta4_3))*cos(theta5_3)-nx*cos(theta1_1)*sin(theta23_3)*sin(theta4_3)+ny*(sin(theta1_1)*cos(theta23_3)*cos(theta4_3)+cos(theta1_1)*sin(theta4_3))*cos(theta5_3)-ny*sin(theta1_1)*sin(theta23_3)*sin(theta5_3)-nz*(sin(theta23_3)*cos(theta4_3)*cos(theta5_3)+cos(theta23_3)*sin(theta5_3));
  78. theta6_3=atan2(ms6_3,mc6_3);
  79. ms6_4=-nx*(cos(theta1_2)*cos(theta23_4)*sin(theta4_4)-sin(theta1_2)*cos(theta4_4))-ny*(sin(theta1_1)*cos(theta23_4)*sin(theta4_4)+cos(theta1_2)*cos(theta4_4))+nz*(sin(theta23_4)*sin(theta4_4));
  80. mc6_4= nx*(cos(theta1_2)*cos(theta23_4)*cos(theta4_4)+sin(theta1_2)*sin(theta4_4))*cos(theta5_4)-nx*cos(theta1_2)*sin(theta23_4)*sin(theta4_4)+ny*(sin(theta1_2)*cos(theta23_4)*cos(theta4_4)+cos(theta1_2)*sin(theta4_4))*cos(theta5_1)-ny*sin(theta1_2)*sin(theta23_4)*sin(theta5_4)-nz*(sin(theta23_4)*cos(theta4_4)*cos(theta5_4)+cos(theta23_4)*sin(theta5_4));
  81. theta6_4=atan2(ms6_4,mc6_4);% 整理得到4组运动学非奇异逆解
  82. theta_MOD1 =[
  83. theta1_1,theta2_1,theta3_1,theta4_1,theta5_1,theta6_1;
  84. theta1_2,theta2_2,theta3_1,theta4_2,theta5_2,theta6_2;
  85. theta1_1,theta2_3,theta3_2,theta4_3,theta5_3,theta6_3;
  86. theta1_2,theta2_4,theta3_2,theta4_4,theta5_4,theta6_4;];% 将操作关节‘翻转’可得到另外4组解
  87. theta_MOD2 =...[
  88. theta1_1,theta2_1,theta3_1,theta4_1+pi,-theta5_1,theta6_1+pi;
  89. theta1_2,theta2_2,theta3_1,theta4_2+pi,-theta5_2,theta6_2+pi;
  90. theta1_1,theta2_3,theta3_2,theta4_3+pi,-theta5_3,theta6_3+pi;
  91. theta1_2,theta2_4,theta3_2,theta4_4+pi,-theta5_4,theta6_4+pi;];
  92. J =[theta_MOD1;theta_MOD2];
  93. end

3. 常规法求六自由度机器人逆解

由于自写的代码过长,阅读较为困难,因此贴上部分逆解代码过程。
建立好机器人模型后,已知期望位姿的矩阵

  1. a
  2. a
  3. a。将所求解的机器人的模型放入逆解脚本中,脚本的输入为期望位姿矩阵
  4. a
  5. a
  6. a,输出为角度
  7. J
  8. J
  9. J

这里的

  1. r
  2. o
  3. b
  4. o
  5. t
  6. robot
  7. robot代表的是机器人的模型,
  8. a
  9. a
  10. a是已知的期望位姿的矩阵,输出是各轴的角度
  11. J
  12. J
  13. J
  1. function [J]= Albert_MODikin(robot,a)%% MOD-DH参数
  2. %连杆偏移 %连杆长度 %连杆扭角
  3. d1 = robot.d(1);a1 = robot.a(1);alpha1 = robot.alpha(1);
  4. d2 = robot.d(2);a2 = robot.a(2);alpha2 = robot.alpha(2);
  5. d3 = robot.d(3);a3 = robot.a(3);alpha3 = robot.alpha(3);
  6. d4 = robot.d(4);a4 = robot.a(4);alpha4 = robot.alpha(4);
  7. d5 = robot.d(5);a5 = robot.a(5);alpha5 = robot.alpha(5);
  8. d6 = robot.d(6);a6 = robot.a(6);alpha6 = robot.alpha(6);%%
  9. nx=a(1,1);ox=a(1,2);ax=a(1,3);px=a(1,4);
  10. ny=a(2,1);oy=a(2,2);ay=a(2,3);py=a(2,4);
  11. nz=a(3,1);oz=a(3,2);az=a(3,3);pz=a(3,4);%j1
  12. j1a = py - ay*d6;
  13. j1b = px - ax*d6;
  14. j11 = atan2(j1a,j1b)-atan2(-d2, sqrt(j1a^2+j1b^2-d2^2));
  15. j12 = atan2(j1a,j1b)-atan2(-d2,-sqrt(j1a^2+j1b^2-d2^2));% 这部分是进行一个判断,将小于1e-16的数字看作0,建议删除。
  16. if j11<1e-16
  17. j11 =0;
  18. end
  19. if j12<1e-16
  20. j12 =0;
  21. end
  22. %j3
  23. j3a1 = px*cos(j11)- d6*(ax*cos(j11)+ ay*sin(j11))+ py*sin(j11)- a2;
  24. j3b1 = pz - d1 - az*d6;
  25. j3k1 = j3a1^2+ j3b1^2- a4^2- d4^2- a3^2;
  26. j3d1 = j3k1/(2*a3);
  27. j3a2 = px*cos(j12)- d6*(ax*cos(j12)+ ay*sin(j12))+ py*sin(j12)- a2;
  28. j3b2 = pz - d1 - az*d6;
  29. j3k2 = j3a2^2+ j3b2^2- a4^2- d4^2- a3^2;
  30. j3d2 = j3k2/(2*a3);
  31. j31 = atan2(j3d1, sqrt(abs(a4^2+ d4^2- j3d1^2)))- atan2(a4,d4);%j11
  32. j32 = atan2(j3d1,-sqrt(abs(a4^2+ d4^2- j3d1^2)))- atan2(a4,d4);%j11
  33. j33 = atan2(j3d2, sqrt(abs(a4^2+ d4^2- j3d2^2)))- atan2(a4,d4);%j12
  34. j34 = atan2(j3d2,-sqrt(abs(a4^2+ d4^2- j3d2^2)))- atan2(a4,d4);%j12
  35. % 经过一系列运算后,最终得到J
  36. J =[j11 j21 j31 j41 j51 j61;
  37. j11 j22 j32 j42 j52 j62;
  38. j12 j23 j33 j43 j53 j63;
  39. j12 j24 j34 j44 j54 j64;
  40. j11 j21 j31 j45 j55 j65;
  41. j11 j22 j32 j46 j56 j66;
  42. j12 j23 j33 j47 j57 j67;
  43. j12 j24 j34 j48 j58 j68];
  44. end

程序运行后的结果如下:
在这里插入图片描述
我们可以看到,左侧机器人示教器中,第二根轴的角度设为

  1. 6
  2. 0
  3. 60^{\circ}
  4. 60∘,其位置矩阵为
  5. [
  6. 99.234
  7. ,
  8. 0
  9. ,
  10. 2605.139
  11. ]
  12. [-99.234,0,2605.139]
  13. [−99.234,0,2605.139]。右上方正解的最后一列完全对应,右下方逆解得到的数值与输入的角度数一致,因此可知逆解程序完全可行。

总结

以上就是逆向运动学的内容,本文详细介绍了如何理解运动学逆解,以及对运动学逆解的求解方法的罗列及原理说明。最后对运动学逆解实现代码的编程,使逆解能够有效得到目标位姿所对应的各轴转角。

参考文献

  1. MATLAB机器人工具箱【1】——建模+正逆运动学+雅克比矩阵
  2. 六轴机器人matlab写运动学逆解函数(改进DH模型)
  3. 六轴机器人建模方法、正逆解、轨迹规划实例与Matalb Robotic Toolbox 的实现

本文转载自: https://blog.csdn.net/AlbertDS/article/details/123679114
版权归原作者 Albert_Lsk 所有, 如有侵权,请联系我们删除。

“【Matlab 六自由度机器人】运动学逆解(附MATLAB机器人逆解代码)”的评论:

还没有评论