forked from Sarrasor/RoboticManipulators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrrr_robot_kinematics.py
55 lines (38 loc) · 893 Bytes
/
rrr_robot_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
"""
RRR Robot FK and IK usage example
"""
import numpy as np
from robots.rrr_robot import RRRRobot
def main():
np.set_printoptions(suppress=True)
T_base = np.array([
[1, 0, 0, 1],
[0, 1, 0, 1],
[0, 0, 1, 0],
[0, 0, 0, 1]
])
T_tool = np.array([
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]
])
robot = RRRRobot(T_base=T_base, T_tool=T_tool)
qs = [np.pi / 2, 0, 0.2]
T = robot.forward_kinematics(qs, plot=False)
print("Forward kinematics:")
print(T)
print()
print("Real Qs:")
print(qs)
T_IK = T
qs = robot.inverse_kinematics(T_IK, m=1, k=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()