The UR's DH in coppeliasim

Typically: "How do I... ", "How can I... " questions
Post Reply
yeah
Posts: 8
Joined: 22 Nov 2024, 10:40

The UR's DH in coppeliasim

Post by yeah »

I attempted to write a forward kinematics program, where the DH parameters were extracted from the UR official website. However, the calculated coordinates are different from those in CoppeliaSim (I placed the robotic arm at the origin of the coordinate system, and each joint angle displayed in CoppeliaSim is also 0).

Code: Select all

import numpy as np
# UR10的DH参数表
ur10_dh_params = [
    # a      alpha     d       theta
    [0.0   , np.pi/2,  0.1273, -np.pi/2],    # Joint 1 
    [0.6121 , 0      ,  0     , 0],    # Joint 2 
    [0.5722, 0      ,  0     , 0],    # Joint 3
    [0.0   , np.pi/2,  0.1639, np.pi/2],    # Joint 4  
    [0.0   ,-np.pi/2, 0.1157,  -np.pi/2],    # Joint 5
    [0.0   , 0      , 0.0922,  -np.pi]     # Joint 6 
]

# DH变换矩阵
def dh_transform(a, alpha, d, theta):
    return np.array([
        [np.cos(theta), -np.sin(theta) * np.cos(alpha), np.sin(theta) * np.sin(alpha), a * np.cos(theta)],
        [np.sin(theta), np.cos(theta) * np.cos(alpha), -np.cos(theta) * np.sin(alpha), a * np.sin(theta)],
        [0, np.sin(alpha), np.cos(alpha), d],
        [0, 0, 0, 1]
    ])

# 计算UR10正运动学
def FK(joint_angles):
    t = np.eye(4)  # 初始变换矩阵(单位矩阵)
    for i in range(6):
        a, alpha, d, theta = ur10_dh_params[i]
        theta=theta+joint_angles[i]  
        A = dh_transform(a, alpha, d, theta)
        t = np.dot(t, A)  # 累积变换矩阵
    return t

joint_angles = [0,0, 0,0, 0, 0]  

end_effector_transform = FK(joint_angles)
end_effector_transform=np.round(end_effector_transform,4)
print("末端执行器变换矩阵:")
print(end_effector_transform)

position = end_effector_transform[:3, 3]
print(f"末端执行器位置: x={position[0]:.3f}, y={position[1]:.3f}, z={position[2]:.3f}")

I want to know the DH parameters in coppeliasim.
Post Reply