-
Notifications
You must be signed in to change notification settings - Fork 0
/
kxrextentions.l
359 lines (333 loc) · 11.1 KB
/
kxrextentions.l
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
;;;
;;; 2020.6.11 Ducted fan thruster
;;;
;;(require :kxranimate)
(require :eus2wrl)
(provide :kxrextentions)
(defun main-shaft nil
(let* ((b (make-cube 20 300 20))
(sbod b)
(b0 (make-cube 17 400 17))
(u0 (make-cube 36 27 14 :pos #f(0 -137 11)))
(u1 (make-cube 36 27 14 :pos #f(0 137 11)))
;;(l0 (make-cube 36 27 12 :pos #f(0 -137 -10)))
;;(l1 (make-cube 36 27 12 :pos #f(0 137 -10)))
(c0 (make-cube 28 10 36 :pos #f(4 -32 0)))
(c1 (make-cube 28 10 36 :pos #f(4 32 0)))
l)
(setq b (body- b b0))
;;(format t ";; shaft volume cc=~A~%" (* 0.001 (send s :volume)))
(setq b (body+ b c0))
(setq b (body+ b c1))
(setq b (body+ b u0))
(setq b (body+ b u1))
;;(setq b (body+ b l0))
;;(setq b (body+ b l1))
(setq l (kxr-make-kxr-body "main-shaft" sbod b nil))
(send l :weight (+ 258.7 (* 2 39.0) 47.0)) ;;shaft+M5Stack, ESC, etc
l)
)
(defun 70mm-duct-mount ()
(let* ((seg 12)
(b (make-cylinder 46.5 25 :segments seg :pos #f(0 0 -12.5)))
(sbod b)
(b0 (make-cylinder 36.5 40 :segments seg :pos #f(0 0 -15)))
(p0 (make-cube 3 100 30))
(p1 (make-cube 100 100 30 :pos #f(-50 0 0)))
(p2 (make-cube 20 100 30 :pos #f(54.79 0 0)))
(c1 (make-cylinder 8 200 :segments seg)))
(setq b (body- b b0))
(setq b (body- b p0))
(setq b (body- b p1))
(setq b (body- b p2))
#|
(setq c0 (make-cylinder 3 200 :segments 6))
(send c0 :rotate pi/2 :y)
(dolist (p (list
#f(-100 -41 6)
#f(-100 -41.5 -6)
#f(-100 41.5 6)
#f(-100 41.5 -6)
))
(send c0 :locate p :world)
(setq b (body- b c0)))
|#
;;
(send c1 :rotate pi/2 :y)
(send c1 :rotate (deg2rad 45) :x)
(dotimes (i 4)
(setq b (body- b c1))
(send c1 :rotate (deg2rad 90) :x))
(kxr-make-kxr-body "70mm-duct-mount" sbod b nil)
))
(defun kxr-joint-base-a-servo-supporter-bodyset nil
(let* ((bod (kxr-joint-frame-base-a-bodyset))
(s (kxr-servo-s3301))
(b (kxr-arm-supporter-b))
(c (get s :upper-coord))
(o (get s :joint-coord))
l)
(send s :assoc c)
(send s :assoc o)
(send b :rotate pi/2 :-y)
(send b :locate #f(0 0 13) :world)
(send s :assoc b)
(send s :rotate pi/2 :y)
(send s :locate (float-vector 0 0 (+ 9 21)) :world)
;;
(send bod :assoc s)
(send bod :rotate pi/2 :z)
(setq l (kxr-bodyset-create (append (send bod :bodies) (list s b)) c))
(send l :put :upper-coord c)
(send l :assoc c)
(send l :put :joint-coord o)
(send l :assoc o)
l))
(defun main-shaft-link (pos)
(let ((m (main-shaft))
(o1 (flying-battery-unit-body))
(o2 (flying-battery-unit-body))
(b1 (kxr-joint-base-a-servo-supporter-bodyset))
(b2 (kxr-joint-base-a-servo-supporter-bodyset))
(c (make-cascoords))
l blist)
(send b1 :locate (float-vector 0 136.5 20) :world)
(send o1 :locate (float-vector 0 136.5 -10) :world)
(send b2 :rotate pi :z)
(send b2 :locate (float-vector 0 -136.5 20) :world)
(send o2 :locate (float-vector 0 -136.5 -10) :world)
(send m :assoc b1)
(send m :assoc o1)
(send m :assoc b2)
(send m :assoc o2)
(send m :locate pos)
(setq blist (cons m (append (send b1 :bodies) (send b2 :bodies) (list o1 o2))))
(setq l (kxr-link-create blist :joint-coord c))
(setf (get l :left-joint-coord) (get b1 :upper-coord))
(setf (get l :right-joint-coord) (get b2 :upper-coord))
(send l :assoc (get l :left-joint-coord))
(send l :assoc (get l :right-joint-coord))
l)
)
(defun 70mm-ducted-fan-motor ()
(let* ((seg 16)
(c (make-solid-of-revolution
(list
(float-vector 41.5 0 (- 58 12.5 10))
(float-vector 41.5 0 (- 58 12.5 10 1.5))
(float-vector 39.0 0 (- 58 12.5 10 1.5 2.5))
(float-vector 36.5 0 (- 58 12.5 10 1.5 5))
(float-vector 36.5 0 (- 0 12.5 10))
)
:segments seg))
(sbod c)
(c0 (make-solid-of-revolution
(list
(float-vector 38.5 0 (- 58 12.5))
(float-vector 38.5 0 (- 58 12.5 10))
(float-vector 36.0 0 (- 58 12.5 10 1.5))
(float-vector 35.0 0 (- 58 12.5 10 1.5 2.5))
(float-vector 34.0 0 (- 58 12.5 10 1.5 5))
(float-vector 34.0 0 (- 0 12.5 20))
)
:segments seg
))
(c1 (make-cylinder 35 200 :pos #f(0 0 -100) :segments seg))
(m (make-solid-of-revolution
(list
(float-vector 14 0 (- 58 12.5 10 (- 58 38)))
(float-vector 14 0 (- 58 12.5 10 35 46))
(float-vector 10 0 (- 58 12.5 10 85.43))
)
:segments seg))
(p (make-cube 3 93 25))
(p0 (make-cube 71 3 25))
(co (make-cascoords))
l)
;;(list c c0)
(setq c (body- c c1))
(setq c (body+ c p))
(setq c (body+ c m))
(setq c (body+ c p0))
(send co :locate (float-vector 0 0 (- 31.75 22.5)))
(setq l (kxr-make-kxr-body "70mm-ducted-fan-motor" sbod c nil))
(setf (get l :joint-coord) co)
(send l :assoc co)
(send l :weight 158)
l))
(defun 70mm-ducted-motor-link (&optional l/r)
(let* ((m (70mm-ducted-fan-motor))
(d (70mm-duct-mount))
(c (make-cascoords))
blist)
(send d :assoc m)
(send d :assoc c)
(cond
((kxr-left-limb? l/r)
(send d :rotate pi/2 :-z)
(send d :locate (float-vector 0 45 0) :world))
(t
(send d :rotate pi/2 :z)
(send d :locate (float-vector 0 -45 0) :world)))
(setq blist (list d m))
(kxr-link-create blist :joint-coord c)
)
)
(defun 5inch-ducted-fan-motor ()
(let* ((s (stl2eus (format nil "~A/stls/5inch_propeller_duct.STL" *rcb4eus-dir*)))
(l (kxr-make-kxr-body "5inch-ducted-fan-motor" s s nil))
)
(send l :weight 175.0)
l))
(defun 5inch-ducted-motor-link (&optional l/r)
(let* ((m (5inch-ducted-fan-motor))
(c (make-cascoords))
blist)
(send m :assoc c)
(cond
((kxr-left-limb? l/r)
;;(send m :rotate pi/2 :-z)
(send m :locate (float-vector 0 80.5 0) :world))
(t
;;(send m :rotate pi/2 :z)
(send m :locate (float-vector 0 -80.5 0) :world)))
(setq blist (list m))
(kxr-link-create blist :joint-coord c)
)
)
(defun ducted-motor-link (&key l/r fan)
(if (eq fan :5inch)
(5inch-ducted-motor-link l/r) (70mm-ducted-motor-link l/r)))
#|
(defun ducted-fan-body-old2 nil
(let ((c (make-solid-of-revolution
(list
(float-vector 5 0 (- 58 12.5 10))
(float-vector 9 0 (- 58 12.5 10 6))
(float-vector 11 0 (- 58 12.5 10 10))
;;(float-vector 13 0 (- 58 12.5 10 15))
;;(float-vector 14 0 (- 58 12.5 10 20))
(float-vector 32 0 (- 58 12.5 10 15))
(float-vector 32 0 (- 58 12.5 10 20))
)))
(p (make-cube 3 93 10))
(p0 (make-cube 71 3 25))
)
(kxr-make-kxr-body "ducted-fan-body" c c nil)
))
(defun ducted-fan-body-old (&optional mirror)
(let* ((c (stl2eus "stls/70mm_duct_propeller.STL" :mirror mirror
:return-type :body
:offset (float-vector 34.75 32 (- 31 (- 31.5 22.5))))))
(if mirror (send c :evert))
(kxr-make-kxr-body
(if mirror "ducted-fan-body-mirror" "ducted-fan-body")
c c nil)
))
(defun ducted-fan-body-mirror-old ()
(let* ((c (stl2eus "stls/70mm_duct_propeller.STL" :mirror t
:return-type :body
:offset (float-vector 34.75 32 (- 31 (- 31.5 22.5))))))
(send c :evert)
(kxr-make-kxr-body "ducted-fan-body-mirror" c c nil)
))
|#
(defun flying-battery-unit-body ()
(let* ((c (stl2eus (format nil "~A/stls/battery_unit.STL" *rcb4eus-dir*)))
(l (kxr-make-kxr-body "flying-battery-unit-body" c c nil)))
(send l :weight 217.0)
l
))
(defun 70mm-ducted-fan-body ()
(let ((c (stl2eus (format nil "~A/stls/70mm_duct_propeller.STL" *rcb4eus-dir*))))
(kxr-make-kxr-body "70mm-ducted-fan-body" c c nil)
))
(defun 70mm-ducted-fan-body-mirror ()
(let ((c (stl2eus (format nil "~A/stls/70mm_duct_propeller_mirror.STL" *rcb4eus-dir*))))
(kxr-make-kxr-body "70mm-ducted-fan-body-mirror" c c nil)
))
(defun 5inch-ducted-fan-body ()
(let* ((c (stl2eus (format nil "~A/stls/5inch_propeller.STL" *rcb4eus-dir*)))
(l (kxr-make-kxr-body "5inch-ducted-fan-body" c c nil)))
(send l :weight 3.2)
l
))
(defun 5inch-ducted-fan-body-mirror ()
(let* ((c (stl2eus (format nil "~A/stls/5inch_propeller_mirror.STL" *rcb4eus-dir*)))
(l (kxr-make-kxr-body "5inch-ducted-fan-body-mirror" c c nil)))
(send l :weight 3.2)
l
))
(defun ducted-fan-body (&optional (fan :5inch)) (if (eq fan :5inch) (5inch-ducted-fan-body) (70mm-ducted-fan-body)))
(defun ducted-fan-body-mirror (&optional (fan :5inch)) (if (eq fan :5inch) (5inch-ducted-fan-body-mirror) (70mm-ducted-fan-body-mirror)))
(defun ducted-fan-link (&key (l/r :lwing) (fan :5inch))
(let* ((m (if (kxr-left-limb? l/r)
(ducted-fan-body fan) (ducted-fan-body-mirror fan)))
(c (make-cascoords))
l)
(send c :locate (float-vector 0 0 (- 58 22.5)) :world)
(send m :assoc c)
(kxr-link-create (list m) :joint-coord c)
)
)
(eval-when (eval load)
(mapc #'(lambda (x) (file-memoization x))
'(70mm-ducted-fan-motor
5inch-ducted-fan-motor
70mm-ducted-fan-body
5inch-ducted-fan-body
70mm-ducted-fan-body-mirror
5inch-ducted-fan-body-mirror
flying-battery-unit-body
70mm-duct-mount main-shaft))
)
(defun kxrl2anzaifly (&key (fan :5inch))
(let ((s (main-shaft-link #f(0 0 0)))
(d1 (ducted-motor-link :l/r :lwing :fan fan))
(d2 (ducted-motor-link :l/r :rwing :fan fan))
(r1 (ducted-fan-link :l/r :lwing :fan fan))
(r2 (ducted-fan-link :l/r :rwing :fan fan))
r)
(send d1 :locate (send (get s :left-joint-coord) :worldpos) :world)
(send d2 :locate (send (get s :right-joint-coord) :worldpos) :world)
(send s :assoc d1)
(send s :assoc d2)
(send r1 :locate (send (get d1 :joint-coord) :worldpos) :world)
(send r2 :locate (send (get d2 :joint-coord) :worldpos) :world)
(send d1 :assoc r1)
(send d1 :assoc r2)
(setq r (kxr-create-robot "kxrl2l6anzai"))
#|
(setq b (find "back-pack" (send r :bodies)
:test #'equal :key #'(lambda (x) (send x :name))))
(send s :locate (send b :worldpos) :world)
|#
(send s :locate (send (get (send r :body-link) :back-panel) :worldpos) :world)
(send r :assoc s)
(objects (list r s d1 d2 r1 r2))
)
)
(defun kxr-flight-unit (&key (fan :5inch))
(let ((s (main-shaft-link #f(-18 0 0)))
(d1 (ducted-motor-link :l/r :lwing :fan fan))
(d2 (ducted-motor-link :l/r :rwing :fan fan))
(r1 (ducted-fan-link :l/r :lwing :fan fan))
(r2 (ducted-fan-link :l/r :rwing :fan fan))
r)
(send d1 :locate (send (get s :left-joint-coord) :worldpos) :world)
(send d2 :locate (send (get s :right-joint-coord) :worldpos) :world)
(send s :assoc d1)
(send s :assoc d2)
(send r1 :locate (send (get d1 :joint-coord) :worldpos) :world)
(send r2 :locate (send (get d2 :joint-coord) :worldpos) :world)
(send d1 :assoc r1)
(send d1 :assoc r2)
(objects (list s d1 d2 r1 r2))
(print (apply #'+ (mapcar #'(lambda (l) (send l :weight)) (list s d1 d2 r1 r2))))
(format t "s ~A~%"(send s :weight))
(format t "d1 ~A~%"(send d1 :weight))
(format t "d2 ~A~%"(send d2 :weight))
(format t "r1 ~A~%"(send r1 :weight))
(format t "r2 ~A~%"(send r2 :weight))
)
)