AI Wiki中文/EN

机器人运动学:从关节角到末端位姿

Robot kinematics

用三角公式、连杆坐标系连乘与指数积公式计算串联机械臂的正向运动学,读懂 Denavit–Hartenberg 参数表,并理解两种参数化在近平行轴附近为何表现不同。

本页目录直觉理解数学与方法代码实现局限与误解实验与练习研究脉络

电机报告角度,任务需要位姿

机械臂的编码器报告的是关节角。但拿起杯子或焊一条焊缝这类任务,是用夹爪在哪里、朝向哪里来描述的。正向运动学(正运动学)用于连接两者:给定关节坐标,计算末端执行器坐标系的位置与姿态。对于有固定基座坐标系 {s}\{s\} 与末端执行器坐标系 {b}\{b\} 的开链,Lynch 与 Park 把它定义为映射 T(θ)T(\theta):以关节向量 θ\theta 为自变量,给出 {b}\{b\} 在 {s}\{s\} 中的构型。正向运动学

对于有三个转动关节的平面机械臂(3R 机械臂),答案就是中学三角:将各连杆长度按累积角度依次相加。这种做法很快就行不通了。六关节工业机械臂的各轴指向不同,轴之间有偏距,工具还斜着安装,手写三角公式很容易出符号错误。因此机器人学使用两种系统的方法:给每根连杆固连一个坐标系,再把相邻连杆之间的变换连乘(Denavit–Hartenberg 约定是选择这些坐标系的经典方法);或者在零位构型下把每个关节描述成一条螺旋轴,再把矩阵指数连乘(指数积公式,PoE)。

本文逐一讲解这两种方法,并在代码中相互核对。文中用到的 SO(3)、SE(3)、齐次矩阵与螺旋指数见刚体变换。反过来为期望位姿求关节值是逆运动学;速度属于机械臂的雅可比矩阵;力与力矩属于机器人动力学。

同一个映射的三种写法

平面链的三角公式。 对连杆长度为 L1,L2,L3L_1,L_2,L_3 的平面 3R 机械臂,末端位置与朝向为

x=L1cos⁡θ1+L2cos⁡(θ1+θ2)+L3cos⁡(θ1+θ2+θ3)x=L_1\cos\theta_1+L_2\cos(\theta_1+\theta_2)+L_3\cos(\theta_1+\theta_2+\theta_3) y=L1sin⁡θ1+L2sin⁡(θ1+θ2)+L3sin⁡(θ1+θ2+θ3),ϕ=θ1+θ2+θ3y=L_1\sin\theta_1+L_2\sin(\theta_1+\theta_2)+L_3\sin(\theta_1+\theta_2+\theta_3),\qquad \phi=\theta_1+\theta_2+\theta_3

如果只关心位置,任务空间就是平面,朝向方程可以去掉。平面 3R

连杆坐标系连乘。 更系统的做法是给每根连杆固连坐标系 {i}\{i\},写出每个坐标系相对前一个坐标系的构型。每个因子只依赖自己的关节值,按下标消去规则得到

T0,n(θ)=T01(θ1) T12(θ2)⋯Tn−1,n(θn)T_{0,n}(\theta)=T_{01}(\theta_1)\,T_{12}(\theta_2)\cdots T_{n-1,n}(\theta_n)

如果工具坐标系与最后一个连杆坐标系不同,末尾再乘一个常数因子。连杆坐标系连乘 这种方法好不好用,取决于放置坐标系的规则,而这正是 Denavit 与 Hartenberg 约定所提供的。

指数积公式。 Lynch 与 Park 的替代方法完全不需要连杆坐标系。选定零位构型 θ=0\theta=0,记下那时末端执行器的构型 MM。每个转动关节是一个节距为零的螺旋:在基座坐标系中,它的螺旋轴为 Si=(ωi,vi)\mathcal{S}_i=(\omega_i,v_i),其中 ωi\omega_i 是关节轴的单位方向,qiq_i 是轴上任意一点,

Si=[ωivi],vi=−ωi×qi\mathcal{S}_i=\begin{bmatrix}\omega_i\\ v_i\end{bmatrix},\qquad v_i=-\omega_i\times q_i

对于移动关节,ωi=0\omega_i=0,viv_i 是移动的单位方向。关节的螺旋轴 让关节 ii 转过 θi\theta_i,相当于施加刚体运动 e[Si]θie^{[\mathcal{S}_i]\theta_i};对单位转轴,其闭式(Lynch 与 Park 命题 3.25)为

e[S]θ=[e[ω]θ(Iθ+(1−cos⁡θ)[ω]+(θ−sin⁡θ)[ω]2)v01]e^{[\mathcal{S}]\theta}=\begin{bmatrix}e^{[\omega]\theta} & \big(I\theta+(1-\cos\theta)[\omega]+(\theta-\sin\theta)[\omega]^2\big)v\\ 0 & 1\end{bmatrix}

推导时先动最远端的关节,它带着 MM 一起运动,再向内动下一个关节,依此类推。每个关节对它外侧的所有连杆施加一次螺旋运动。结果就是 PoE 的空间形式;同一映射也可以用零位时在末端执行器坐标系中表示的螺旋轴 Bi\mathcal{B}_i 来写,即物体形式:

T(θ)=e[S1]θ1⋯e[Sn]θnM=M e[B1]θ1⋯e[Bn]θn,Bi=[AdM−1]SiT(\theta)=e^{[\mathcal{S}_1]\theta_1}\cdots e^{[\mathcal{S}_n]\theta_n}M=M\,e^{[\mathcal{B}_1]\theta_1}\cdots e^{[\mathcal{B}_n]\theta_n},\qquad \mathcal{B}_i=[\mathrm{Ad}_{M^{-1}}]\mathcal{S}_i

其中 AdX\mathrm{Ad}_X 是 X∈SE(3)X\in\mathrm{SE}(3) 的 6×6 伴随矩阵,物体形式由 eM−1PM=M−1ePMe^{M^{-1}PM}=M^{-1}e^{P}M 得出。空间形式与物体形式

关节轴会随机械臂运动而移动,为什么只需在零位找一次?从右向左读空间形式:关节 nn 先动,然后是关节 n−1n-1,依此类推。关节 ii 动作时,按这个顺序,它近端的关节还没有动,所以轴 ii 仍在零位时的位置。物体形式的论证方向相反:从末端执行器看,远端关节的轴不受近端运动影响。顺序 PoE 只需要三样东西:MM、nn 条螺旋轴和关节值,不需要任何中间坐标系。

Denavit–Hartenberg 参数。 D–H 约定用规则固定连杆坐标系,使每个连杆变换只需四个数。按 Lynch 与 Park 的版本,z^i\hat z_i 沿关节轴 ii;坐标系 {i−1}\{i-1\} 的原点位于轴 i−1i-1 与轴 ii 的公垂线和轴 i−1i-1 的交点;x^i−1\hat x_{i-1} 沿这条公垂线指向轴 ii;y^\hat y 按右手系补全。坐标系规则 四个参数是:

  • 连杆长度 ai−1a_{i-1}:公垂线的长度(不一定是连杆的物理长度);
  • 连杆扭角 αi−1\alpha_{i-1}:绕 x^i−1\hat x_{i-1} 从 z^i−1\hat z_{i-1} 转到 z^i\hat z_i 的角度;
  • 连杆偏距 did_i:沿 z^i\hat z_i 的距离;
  • 关节角 ϕi\phi_i:绕 z^i\hat z_i 从 x^i−1\hat x_{i-1} 转到 x^i\hat x_i 的角度。

对转动关节只有 ϕi\phi_i 变化;对移动关节 did_i 是变量。相邻轴相交时 a=0a=0,x^\hat x 垂直于两轴所在平面,符号可以任选。相邻轴平行时,公垂线有一个单参数族,通常选让许多参数为零的那一条。特殊情形 Lynch 与 Park 约定下的连杆变换为

Ti−1,i=Rot(x^,αi−1) Trans(x^,ai−1) Trans(z^,di) Rot(z^,ϕi)T_{i-1,i}=\mathrm{Rot}(\hat x,\alpha_{i-1})\,\mathrm{Trans}(\hat x,a_{i-1})\,\mathrm{Trans}(\hat z,d_i)\,\mathrm{Rot}(\hat z,\phi_i)

正向运动学就是这些变换的乘积。并非任意两个坐标系都能这样联系;例如沿 y^\hat y 的纯平移就不行,因为只允许绕 x^\hat x、z^\hat z 的旋转和沿它们的平移。正是坐标系规则让四个数足够,Lynch 与 Park 还转述,Denavit 与 Hartenberg 证明了四是最少的数目。为什么是四个

“D–H”不只指一种约定。 有些作者让关节轴沿 x^\hat x 而不是 z^\hat z,或者按不同顺序施加四个基本运动,所以一张 a,α,d,θa,\alpha,d,\theta 数值表若没有配套的坐标系图,就没有意义。约定差异 Hartenberg 与 Denavit 本人 1964 年的教材就是一个例子。他们把机构描述为一串运动副,每个连接由沿相邻副轴唯一公垂线量取的四个参数 a,α,θ,sa,\alpha,\theta,s 确定,xx 轴沿这些公垂线。他们先把机构写成符号方程,再把每一项替换为 4×4 矩阵。在他们的矩阵中,齐次坐标排在第一位:第一行是 (1, 0, 0, 0),第一列是 (acos⁡θ,asin⁡θ,s)(a\cos\theta,a\sin\theta,s),旋转块等于 Rot(z,θ)Rot(x,α)\mathrm{Rot}(z,\theta)\mathrm{Rot}(x,\alpha)。换句话说,他们的基本运动顺序是绕 zz 转、沿 zz 移、沿 xx 移、绕 xx 转:即把 Lynch 与 Park 序列中 xx 与 zz 的角色互换。矩阵方法 他们把转动副与移动副看作螺旋副的极限情形,导程分别为零和无穷大,同属六种低副。对于闭链,沿回路的矩阵乘积必须等于单位矩阵,A1A2A3A4=IA_1A_2A_3A_4=I,他们仅凭这一条件就用代数方法推出了万向节(虎克铰)的位移方程。闭合回路

D–H 与 PoE 的关系。 每个 D–H 连杆变换都可以写成 Ti−1,i=Mie[Ai]θiT_{i-1,i}=M_ie^{[A_i]\theta_i}。反复使用 MePM−1=eMPM−1Me^{P}M^{-1}=e^{MPM^{-1}},把每个指数移到左边,就得到空间形式的 PoE,其中 M=M1⋯MnM=M_1\cdots M_n,每个 Si\mathcal{S}_i 由 M1⋯Mi−1M_1\cdots M_{i-1} 对 AiA_i 作变换得到。从 D–H 到 PoE 两种描述的代价与行为不同。D–H 是最少参数的:Lynch 与 Park 对 nn 关节机器人计为 3n3n 个结构参数加 nn 个关节值。PoE 用 6n6n 个数描述螺旋轴,再加 nn 个关节值;我们补充一点:还需要给出 MM。参数数目 作为交换,PoE 允许任意选择基座与末端坐标系,不需要连杆坐标系,统一处理转动与移动关节,每个参数都有直接的几何意义。Lynch 与 Park 的结论是,对开链几乎没有理由优先用 D–H;他们也指出,大多数运动学文献使用的是 D–H。比较 他们的参考文献把 D–H 追溯到 Denavit 与 Hartenberg 1955 年发表于 ASME《Journal of Applied Mechanics》的论文,把 PoE 公式归于 Brockett(1983);这两篇论文我们只通过该参考文献得知。

四种必须一致的计算

程序是原创的 numpy 代码。它用一个固定种子(16)的随机数生成器产生 1000 个随机关节向量,运行约十分之一秒。相等性检查在最大元素差小于 1e-12 时打印“ok”。第 4 部分使用 Lynch 与 Park 例 4.1 与例 C.1 的空间 3R 链;其余几何全部是我们自己设定的。

import numpy as np


def skew(w):
    return np.array([[0.0, -w[2], w[1]], [w[2], 0.0, -w[0]], [-w[1], w[0], 0.0]])


def exp_screw(S, theta):
    w, v = np.asarray(S[:3], float), np.asarray(S[3:], float)
    T = np.eye(4)
    if np.linalg.norm(w) < 1e-12:
        T[:3, 3] = v * theta
        return T
    K = skew(w)
    T[:3, :3] = np.eye(3) + np.sin(theta) * K + (1 - np.cos(theta)) * K @ K
    G = np.eye(3) * theta + (1 - np.cos(theta)) * K + (theta - np.sin(theta)) * K @ K
    T[:3, 3] = G @ v
    return T


def adjoint(T):
    R, p = T[:3, :3], T[:3, 3]
    A = np.zeros((6, 6))
    A[:3, :3] = R
    A[3:, 3:] = R
    A[3:, :3] = skew(p) @ R
    return A


def inv_T(T):
    R, p = T[:3, :3], T[:3, 3]
    Ti = np.eye(4)
    Ti[:3, :3] = R.T
    Ti[:3, 3] = -R.T @ p
    return Ti


def fk_space(M, S_list, thetas):
    T = np.eye(4)
    for S, th in zip(S_list, thetas):
        T = T @ exp_screw(S, th)
    return T @ M


def fk_body(M, B_list, thetas):
    T = M.copy()
    for B, th in zip(B_list, thetas):
        T = T @ exp_screw(B, th)
    return T


def rot_x(a):
    T = np.eye(4)
    c, s = np.cos(a), np.sin(a)
    T[1:3, 1:3] = [[c, -s], [s, c]]
    return T


def rot_z(a):
    T = np.eye(4)
    c, s = np.cos(a), np.sin(a)
    T[:2, :2] = [[c, -s], [s, c]]
    return T


def trans(x, y, z):
    T = np.eye(4)
    T[:3, 3] = [x, y, z]
    return T


def dh_link(alpha_prev, a_prev, d, phi):
    return rot_x(alpha_prev) @ trans(a_prev, 0, 0) @ trans(0, 0, d) @ rot_z(phi)


def screw_revolute(w, q):
    w = np.asarray(w, float)
    return np.concatenate([w, -np.cross(w, q)])


def ok(err, tol=1e-12):
    return "ok" if err < tol else f"FAIL ({err:.1e})"


def fmt(v, d=4):
    return "[" + ", ".join(f"{x + 0.0:+.{d}f}" for x in np.ravel(v)) + "]"


L1, L2, L3 = 1.0, 0.8, 0.5
th = np.radians([30.0, 45.0, -60.0])

print("1. Planar 3R arm, L = (1.0, 0.8, 0.5), theta = (30, 45, -60) deg")
x = L1*np.cos(th[0]) + L2*np.cos(th[0]+th[1]) + L3*np.cos(th.sum())
y = L1*np.sin(th[0]) + L2*np.sin(th[0]+th[1]) + L3*np.sin(th.sum())
print(f"   trigonometry: x = {x:.4f}, y = {y:.4f}, phi = {np.degrees(th.sum()):.1f} deg")

T_chain = rot_z(th[0]) @ trans(L1, 0, 0) @ rot_z(th[1]) @ trans(L2, 0, 0) @ rot_z(th[2]) @ trans(L3, 0, 0)
M = trans(L1 + L2 + L3, 0, 0)
S_list = [screw_revolute([0, 0, 1], [0, 0, 0]),
          screw_revolute([0, 0, 1], [L1, 0, 0]),
          screw_revolute([0, 0, 1], [L1 + L2, 0, 0])]
print("   space screw axes S_i = (w, v):")
for i, S in enumerate(S_list, 1):
    print(f"     S{i} = {fmt(S, 2)}")
T_space = fk_space(M, S_list, th)
B_list = [np.linalg.solve(adjoint(M), S) for S in S_list]
print("   body screw axes B_i = Ad(M^-1) S_i:")
for i, B in enumerate(B_list, 1):
    print(f"     B{i} = {fmt(B, 2)}")
T_body = fk_body(M, B_list, th)
print("   T(theta) from PoE space form:")
for row in T_space[:3]:
    print("     ", fmt(row))
print(f"   link-frame product = PoE space: {ok(np.abs(T_chain - T_space).max())}")
print(f"   PoE body = PoE space:           {ok(np.abs(T_body - T_space).max())}")
print(f"   trig (x, y) = T[0:2, 3]:        {ok(abs(x - T_space[0, 3]) + abs(y - T_space[1, 3]))}")

print("2. The order of the exponentials matters")
T_rev = exp_screw(S_list[2], th[2]) @ exp_screw(S_list[1], th[1]) @ exp_screw(S_list[0], th[0]) @ M
print(f"   reversed product tip: ({T_rev[0, 3]:.4f}, {T_rev[1, 3]:.4f}) vs correct ({T_space[0, 3]:.4f}, {T_space[1, 3]:.4f})")

print("3. Many joint vectors, one end-effector position (2R arm, L = 1.0, 0.8)")
t1, t2 = np.radians([30.0, 45.0])
px = L1*np.cos(t1) + L2*np.cos(t1+t2)
py = L1*np.sin(t1) + L2*np.sin(t1+t2)
gamma = np.arctan2(L2*np.sin(t2), L1 + L2*np.cos(t2))
t1b, t2b = np.arctan2(py, px) + gamma, -t2
qx = L1*np.cos(t1b) + L2*np.cos(t1b+t2b)
qy = L1*np.sin(t1b) + L2*np.sin(t1b+t2b)
print(f"   (30.0, 45.0) deg -> ({px:.4f}, {py:.4f}); ({np.degrees(t1b):.4f}, {np.degrees(t2b):.1f}) deg -> ({qx:.4f}, {qy:.4f})")
print(f"   reachable radius range: [{abs(L1 - L2):.1f}, {L1 + L2:.1f}]")

print("4. Spatial 3R chain (Lynch & Park Example 4.1 / C.1), L1 = 1.0, L2 = 0.8")
M3 = np.array([[0, 0, 1, L1], [0, 1, 0, 0], [-1, 0, 0, -L2], [0, 0, 0, 1]], float)
S3 = [np.array([0, 0, 1, 0, 0, 0], float),
      np.array([0, -1, 0, 0, 0, -L1], float),
      np.array([1, 0, 0, 0, -L2, 0], float)]
T_dh_zero = dh_link(0, 0, 0, 0) @ dh_link(np.pi/2, L1, 0, -np.pi/2) @ dh_link(-np.pi/2, L2, 0, 0)
print(f"   DH chain at theta = 0 equals M: {ok(np.abs(T_dh_zero - M3).max())}")
rng = np.random.default_rng(16)
worst = 0.0
for _ in range(1000):
    q = rng.uniform(-np.pi, np.pi, 3)
    T_poe = fk_space(M3, S3, q)
    T_dh = dh_link(0, 0, 0, q[0]) @ dh_link(np.pi/2, L1, 0, q[1] - np.pi/2) @ dh_link(-np.pi/2, L2, 0, q[2])
    worst = max(worst, np.abs(T_poe - T_dh).max())
print(f"   PoE vs DH over 1000 random joint vectors: max entry difference {ok(worst)}")
S3_wrong = [S3[0], S3[1], np.array([1, 0, 0, 0, +L2, 0], float)]
q = np.radians([20.0, 30.0, 40.0])
T_dh = dh_link(0, 0, 0, q[0]) @ dh_link(np.pi/2, L1, 0, q[1] - np.pi/2) @ dh_link(-np.pi/2, L2, 0, q[2])
err = np.abs(fk_space(M3, S3_wrong, q) - T_dh).max()
print(f"   with v3 = (0, +L2, 0) instead of (0, -L2, 0): max entry difference {err:.4f} at (20, 30, 40) deg")
print("   parameter count, n = 3: DH structure 3n =", 3*3, "| PoE screws 6n =", 6*3, "+ M (6 dof)")

print("5. DH parameters are ill-conditioned near parallel axes; screw axes are not")


def common_normal(p1, u1, p2, u2):
    u1, u2 = u1/np.linalg.norm(u1), u2/np.linalg.norm(u2)
    n = np.cross(u1, u2)
    if np.linalg.norm(n) < 1e-12:
        return np.linalg.norm(np.cross(p2 - p1, u1)), None
    w0 = p1 - p2
    a, b, c = u1 @ u1, u1 @ u2, u2 @ u2
    d, e = u1 @ w0, u2 @ w0
    den = a*c - b*b
    s = (b*e - c*d) / den
    t = (a*e - b*d) / den
    return np.linalg.norm((p1 + s*u1) - (p2 + t*u2)), s


p1, u1 = np.zeros(3), np.array([0.0, 0.0, 1.0])
p2 = np.array([1.0, 0.0, 0.0])
for label, u2 in [("exactly parallel", np.array([0.0, 0.0, 1.0])),
                  ("tilt 1e-3 toward x", np.array([1e-3, 0.0, 1.0])),
                  ("tilt 1e-3 toward y", np.array([0.0, 1e-3, 1.0]))]:
    length, foot = common_normal(p1, u1, p2, u2)
    w2 = u2 / np.linalg.norm(u2)
    S2 = screw_revolute(w2, p2)
    dS = np.abs(S2 - screw_revolute(u1, p2)).max()
    foot_txt = "undefined (any height)" if foot is None else f"{foot:+.1f}"
    print(f"   {label:18s}: link length a = {length:.4f}, normal foot on axis 1 at z = {foot_txt}, screw change {dS:.4f}")
查看运行输出
1. Planar 3R arm, L = (1.0, 0.8, 0.5), theta = (30, 45, -60) deg
   trigonometry: x = 1.5560, y = 1.4022, phi = 15.0 deg
   space screw axes S_i = (w, v):
     S1 = [+0.00, +0.00, +1.00, +0.00, +0.00, +0.00]
     S2 = [+0.00, +0.00, +1.00, +0.00, -1.00, +0.00]
     S3 = [+0.00, +0.00, +1.00, +0.00, -1.80, +0.00]
   body screw axes B_i = Ad(M^-1) S_i:
     B1 = [+0.00, +0.00, +1.00, +0.00, +2.30, +0.00]
     B2 = [+0.00, +0.00, +1.00, +0.00, +1.30, +0.00]
     B3 = [+0.00, +0.00, +1.00, +0.00, +0.50, +0.00]
   T(theta) from PoE space form:
      [+0.9659, -0.2588, +0.0000, +1.5560]
      [+0.2588, +0.9659, +0.0000, +1.4022]
      [+0.0000, +0.0000, +1.0000, +0.0000]
   link-frame product = PoE space: ok
   PoE body = PoE space:           ok
   trig (x, y) = T[0:2, 3]:        ok
2. The order of the exponentials matters
   reversed product tip: (2.6557, 1.5469) vs correct (1.5560, 1.4022)
3. Many joint vectors, one end-effector position (2R arm, L = 1.0, 0.8)
   (30.0, 45.0) deg -> (1.0731, 1.2727); (69.7298, -45.0) deg -> (1.0731, 1.2727)
   reachable radius range: [0.2, 1.8]
4. Spatial 3R chain (Lynch & Park Example 4.1 / C.1), L1 = 1.0, L2 = 0.8
   DH chain at theta = 0 equals M: ok
   PoE vs DH over 1000 random joint vectors: max entry difference ok
   with v3 = (0, +L2, 0) instead of (0, -L2, 0): max entry difference 0.9024 at (20, 30, 40) deg
   parameter count, n = 3: DH structure 3n = 9 | PoE screws 6n = 18 + M (6 dof)
5. DH parameters are ill-conditioned near parallel axes; screw axes are not
   exactly parallel  : link length a = 1.0000, normal foot on axis 1 at z = undefined (any height), screw change 0.0000
   tilt 1e-3 toward x: link length a = 0.0000, normal foot on axis 1 at z = -1000.0, screw change 0.0010
   tilt 1e-3 toward y: link length a = 1.0000, normal foot on axis 1 at z = +0.0, screw change 0.0010

平面 3R:四条路线,一个位姿。 取 L=(1.0,0.8,0.5)L=(1.0,0.8,0.5)、θ=(30°,45°,−60°)\theta=(30°,45°,-60°),三角公式给出 x=1.5560x=1.5560、y=1.4022y=1.4022,朝向 15.0°。空间螺旋轴都沿 z^\hat z;它们的线性部分为 v=−z^×qv=-\hat z\times q,对于分别穿过原点、(1, 0, 0) 与 (1.8, 0, 0) 的轴,读数为 (0, 0, 0)、(0, −1.00, 0) 与 (0, −1.80, 0)。从零位时位于 xx 方向 2.3 m 处的末端执行器看,同样三条轴的线性部分为 2.30、1.30 与 0.50。PoE 位姿的旋转块是 15° 转动(0.9659 与 0.2588),位置为 (1.5560, 1.4022, 0)。连杆坐标系连乘、空间形式、物体形式与三角公式的位置全部一致。

顺序很重要。 把三个指数按相反顺序相乘,末端落在 (2.6557, 1.5469),而不是 (1.5560, 1.4022)。刚体运动不可交换;在空间形式中,最右边的因子必须属于最远端的关节。

同一位置,不同关节值。 对 L=(1.0,0.8)L=(1.0,0.8) 的 2R 机械臂,关节向量 (30°, 45°) 与 (69.7298°, −45°) 都把末端放在 (1.0731, 1.2727):肘部向一侧或另一侧弯曲。末端到基座的可达距离范围是 0.2 到 1.8。正向运动学是一个函数,反过来却不是,所以逆运动学是一个独立且更难的问题。

空间机械臂上 PoE 与 D–H 的对比。 Lynch 与 Park 的空间 3R 链关节轴为 ω1=(0,0,1)\omega_1=(0,0,1)、ω2=(0,−1,0)\omega_2=(0,-1,0)、ω3=(1,0,0)\omega_3=(1,0,0),q2=(L1,0,0)q_2=(L_1,0,0)、q3=(0,0,−L2)q_3=(0,0,-L_2),零位构型 MM 的工具坐标系绕 y^\hat y 转过一定角度。例 4.1 例 C.1 中它的 D–H 表为 (α,a,d,ϕ)=(0,0,0,θ1)(\alpha,a,d,\phi)=(0,0,0,\theta_1)、(90°,L1,0,θ2−90°)(90°,L_1,0,\theta_2-90°)、(−90°,L2,0,θ3)(-90°,L_2,0,\theta_3);注意 D–H 坐标系规则迫使关节 2 带上 −90° 的关节角偏置。例 C.1 取 L1=1.0L_1=1.0、L2=0.8L_2=0.8,D–H 乘积在 θ=0\theta=0 时等于 MM,两种公式在 1000 个随机关节向量上的差都小于 1e-12。有一个细节:对关节 3 应用 v=−ω×qv=-\omega\times q 得到 v3=(0,−L2,0)v_3=(0,-L_2,0),与书中正文的推导一致,而书中的汇总表印的是 (0,L2,0)(0,L_2,0)。这个符号有影响:用 +L2+L_2 时,在 (20°, 30°, 40°) 处 PoE 位姿与 D–H 位姿的某个矩阵元素相差达 0.9024。在两种独立参数化之间做随机交叉检验,是发现这类笔误的廉价方法。n=3n=3 时,D–H 结构用 9 个数,PoE 螺旋轴用 18 个数再加 MM。

近平行轴处的条件数。 Lynch 与 Park 提醒,相邻轴接近平行时,公垂线会随轴方向的微小变化而剧烈变动,使真实(不完美)机器人的 D–H 参数难以测量和辨识。病态问题 第 5 部分是我们自己构造的玩具示例。轴 1 是 zz 轴;轴 2 穿过 (1, 0, 0)。两轴严格平行时,a=1.0000a=1.0000,公垂线可以位于任意高度。把轴 2 朝 xx 倾斜 1e-3,两轴就在原点下方很远处相交:aa 跳到 0.0000,公垂线垂足移到 z=−1000.0z=-1000.0。朝 yy 倾斜同样的量,两轴仍然异面,a=1.0000a=1.0000,垂足在 z=0.0z=0.0。两种情形下,PoE 螺旋轴的最大元素只变化 0.0010。在这种构型附近拟合 D–H 参数的标定程序面对的是不连续的目标,而螺旋参数是平滑变化的。

正向运动学的代价是 nn 次 4×4 矩阵乘法,与关节数成线性;实际需要关心的是约定与建模误差,而不是速度。

正向映射告诉不了你什么

正向映射假设几何模型是完美的。真实机械臂存在制造公差、连杆柔性、齿轮间隙与编码器零点偏差,所以计算出的位姿与真实位姿不同;标定会估计修正后的参数,而参数化的选择正是在这里起作用(见上面的条件数示例)。我们的玩具几何只是演示 Lynch 与 Park 所描述的机制,不是一项标定研究。

D–H 表很难跨文献直接搬用。各种约定在关节轴放在哪个坐标轴、四个基本运动的顺序、齐次坐标的位置上都有差别(Hartenberg 与 Denavit 1964 年的矩阵把它放在第一位)。使用已发表的表之前,先找回它的坐标系图,并在一个已知位姿上测试。两种流行变体常用的名称本文不采用,因为我们的两个来源都没有定义它们。

上文所述对 PoE 的偏好是 Lynch 与 Park 在书中论证的观点。D–H 在教材、论文与厂商文档中仍然广泛使用;只要用对,两者描述的是同一个映射。

正向运动学不告诉你末端运动有多快(雅可比矩阵;Lynch 与 Park 指出其各列就是随构型变化的关节螺旋),哪些关节值能到达目标(逆运动学),需要多大力矩(机器人动力学),也不告诉你某个构型是否超出关节限位或发生碰撞。闭链与并联机构增加了回路闭合约束,本文只通过 Hartenberg 与 Denavit 的 A1A2A3A4=IA_1A_2A_3A_4=I 提及。

哪条轴、哪个坐标系、哪种顺序?

  1. 关节轴会随机械臂运动而在物理上移动,为什么空间形式的 PoE 只需要零位时的螺旋轴?

    答案:在 e[S1]θ1⋯e[Sn]θnMe^{[\mathcal{S}_1]\theta_1}\cdots e^{[\mathcal{S}_n]\theta_n}M 中,最右边的因子最先作用:关节 nn 移动 MM,然后关节 n−1n-1 移动其结果,依此类推。关节 ii 作用时,按这个顺序,它近端的关节还没有动,所以轴 ii 仍在固定坐标系中的零位位置。物体形式的论证相反,轴在末端执行器坐标系中表示。

  2. 平面 2R 机械臂 L1=1L_1=1、L2=0.8L_2=0.8。(a)求 θ=(30°,45°)\theta=(30°,45°) 时的 (x,y)(x,y)。(b)写出关节 2 的 S2\mathcal{S}_2,其轴沿 z^\hat z 并穿过 (1, 0, 0)。(c)验证 e[S2]θe^{[\mathcal{S}_2]\theta} 使点 (1, 0, 0) 保持不动。

    答案:(a)x=cos⁡30°+0.8cos⁡75°=0.8660+0.8⋅0.2588=1.0731x=\cos30°+0.8\cos75°=0.8660+0.8\cdot0.2588=1.0731,y=sin⁡30°+0.8sin⁡75°=0.5+0.8⋅0.9659=1.2727y=\sin30°+0.8\sin75°=0.5+0.8\cdot0.9659=1.2727,与程序一致。(b)ω=(0,0,1)\omega=(0,0,1)、q=(1,0,0)q=(1,0,0) 给出 ω×q=(0,1,0)\omega\times q=(0,1,0),所以 v=(0,−1,0)v=(0,-1,0),S2=(0,0,1,0,−1,0)\mathcal{S}_2=(0,0,1,0,-1,0),即程序中的 −1.00。(c)该点在轴上,而节距为零的螺旋只绕自身的轴旋转。代数上,像点为 e[ω]θ(1,0,0)+G(θ)ve^{[\omega]\theta}(1,0,0)+G(\theta)v,其中 e[ω]θ(1,0,0)=(cos⁡θ,sin⁡θ,0)e^{[\omega]\theta}(1,0,0)=(\cos\theta,\sin\theta,0),G(θ)v=(1−cos⁡θ,−sin⁡θ,0)G(\theta)v=(1-\cos\theta,-\sin\theta,0),两者之和为 (1, 0, 0)。

  3. 一位工程师标定一台关节 2 与关节 3 轴名义上平行、相距 1 m 的机械臂,发现在两次标定之间,拟合出的偏距 dd 从约 0 跳到约 −1000 m,aa 从 1 m 降到 0,而拟合出的轴方向只相差约 0.001 rad。机器人坏了吗?

    答案:多半没有。近平行轴使公垂线定义不清:微小的倾斜可能让两轴在很远处相交(a→0a\to0,垂足处 ∣d∣|d| 很大),也可能让两轴保持异面而垂足靠近原点。程序用 1e-3 的倾斜复现了这一点(垂足在 z=−1000z=-1000 或 0),Lynch 与 Park 指出的正是这种病态问题。物理轴几乎没变;它的螺旋描述只移动了 0.0010。应当使用随轴连续变化的参数化,例如螺旋轴。

  4. 你需要(i)根据 CAD 文件为一台新的六关节机械臂建立仿真模型,(ii)使用一篇旧论文中某机械臂的 a,α,d,θa,\alpha,d,\theta 表,(iii)根据测量数据标定一台机器人。各用哪种表示?要注意什么?

    答案:(i)用 PoE:任选基座坐标系与零位构型 MM,从 CAD 中读出每个关节轴的方向和轴上一点,计算 Si\mathcal{S}_i;不需要连杆坐标系。(ii)保留 D–H 表,但先确定它的约定:关节放在哪个坐标轴上,基本运动按什么顺序(Lynch 与 Park 的 Rot(x^)⋯Rot(z^)\mathrm{Rot}(\hat x)\cdots\mathrm{Rot}(\hat z),还是 Hartenberg 与 Denavit 1964 年矩阵中 zz 在前的顺序)。在一个已知位姿上检验它,需要时转换为 PoE。(iii)在近平行轴附近避免直接使用 D–H,因为存在病态问题;螺旋轴之类的连续参数化表现更好。

  5. 证明 Rot(x^,α)Trans(x^,a)Trans(z^,d)Rot(z^,ϕ)\mathrm{Rot}(\hat x,\alpha)\mathrm{Trans}(\hat x,a)\mathrm{Trans}(\hat z,d)\mathrm{Rot}(\hat z,\phi) 等于 Trans(x^,a)Rot(x^,α)Rot(z^,ϕ)Trans(z^,d)\mathrm{Trans}(\hat x,a)\mathrm{Rot}(\hat x,\alpha)\mathrm{Rot}(\hat z,\phi)\mathrm{Trans}(\hat z,d)。

    答案:绕某轴的旋转与沿同一轴的平移可交换:绕 x^\hat x 旋转不改变 x^\hat x 方向。交换前一对(都关于 x^\hat x)和后一对(都关于 z^\hat z),就得到第二个表达式。Lynch 与 Park 指出了这两处交换。

从公式到机器人模型

Lynch 与 Park 第 4 章为开链展开了 PoE,并给出空间机械臂的算例;附录 C 讲解 D–H 坐标系的设置、向 PoE 的转换以及两者的比较。第 4 章与附录 C Hartenberg 与 Denavit 第 12 章展示了矩阵方法的原始语境,即万向节之类的闭链机构,在记号上也是一个有用的对照。运动学综合

Lynch 与 Park 第 4 章的小结介绍了统一机器人描述格式(URDF):机器人操作系统(ROS)及其他软件用这种文件格式描述树状结构的机器人,包括串联链;其中的关节条目各自连接一个父连杆与一个子连杆,完整给出运动学,连杆条目则记录惯性参数。URDF 因此,读取这种文件的软件已具备计算正向映射所需的全部信息。无论采用什么格式,像上面程序那样对同一位姿做两次独立计算,仍是防范符号与约定错误最简单的办法。

先判断,再看解释

标定一台机械臂时,两条名义上平行、相距 1 m 的关节轴拟合出的 D–H 偏距 d 在两次标定之间从约 0 跳到约 −1000 m,而两轴实际方向只差约 0.001 rad。最合理的解释是什么?

选择一个答案

学习目标

  • 把串联机械臂的正向运动学写成从关节空间到 SE(3) 的映射,分别用三角公式、连杆坐标系连乘和指数积公式(空间形式与物体形式)计算末端位姿,并验证三者一致。
  • 读懂并换算 D–H 参数表(坐标系规则、四个参数、约定差异),说明 D–H 与 PoE 的关系与取舍,包括最少参数与近平行轴病态问题。

先修与延伸

查看知识关联图 →

参考文献

  1. Modern Robotics: Mechanics, Planning, and Control — May 2017 preprint, scoped
    Kevin M. Lynch; Frank C. Park · 2017
  2. Kinematic Synthesis of Linkages (McGraw-Hill, 1964), Cornell eCommons KMODDL scan
    Richard S. Hartenberg; Jacques Denavit · 1964

版本1 · 编写状态: 已完成记录中的技术复核

查看技术检查记录(AI)

Claude · 2026-12-03 · Independent AI check (Claude subagent, not the author; not a human or expert review). Before this check the main session had applied style-only edits suggested by the Gemini app to the opening sections (logged in gemini-edits-016a.json); research was done by a separate research subagent (facts.md) and the prose by a writer subagent. I re-ran example.py with the pinned CPython + numpy 1.26.4 interpreter and diffed it against example.stdout.txt (identical), confirmed the python block in en.mdx and zh.mdx is byte-identical to example.py, the recorded-output block matches the stdout, and the seven display equations are identical across languages. I re-derived the planar 3R formulas, the screw axes v = −ω × q and the body axes Ad(M^{-1})S, the Prop. 3.25 closed form, the toy common-normal geometry (a 1e-3 tilt toward x makes the axes meet at z = −1000), and all five exercise answers including the G(θ)v computation in exercise 2. I downloaded the Modern Robotics preprint PDF (May 2017) and re-read by text extraction the Ch. 4 opening (3n + n vs 6n + n parameter counts), §4.1.2 Example 4.1 pp. 143–144 (text and the [S3] matrix give v3 = (0, −L2, 0); the summary table prints (0, L2, 0), as the article states), §4.3 Summary pp. 158–159 (including the URDF bullet), §4.5 p. 160 with bibliography entries [20] Brockett 1983 and [34] Denavit & Hartenberg 1955, and Appendix C pp. 585–596 (frame rules, four parameters, special cases, Fig. C.3, alternative conventions, link transform and swap note, Example C.1 table, C.5 relation to PoE, C.6 ill-conditioning and comparison). I downloaded the Chapter 12 file of the Cornell eCommons scan of Hartenberg & Denavit (1964) and re-read §12-3 pp. 347–355 by OCR, and checked Eq. 12-9 against the rendered page image of p. 353: first row (1, 0, 0, 0), first column (a cos θ, a sin θ, s), rotation block Rot(z, θ)Rot(x, α), as the article states; the six lower pairs, zero/infinite lead, and the closure A1A2A3A4 = I with the Hooke-joint derivation are also as stated. The 1955 paper and Brockett's paper are cited only via the Modern Robotics bibliography and were not read by me either. I compared zh and en section by section and checked data.json (source rows, catalogue IDs, quiz answer). Not checked: Modern Robotics §4.2 body text, Examples 4.3–4.6, other chapters of the 1964 book.

  • 代码与输出:用固定解释器重跑 example.py,与 example.stdout.txt 完全一致;两种语言的 python 代码块与 example.py 逐字节相同,正文引用的数字(1.5560、1.4022、2.6557、69.7298°、0.9024、−1000.0、0.0010 等)均与输出一致。
  • 公式与习题:平面 3R 公式、v=−ω×q、物体形式螺旋轴、命题 3.25 闭式、D–H 连杆变换与两处可交换性、玩具公垂线几何以及五道习题答案均重新推导无误。
  • 来源:例 4.1 正文与 [S3] 矩阵给出 v3=(0,−L2,0),汇总表印作 (0,L2,0),正文表述准确;Hartenberg 与 Denavit 1964 年式 12-9 已与第 353 页扫描图像核对,布局与正文一致;1955 年论文与 Brockett 论文只经《Modern Robotics》参考文献引用。
  • 双语与 Gemini 编辑:逐节对照中英文,定义、数字、习题与限定一致;gemini-edits-016a.json 中本题 9 处编辑均为文风修改,未改变事实或归属(其中一处措辞把 D–H 说成连乘的方式,已恢复为“选择坐标系”的准确说法)。

核对的来源位置:

  • Modern Robotics: Mechanics, Planning, and Control — May 2017 preprint, scoped · Preprint PDF dated 2017-05-03 fetched 2026-12-03, text extracted with pdftotext; printed page numbers. Checked: Ch. 4 opening pp. 137–140 (FK definition; Eqs. 4.1–4.3 planar 3R; Eq. 4.4–4.5 link-frame product; Eqs. 4.6–4.11 M, S1–S3 and PoE for planar 3R; D–H 3n+n vs PoE 6n+n parameter counts and authors' preference); §4.1, §4.1.1 pp. 140–142 (frames needed; screw axis of revolute/prismatic joint, v = −ω × q; Eq. 4.14 space form; three required elements); §4.1.2 pp. 143–144 (Example 4.1: M, ω_i, q_i, v_i; table lists v3 = (0, L2, 0) while text gives (0, −L2, 0); start of Example 4.2 table); §4.1.3 pp. 148–150 (Eq. 4.16 body form via e^{M^{-1}PM} = M^{-1}e^{P}M; ordering argument); §4.3 pp. 158–159 (summary incl. D–H and PoE statements, URDF bullet); §4.4 p. 159 (FKinBody/FKinSpace); §4.5 p. 160 (D–H in most literature, ref. [34]; PoE from Brockett ref. [20]; Park ref. [132]; differing link-frame conventions); Appendix C pp. 585–596 (C.1 frame rules and four parameters, intersecting/parallel/prismatic cases, ground and end-effector frames; C.2 Fig. C.3 non-representable frames, four is minimum per D&H; alternative conventions; C.3 link transform and step order; C.4 Examples C.1–C.3 tables; C.5 Eqs. C.6–C.15 PoE from D–H; C.6 comparison incl. ill-conditioning near parallel axes); bibliography [20] Brockett 1983 MTNS Beer Sheva, [34] Denavit & Hartenberg 1955 J. Appl. Mech. 23:215–221, [132] Park 1994 IEEE TAC 39(3):643–647. NOT read: Examples 4.3–4.6 in detail, §4.2 URDF text, exercises, Chapters 5–7.
  • Kinematic Synthesis of Linkages (McGraw-Hill, 1964), Cornell eCommons KMODDL scan · Cornell eCommons item d0ec9495-2d37-4a17-888c-43fd7f8a8010 (handle 1813/58640), OCR text bitstreams fetched 2026-12-03: 013_001.pdf.txt (title page, Preface, table of contents — Preface says Chapter 12 summarizes the authors' previous work on matrix analysis of spatial mechanisms; TOC gives §12-3 on p. 347) and 013_013.pdf.txt (Chapter 12). Checked §12-1 pp. 343–344 (spatial linkages hard to visualize; analytic and matrix methods; full matrix method beyond scope, outlined in §12-3) and §12-3 pp. 347–355 (four parameters per connection; pairs, links, open/closed chains; six lower pairs, revolute and prismatic as zero/infinite-lead screws; common perpendicular, axes and parameters a, α, θ, s with Fig. 12-3; symbolic equations 12-3 to 12-8 for planar, spherical four-revolute and Bennett mechanisms; Eq. 12-9 4×4 matrix with first row (1,0,0,0); closure Eq. 12-10 A1A2A3A4 = I; Hooke-joint derivation Eqs. 12-12 to 12-16). OCR garbles Greek letters; matrix layout reconstructed and cross-checked against the a = s = 0 Hooke-joint matrices on p. 354. NOT read: §12-2 details beyond the equation shape, §12-4 to §12-6, chapter bibliography (OCR unreadable), other chapters, and the 1955 J. Applied Mechanics paper.

相关主题

没有匹配结果,试试英文名或缩写。

已显示 0 条结果

将整个查询放入双引号,可按短语匹配。