20
20
env = swift .Swift ()
21
21
env .launch ()
22
22
23
- path = rtb .path_to_datafile (' data' )
23
+ path = rtb .path_to_datafile (" data" )
24
24
25
25
26
26
g1 = Mesh (
27
- filename = str (path / 'gimbal-ring1.stl' ),
28
- color = [34 , 143 , 201 ],
29
- scale = (1. / 3 ,) * 3
27
+ filename = str (path / "gimbal-ring1.stl" ), color = [34 , 143 , 201 ], scale = (1.0 / 3 ,) * 3
30
28
)
29
+ g1 .v = [0 , 0 , 0 , 0 , 0.5 , 0 ]
31
30
32
31
g2 = Mesh (
33
- filename = str (path / 'gimbal-ring2.stl' ),
34
- color = [31 , 184 , 72 ],
35
- scale = (1.1 / 3 ,) * 3
36
-
32
+ filename = str (path / "gimbal-ring2.stl" ), color = [31 , 184 , 72 ], scale = (1.1 / 3 ,) * 3
37
33
)
34
+ g2 .v = [0 , 0 , 0 , 0.5 , 0 , 0 ]
38
35
39
36
g3 = Mesh (
40
- filename = str (path / ' gimbal-ring3.stl' ),
37
+ filename = str (path / " gimbal-ring3.stl" ),
41
38
color = [240 , 103 , 103 ],
42
- scale = (1.1 ** 2 / 3 ,) * 3
39
+ scale = (1.1 ** 2 / 3 ,) * 3 ,
43
40
)
41
+ g3 .v = [0 , 0 , 0 , 0 , 0 , 0.5 ]
44
42
45
43
plane = Mesh (
46
- filename = str (path / ' spitfire_assy-gear_up.stl' ),
47
- scale = (1. / (180 * 3 ),) * 3 ,
48
- color = [240 , 103 , 103 ]
44
+ filename = str (path / " spitfire_assy-gear_up.stl" ),
45
+ scale = (1.0 / (180 * 3 ),) * 3 ,
46
+ color = [240 , 103 , 103 ],
49
47
)
50
- print (path / ' spitfire_assy-gear_up.stl' )
48
+ print (path / " spitfire_assy-gear_up.stl" )
51
49
env .add (g1 )
52
50
env .add (g2 )
53
51
env .add (g3 )
54
52
env .add (plane )
55
53
56
- print (' Supermarine Spitfire Mk VIII by Ed Morley @GRABCAD' )
57
- print (' Gimbal models by Peter Corke using OpenSCAD' )
54
+ print (" Supermarine Spitfire Mk VIII by Ed Morley @GRABCAD" )
55
+ print (" Gimbal models by Peter Corke using OpenSCAD" )
58
56
59
57
# compute the three rotation matrices
60
58
BASE = SE3 (0 , 0 , 0.5 )
@@ -72,11 +70,11 @@ def update_gimbals(theta, ring):
72
70
# update the relevant transform, depending on which ring's slider moved
73
71
def Rxyz (theta , which ):
74
72
theta = np .radians (theta )
75
- if which == 'X' :
73
+ if which == "X" :
76
74
return SO3 .Rx (theta )
77
- elif which == 'Y' :
75
+ elif which == "Y" :
78
76
return SO3 .Ry (theta )
79
- elif which == 'Z' :
77
+ elif which == "Z" :
80
78
return SO3 .Rz (theta )
81
79
82
80
if ring == 1 :
@@ -111,46 +109,32 @@ def set_three(x):
111
109
112
110
113
111
r_one = swift .Slider (
114
- set_one ,
115
- min = - 180 , max = 180 ,
116
- step = 1 , value = 0 ,
117
- desc = 'Outer gimbal' , unit = '°' )
112
+ set_one , min = - 180 , max = 180 , step = 1 , value = 0 , desc = "Outer gimbal" , unit = "°"
113
+ )
118
114
119
115
120
116
r_two = swift .Slider (
121
- set_two ,
122
- min = - 180 , max = 180 ,
123
- step = 1 , value = 0 ,
124
- desc = 'Middle gimbal' , unit = '°' )
117
+ set_two , min = - 180 , max = 180 , step = 1 , value = 0 , desc = "Middle gimbal" , unit = "°"
118
+ )
125
119
126
120
127
121
r_three = swift .Slider (
128
- set_three ,
129
- min = - 180 , max = 180 ,
130
- step = 1 , value = 0 ,
131
- desc = 'Inner gimbal' , unit = '°' )
122
+ set_three , min = - 180 , max = 180 , step = 1 , value = 0 , desc = "Inner gimbal" , unit = "°"
123
+ )
132
124
133
125
134
126
# buttons to set a 3-angle sequence
135
127
ZYX_button = swift .Button (
136
- lambda x : change_sequence ('ZYX' ),
137
- desc = 'ZYX (roll-pitch-yaw angles)'
128
+ lambda x : change_sequence ("ZYX" ), desc = "ZYX (roll-pitch-yaw angles)"
138
129
)
139
130
140
131
XYZ_button = swift .Button (
141
- lambda x : change_sequence ('XYZ' ),
142
- desc = 'XYZ (roll-pitch-yaw angles)'
132
+ lambda x : change_sequence ("XYZ" ), desc = "XYZ (roll-pitch-yaw angles)"
143
133
)
144
134
145
- ZYZ_button = swift .Button (
146
- lambda x : change_sequence ('ZYZ' ),
147
- desc = 'ZYZ (Euler angles)'
148
- )
135
+ ZYZ_button = swift .Button (lambda x : change_sequence ("ZYZ" ), desc = "ZYZ (Euler angles)" )
149
136
150
- button = swift .Button (
151
- lambda x : set ('ZYX' ),
152
- desc = 'Set to Zero'
153
- )
137
+ button = swift .Button (lambda x : set ("ZYX" ), desc = "Set to Zero" )
154
138
155
139
156
140
# button to reset joint angles
@@ -161,10 +145,7 @@ def reset(e):
161
145
# env.step(0)
162
146
163
147
164
- zero_button = swift .Button (
165
- reset ,
166
- desc = 'Set to Zero'
167
- )
148
+ zero_button = swift .Button (reset , desc = "Set to Zero" )
168
149
169
150
170
151
def update_all_sliders ():
@@ -176,7 +157,7 @@ def update_all_sliders():
176
157
def change_sequence (new ):
177
158
global sequence
178
159
179
- xyz = ' XYZ'
160
+ xyz = " XYZ"
180
161
181
162
# update the state of the ring_axis dropdowns
182
163
ring1_axis .checked = xyz .find (new [0 ])
@@ -192,62 +173,36 @@ def angle(index, ring):
192
173
global sequence
193
174
194
175
# print('angle', index, ring)
195
- xyz = ' XYZ'
176
+ xyz = " XYZ"
196
177
s = list (sequence )
197
178
s [ring ] = xyz [int (index )]
198
- sequence = '' .join (s )
179
+ sequence = "" .join (s )
199
180
update_all_sliders ()
200
181
201
182
202
- ring1_axis = swift .Radio (
203
- lambda x : angle (x , 0 ),
204
- options = [
205
- 'X' ,
206
- 'Y' ,
207
- 'Z'
208
- ],
209
- checked = 2
210
- )
183
+ ring1_axis = swift .Radio (lambda x : angle (x , 0 ), options = ["X" , "Y" , "Z" ], checked = 2 )
211
184
212
- ring2_axis = swift .Radio (
213
- lambda x : angle (x , 1 ),
214
- options = [
215
- 'X' ,
216
- 'Y' ,
217
- 'Z'
218
- ],
219
- checked = 1
220
- )
185
+ ring2_axis = swift .Radio (lambda x : angle (x , 1 ), options = ["X" , "Y" , "Z" ], checked = 1 )
221
186
222
- ring3_axis = swift .Radio (
223
- lambda x : angle (x , 2 ),
224
- options = [
225
- 'X' ,
226
- 'Y' ,
227
- 'Z'
228
- ],
229
- checked = 0
230
- )
187
+ ring3_axis = swift .Radio (lambda x : angle (x , 2 ), options = ["X" , "Y" , "Z" ], checked = 0 )
231
188
232
189
233
- label = swift .Label (
234
- desc = 'Triple angle'
235
- )
190
+ label = swift .Label (desc = "Triple angle" )
236
191
237
192
238
193
def chekked (e , el ):
239
- nlabel = ' s: '
194
+ nlabel = " s: "
240
195
241
196
if e [0 ]:
242
- nlabel += 'a'
197
+ nlabel += "a"
243
198
r_one .value = 0
244
199
245
200
if e [1 ]:
246
- nlabel += 'b'
201
+ nlabel += "b"
247
202
r_two .value = 0
248
203
249
204
if e [2 ]:
250
- nlabel += 'c'
205
+ nlabel += "c"
251
206
r_three .value = 0
252
207
253
208
if e [3 ]:
@@ -275,5 +230,5 @@ def chekked(e, el):
275
230
update_gimbals (0 , 2 )
276
231
update_gimbals (0 , 3 )
277
232
278
- while ( True ) :
279
- env .step (0 )
233
+ while True :
234
+ env .step (0.05 )
0 commit comments