forked from Sarrasor/RoboticManipulators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrrr_robot_jacobians.py
78 lines (57 loc) · 1.9 KB
/
rrr_robot_jacobians.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""
RRR Robot Jacobian calculation
"""
import pickle
from pathlib import Path
import sympy as sp
from utils.jacobians import JacobianCalculator
data_path = Path("data/rrr_jacobian.pkl")
def get_symbolic_jacobian_inverse():
if data_path.is_file():
with open(data_path, 'rb') as input:
J_inv = pickle.load(input)
else:
T_base = sp.eye(4)
T_tool = sp.eye(4)
variables = ['q_0', 'l_0', 'q_1', 'l_1', 'q_2', 'l_2']
indices = [1, 0, 1, 0, 1, 0]
sequence = "RzTzRyTxRyTx"
jc = JacobianCalculator(sequence,
indices,
variables=variables,
T_base=T_base,
T_tool=T_tool,
simplify=False)
ls = (1.0, 1.0, 1.0)
value_pairs = []
for i in range(len(ls)):
value_pairs.append((f"l_{i}", ls[i]))
J_inv = jc.calculate_numeric()[:3, :3].inv()
J_inv = sp.simplify(J_inv.subs(value_pairs))
with open(data_path, 'wb') as output:
pickle.dump(J_inv, output, pickle.HIGHEST_PROTOCOL)
return J_inv
def main():
T_base = sp.eye(4)
T_tool = sp.eye(4)
variables = ['q_0', 'l_0', 'q_1', 'l_1', 'q_2', 'l_2']
indices = [1, 0, 1, 0, 1, 0]
sequence = "RzTzRyTxRyTx"
jc = JacobianCalculator(sequence,
indices,
variables=variables,
T_base=T_base,
T_tool=T_tool,
simplify=False)
J_num = sp.simplify(jc.calculate_numeric())
print("Numeric Jacobian:")
print()
sp.pprint(J_num)
print()
print("Inverse translation part of the Jacobian:")
J_transl = J_num[:3, :3]
print()
sp.pprint(sp.simplify(J_transl.inv()))
print()
if __name__ == '__main__':
main()