|
1 | 1 | import numpy as np |
2 | | -import ur3e_ikfast |
3 | | -import ur5_ikfast |
| 2 | +# import ur3e_ikfast |
| 3 | +import ur5e.ur5e_ikfast as ur5e_ikfast |
| 4 | + |
4 | 5 |
|
5 | 6 | # Initialize kinematics for UR5 robot arm |
6 | | -ur3e_kin = ur3e_ikfast.PyKinematics() |
7 | | -ur5_kin = ur5_ikfast.PyKinematics() |
8 | | -n_joints = ur3e_kin.getDOF() |
| 7 | +ur5e_kin = ur5e_ikfast.PyKinematics() |
| 8 | +n_joints = ur5e_kin.getDOF() |
9 | 9 |
|
10 | 10 | joint_angles = [-3.1, -1.6, 1.6, -1.6, -1.6, 0.] # in radians |
11 | 11 |
|
12 | 12 | # Test forward kinematics: get end effector pose from joint angles |
13 | 13 | print("\nTesting forward kinematics:\n") |
14 | 14 | print("Joint angles:") |
15 | 15 | print(joint_angles) |
16 | | -ee_pose = ur3e_kin.forward(joint_angles) |
| 16 | +ee_pose = ur5e_kin.forward(joint_angles) |
17 | 17 | ee_pose = np.asarray(ee_pose).reshape(3, 4) # 3x4 rigid transformation matrix |
18 | 18 | print("\nEnd effector pose:") |
19 | 19 | print(ee_pose) |
20 | 20 | print("\n-----------------------------") |
21 | 21 |
|
22 | 22 | # Test inverse kinematics: get joint angles from end effector pose |
23 | 23 | print("\nTesting inverse kinematics:\n") |
24 | | -joint_configs = ur3e_kin.inverse(ee_pose.reshape(-1).tolist()) |
| 24 | +joint_configs = ur5e_kin.inverse(ee_pose.reshape(-1).tolist()) |
25 | 25 | n_solutions = int(len(joint_configs)/n_joints) |
26 | 26 | print("%d solutions found:" % (n_solutions)) |
27 | 27 | joint_configs = np.asarray(joint_configs).reshape(n_solutions, n_joints) |
|
35 | 35 | print("\nTesting forward kinematics UR5:\n") |
36 | 36 | print("Joint angles:") |
37 | 37 | print(joint_angles) |
38 | | -ee_pose = ur5_kin.forward(joint_angles) |
| 38 | +ee_pose = ur5e_kin.forward(joint_angles) |
39 | 39 | ee_pose = np.asarray(ee_pose).reshape(3, 4) # 3x4 rigid transformation matrix |
40 | 40 | print("\nEnd effector pose:") |
41 | 41 | print(ee_pose) |
|
0 commit comments