-
Notifications
You must be signed in to change notification settings - Fork 13
/
RobotInterfaceBoardEsp32.groovy
364 lines (345 loc) · 11 KB
/
RobotInterfaceBoardEsp32.groovy
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
359
360
361
362
363
364
class BoardMaker{
static double radius = 1
static double insertionDepthOfWii = 7.1
static double wiiCenterOffset=2.2
static double wiiConnectorThickness = 7.40
static double wiiConnectorWidth = 12.21
static double wiiInsetFromEdge = 12.42+(wiiConnectorWidth/2)
static double boardX =67.35
static double boardY =75.0
static double boardZ =1.67
static double cutoutRadius=4
static double cutoutDepth = 7.3
static double ioKaX =63.7
static double ioKaY =48.79
static double ioKaZ =17.67
static double lowerKeepaway = 6.3
static double holeCornerInset = 1.8+1.5
static double boardConnects = 2.3
static double usbThickness = 8
static double wireHeight = 5
static double wireRadius = 1.5
static double negativeWireOffset = 3-3.5
static double positiveWireOffset = 7+3.5
static double caseOutSet = 4
static double powerKeepawayOffset=56.6
static double usbHeight=11.06
static LengthParameter printerOffset = new LengthParameter("Printer Offset",0.6,[1.75,0])
double caseRounding = 4
def makeWiiConnector(){
CSG wiiConnect = new RoundedCube( wiiConnectorWidth,// X dimention
wiiConnectorThickness,// Y dimention
8.11+(radius)// Z dimention
).cornerRadius(radius)// sets the radius of the corner
.toCSG()
.toZMin()
.movez(-radius)
CSG cutout = new RoundedCube( 5,// X dimention
1.58+radius,// Y dimention
8.11+(radius*2)// Z dimention
)
.cornerRadius(radius)// sets the radius of the corner
.toCSG()
.toZMin()
.movez(-radius)
.toYMax()
.movey(radius)
.movey(wiiConnect.getMaxY())
CSG wiiBody = new Cube( 20.27,// X dimention
13,// Y dimention
23.4// Z dimention
)
.toCSG()
.toZMax()
CSG wiiClip = new Cube( 17.9,// X dimention
6.62,// Y dimention
5// Z dimention
)
.toCSG()
.toZMax()
.toYMax()
.movey(wiiBody.getMinY())
CSG wiiNotch = new Cube( 14.75,// X dimention
3.5,// Y dimention
3.5// Z dimention
)
.toCSG()
.toZMin()
.toYMin()
.movez(wiiConnect.getMaxZ()-5)
.movey(wiiConnect.getMinY()+1.5)
wiiConnect=wiiConnect
.difference(cutout)
.union([wiiBody,
wiiClip,
wiiNotch])
return wiiConnect
}
def makeBoard(){
CSG wiiConnect = makeWiiConnector()
wiiConnect=wiiConnect
.toZMax()
.movez(insertionDepthOfWii)
.movey(wiiConnectorThickness/2-wiiCenterOffset)
.rotx(-90)
.rotz(180)
.movex(wiiInsetFromEdge)
.movez(-boardZ)
CSG mainBoard = new Cube(boardX+boardConnects*2,boardY+boardConnects,boardZ).toCSG()
.toXMin()
.toYMin()
.toZMax()
.move(-boardConnects,-boardConnects,0)
CSG mainBoardCutout = new RoundedCube(33.0-1,cutoutDepth+cutoutRadius,boardZ+cutoutRadius*2)
.cornerRadius(cutoutRadius)
.toCSG()
.toYMax()
.toZMax()
.movez(cutoutRadius)
.movey(mainBoard.getMaxY()+cutoutRadius)
.movex(boardX/2)
mainBoard=mainBoard.difference(mainBoardCutout)
CSG antenna = new Cube(21.85,7,13.69+boardZ+lowerKeepaway+1).toCSG()
.toYMax()
.toZMin()
.movey(-ioKaY)
.movex(ioKaX/2)
CSG IOkeepaway = new Cube(ioKaX,ioKaY,ioKaZ+boardZ+lowerKeepaway).toCSG()
.toXMin()
.toYMax()
.toZMin()
.union(antenna)
.movez(-(boardZ+lowerKeepaway))
.movey(-cutoutDepth+boardY)
.movex(1.8)
CSG fusekeepaway = new Cube(20-0.12,9,ioKaZ+boardZ+lowerKeepaway+10).toCSG()
.toXMin()
.toYMin()
.toZMin()
.movez(-(boardZ+lowerKeepaway))
.movey(IOkeepaway.getMinY()-1.9)
.movex(1.63)
CSG electronicsKeepaway = new Cube(30,19.4,3.2+(boardZ+lowerKeepaway)).toCSG()
.toXMin()
.toYMin()
.toZMin()
.movez(-(boardZ+lowerKeepaway))
.movex(wiiConnect.getMaxX()-7.5)
.difference(wiiConnect.intersect(wiiConnect.getBoundingBox().toYMin()))
CSG switchkeepaway = new Cube(20,10.6,ioKaZ+boardZ+lowerKeepaway+10).toCSG()
.toXMax()
.toYMin()
.toZMin()
.movez(-(boardZ+lowerKeepaway))
.movey(6.81)
.movex(boardX-1.63)
CSG holeLower = new Cylinder(1.25,1.25,ioKaZ,(int)20).toCSG()
.movez(-ioKaZ)
CSG holeUpper = new Cylinder(1.5,1.5,ioKaZ,(int)10).toCSG()
CSG holeHead = new Cylinder(3.1,3.1,ioKaZ,(int)20).toCSG()
.movez(7)
def hole = holeUpper.union([holeLower,holeHead])
mainBoard=mainBoard
.union(hole.move(holeCornerInset,holeCornerInset,0))
.union(hole.move(holeCornerInset,boardY-holeCornerInset,0))
.union(hole.move(boardX-holeCornerInset,boardY-holeCornerInset,0))
.union(hole.move(boardX-holeCornerInset,holeCornerInset,0))
def WireActualPartLine= wireHeight-caseRounding
CSG wire = new Cylinder(wireRadius,40).toCSG()
.movez(-wireRadius)
.rotx(-90)
.movez(WireActualPartLine)
CSG wirekeepaway = new Cube(positiveWireOffset+wireRadius*6,boardConnects,wireHeight).toCSG()
.toXMax()
.toZMin()
.toYMax()
.movex(wireRadius+3.5)
CSG powerkeepaway = new Cube(17.84,19.79,10.43+boardZ+lowerKeepaway).toCSG()
.toXMax()
.movex(3.5)
.toYMin()
.toZMin()
.movez(-(boardZ+lowerKeepaway))
.union(wire.movex(-negativeWireOffset))
.union(wire.movex(-positiveWireOffset))
.union(wirekeepaway)
.movex(powerKeepawayOffset)
CSG usbCord = new Cylinder(2.0,40).toCSG()
.rotx(90)
.movez(usbThickness/2)
CSG usbCordkeepaway = new RoundedCube(6,1,usbThickness)
.cornerRadius(1)
.toCSG()
.toYMax()
.toZMin()
.movey(27.75)
CSG usbkeepaway = new RoundedCube(10.4,20.73,usbThickness)
.cornerRadius(1)
.toCSG()
.toYMin()
.toZMin()
.union(usbCordkeepaway)
.hull()
.union(usbCord)
.movey(-cutoutDepth+boardY)
.movex(boardX/2)
.movez(usbHeight)
def lightPipe = new Cylinder(1.5,100).toCSG()
def v5Power = lightPipe.move(41.21,2.8,0)
def fused = lightPipe.move(36.26,10,0)
def vcc = lightPipe.move(44.65,8.6,0)
def screwTerm = new Cube(4,4,100).toCSG().toZMin().union(new Cube(1.5,1.5,100).toCSG().toZMin().rotx(-90))
def point1 = 0.1*25.4
screwTerm =screwTerm .union(screwTerm.movex(point1))
.movez(WireActualPartLine)
.movey(point1)
.movex(powerKeepawayOffset-positiveWireOffset*0.5-point1/2)
//return electronicsKeepaway
return [wiiConnect,mainBoard,IOkeepaway,switchkeepaway,powerkeepaway,usbkeepaway,fusekeepaway,electronicsKeepaway,
v5Power,
fused,
vcc,
screwTerm
]
}
def makeCase(){
def board =makeBoard()
double frontCaseDepth = -cutoutDepth+boardY-ioKaY-caseRounding+3
double lowerCaseDepth = Math.abs(board[0].getMinZ())
if(lowerCaseDepth<(lowerKeepaway+3)){
lowerCaseDepth=lowerKeepaway+3
}
CSG wirekeepaway = new RoundedCube(positiveWireOffset+wireRadius*8,caseOutSet-boardConnects,wireHeight+4)
.toCSG()
.toXMax()
.toZMin()
.toYMin()
.movez(-caseRounding*2)
.movex(wireRadius*3)
.movey(-caseOutSet)
.movex(powerKeepawayOffset)
double LugX = boardX+(boardConnects*2)+caseOutSet*2
CSG basicLug = new RoundedCube(LugX,frontCaseDepth,lowerCaseDepth)
.cornerRadius(caseRounding)
.toCSG()
.toZMax()
.toYMin()
.movey(-caseOutSet)
.toXMin()
.movex(-caseOutSet-boardConnects)
CSG fullBoard = CSG.unionAll(board)
double backeOfCaseY = boardY- cutoutDepth+printerOffset.getMM()*2
CSG usbkeepaway = new RoundedCube(13+caseRounding*2,frontCaseDepth,usbHeight+caseRounding*2+usbThickness/2)
.cornerRadius(caseRounding)
.toCSG()
.toZMin()
.movez(-caseRounding*2)
.toYMin()
.movex(boardX/2)
CSG backBottom = basicLug
.toYMin()
.movey(backeOfCaseY)
.union(basicLug)
.hull()
.union(usbkeepaway.movey(backeOfCaseY))
.union( wirekeepaway)
.difference(fullBoard)
double vexGrid = 1.0/2.0*25.4
CSG vexMount = Vitamins.get( "vexFlatSheet","Aluminum 1x5")
.intersect(new Cube(vexGrid*7.5).toCSG())
.rotz(-90)
.movey( -caseOutSet+caseRounding+vexGrid/2)
.movex(-caseOutSet+2-boardConnects-vexGrid/2)
.movez( backBottom.getMinZ())
vexMount=vexMount.movey(vexGrid*2)
.union(vexMount)
CSG vexMountB = vexMount.movex(vexGrid*7)
def vexAttach = vexMount.union(vexMountB)
.hull()
.difference([vexMount.hull(),vexMountB.hull()])
def allvexbits = CSG.unionAll([vexMountB,
vexMount,
vexAttach
])
.toYMin()
.movey(backBottom.getMinY()+caseRounding)
backBottom= backBottom
.union(allvexbits)
println "Performing keepaway opperation ..."
def fullBoardMink =CSG.unionAll(fullBoard.minkowski(new Cube(printerOffset.getMM()).toCSG()))
def backBottomMink =CSG.unionAll(backBottom.minkowski(new Cube(printerOffset.getMM()).toCSG()))
println "keepaway Done!"
double caseheight = 20
def rounding = makeRoundedCyl(
basicLug.getTotalX()*0.60, // Radius at the top
basicLug.getTotalY(), // Height
caseRounding,
(int)80 //resolution
)
.rotx(90)
.movey(basicLug.getMinY())
.movex(boardX/2)
.toZMax()
.movez(caseheight+caseRounding)
CSG frontTop = basicLug.union(basicLug.toZMax().movez( caseheight))
.hull()
.toZMin()
.movez(-caseRounding*2)
.intersect(rounding)
.difference(fullBoardMink)
.difference(backBottomMink)
CSG backTop = basicLug.union(basicLug.toZMax().movez( caseheight))
.hull()
.toZMin()
.movez(-caseRounding*2)
.intersect(rounding)
.toYMin()
.movey(backeOfCaseY)
.difference(fullBoardMink)
.difference(backBottomMink)
CSG bottom = backBottom
bottom.setManufacturing({ toMfg ->
return toMfg
.toXMin()
.toYMin()
.toZMin()
})
frontTop.setManufacturing({ toMfg ->
return toMfg
.toXMin()
.toYMin()
.rotx(-90)
.toZMin()
})
backTop.setManufacturing({ toMfg ->
return toMfg
.toXMin()
.toYMin()
.rotx(90)
.toZMin()
})
def caseParts = [bottom,frontTop,backTop]
return caseParts
board.addAll(caseParts)
return board
}
def makeRoundedCyl(def rad,def height, def corner,def resolution){
def minHeight = height-corner*2
def cylParts =[]
def divisor = 6
for(int i=0;i<divisor;i++){
def radInc = rad-corner+Math.sin(Math.PI/2*((double)i/(double)divisor))*corner
def heightInc = (Math.cos(Math.PI/2*((double)i/(double)(divisor)))*corner)
cylParts.add(
new Cylinder(radInc, // Radius at the bottom
radInc, // Radius at the top
heightInc*2+minHeight, // Height
(int)resolution //resolution
).toCSG()
.movez(-heightInc)
)
}
return CSG.unionAll(cylParts).hull().toZMin()
}
}
return new BoardMaker().makeCase()