-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathfanuc_kinematics.py
62 lines (44 loc) · 1.03 KB
/
fanuc_kinematics.py
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
53
54
55
56
57
58
59
60
61
62
"""
Fanuc FK and IK usage example
"""
import numpy as np
from robots.fanuc import Fanuc165F
def main():
np.set_printoptions(suppress=True)
T_base = np.array([
[1, 0, 0, 500],
[0, 1, 0, 300],
[0, 0, 1, -100],
[0, 0, 0, 1]
])
T_tool = np.array([
[1, 0, 0, 100],
[0, 1, 0, 0],
[0, 0, 1, -300],
[0, 0, 0, 1]
])
robot = Fanuc165F(T_base=T_base, T_tool=T_tool)
qs = [-0.485, 0.5, -0.23, 0.23, 0.21, 0.213]
T = robot.forward_kinematics(qs, plot=False)
print("Forward kinematics:")
print(T)
print()
print("Real Qs:")
print(qs)
T_IK = T
# T_IK = np.array([
# [1, 0, 0, 2000],
# [0, 1, 0, 0],
# [0, 0, 1, 900],
# [0, 0, 0, 1]
# ])
qs = robot.inverse_kinematics(T_IK, m=-1, w=1)
print()
print("IK Qs:")
print(qs)
T_res = robot.forward_kinematics(qs, plot=True)
print()
print("After inverse kinematics:")
print(T_res)
if __name__ == '__main__':
main()