-
Notifications
You must be signed in to change notification settings - Fork 0
/
RobotykaLib.py
129 lines (112 loc) · 2.69 KB
/
RobotykaLib.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
"""
Module contains rotations for robotics.
Author: Jan Bornicki
https://github.com/John15321
https://github.com/John15321/Robotics_1/tree/master/Skrypty
Changes: Górka Mateusz
"""
import sympy as sp
def rot_z_fun(alpha):
return sp.Matrix([
[sp.cos(alpha), -sp.sin(alpha), 0],
[sp.sin(alpha), sp.cos(alpha), 0],
[0, 0, 1]
])
def rot_x_fun(beta):
return sp.Matrix([
[1, 0, 0],
[0, sp.cos(beta), -sp.sin(beta)],
[0, sp.sin(beta), sp.cos(beta)]
])
def rot_y_fun(gamma):
return sp.Matrix([
[sp.cos(gamma), 0, sp.sin(gamma)],
[0, 1, 0],
[-sp.sin(gamma), 0, sp.cos(gamma)]
])
def trans_z_fun(c):
return sp.Matrix([
[0],
[0],
[c]
])
def trans_x_fun(a):
return sp.Matrix([
[a],
[0],
[0]
])
def trans_y_fun(b):
return sp.Matrix([
[0],
[b],
[0]
])
# Jednorodne:
def rot_x(alpha):
return sp.Matrix([
[1, 0, 0, 0],
[0, sp.cos(alpha), -sp.sin(alpha), 0],
[0, sp.sin(alpha), sp.cos(alpha), 0],
[0, 0, 0, 1]
])
def rot_y(beta):
return sp.Matrix([
[ sp.cos(beta), 0, sp.sin(beta), 0],
[0, 1, 0, 0],
[-sp.sin(beta), 0, sp.cos(beta), 0],
[0, 0, 0, 1]
])
def rot_z(gamma):
return sp.Matrix([
[sp.cos(gamma), -sp.sin(gamma), 0, 0],
[sp.sin(gamma), sp.cos(gamma), 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]
])
def trans_x(a):
return sp.Matrix([
[1, 0, 0, a],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]
])
def trans_y(b):
return sp.Matrix([
[1, 0, 0, 0],
[0, 1, 0, b],
[0, 0, 1, 0],
[0, 0, 0, 1]
])
def trans_z(c):
return sp.Matrix([
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, c],
[0, 0, 0, 1]
])
# General funcion
def rot( axis, var ):
if axis == 0:
return sp.eye(3)
elif axis.name == 'z':
return rot_z( var )
elif axis.name == 'x':
return rot_x( var )
elif axis.name == 'y':
return rot_y( var )
else:
print("Nie znana os")
def trans( axis, var ):
if axis == 0:
return sp.eye(3)
elif axis.name == 'z':
return trans_z( var )
elif axis.name == 'x':
return trans_x( var )
elif axis.name == 'y':
return trans_y( var )
else:
print("Nie znana os")
def tr( axis, var ):
return trans(axis, var)