-
Notifications
You must be signed in to change notification settings - Fork 12
/
LinkedGearedCadGen.groovy
1695 lines (1539 loc) · 58 KB
/
LinkedGearedCadGen.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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import com.neuronrobotics.bowlerstudio.creature.ICadGenerator;
import org.apache.commons.io.IOUtils;
import com.neuronrobotics.bowlerstudio.vitamins.*;
import eu.mihosoft.vrl.v3d.parametrics.*;
import com.neuronrobotics.bowlerstudio.vitamins.Vitamins;
import javafx.scene.paint.Color;
import eu.mihosoft.vrl.v3d.Transform;
import com.neuronrobotics.bowlerstudio.physics.TransformFactory;
import eu.mihosoft.vrl.v3d.Transform;
import javafx.scene.transform.Affine;
if(args==null){
args=[ [36,// Number of teeth gear a link 0
84],// Number of teeth gear b link 0
[36,// Number of teeth gear a link 1
84],// Number of teeth gear b link 1
[36,// Number of teeth gear a link 2
84],// Number of teeth gear b link 2
]
}
Vitamins.setGitRepoDatabase("https://github.com/madhephaestus/Hardware-Dimensions.git")
CSGDatabase.clear()
class MyCadGenerator implements ICadGenerator{
double capPinSpacing
double pinOffset
double mountPlatePinAngle
CSG screwSet
double topOfGearToCenter
double distanceToTopOfGear
double drivenLinkThickness
double gearDistance
CSG armScrews
CSG screwWithNut
CSG gearScrew
CSG LoadCellScrews
CSG loadBearingPinBearing
CSG loadBearingPin
//HashMap<String, Object> gearAMeasurments
//HashMap<String, Object> gearBMeasurments
double gearHeightValue=12.8
CSG gearStandoff
CSG gearKeepaway
CSG gearA
CSG gearB
def gearRatios
public MyCadGenerator(def args){
gearRatios= args
}
public void setGearing(def ratio){
println "\n\n\tSetting gearing to "+ratio+"\n\n"
def bevelGears = ScriptingEngine.gitScriptRun(
"https://github.com/madhephaestus/GearGenerator.git", // git location of the library
"bevelGear.groovy" , // file to load
// Parameters passed to the funcetion
[ ratio[0],// Number of teeth gear a
ratio[1],// Number of teeth gear b
gearHeightValue,// thickness of gear A
3.42303,//computeGearPitch(26.15,24),// gear pitch in arc length mm
0,// shaft angle, can be from 0 to 100 degrees
0// helical angle, only used for 0 degree bevels
]
)
gearDistance = bevelGears[2]
capPinSpacing = (bevelGears[11]*2)*0.75+encoderCapRodRadius
pinOffset =bevelGears[12]+encoderCapRodRadius*2
topOfGearToCenter = (centerLinkToBearingTop-gearHeightValue)//gearBMeasurments.height
gearA = bevelGears[0].rotz(180).movex(-gearDistance)
gearB = bevelGears[1].rotz(180).movex(-gearDistance)
mountPlatePinAngle =Math.toDegrees(Math.atan2(capPinSpacing,pinOffset))
gearStandoff = new Cylinder(gearA.getMaxY(),gearA.getMaxY(),motorBackSetDistance+washerThickness,20).toCSG()
.toZMax()
.movex(-gearDistance)
gearKeepaway = gearStandoff.toolOffset(1).getBoundingBox()
screwSet =screwTotal
.movex(-pinOffset)
.rotz(mountPlatePinAngle)
.union(screwTotal
.movex(-pinOffset)
.rotz(-mountPlatePinAngle))
distanceToTopOfGear = topOfGearToCenter
drivenLinkThickness =centerLinkToBearingTop+topOfGearToCenter-(washerThickness*2)
screwWithNut = screwTotal.union(LockNutCentered.makeKeepaway(printerOffset.getMM())
.rotx(180)
.union(wrenchKeepaway)
.rotz(90)
)
.movez(-58)
armScrews = screwWithNut.rotz(-45)
.movey(-screwCenterLine+screwHeadKeepaway)
.union(screwWithNut.rotz(45)
.movey(screwCenterLine-screwHeadKeepaway))
.union(screwTotal
.union(new Cylinder(boltHeadKeepaway/2,boltHeadKeepaway/2,screwLength*2,(int)8).toCSG()
.movez(thirdPinStandoff-drivenLinkThickness)
)
.movez(centerLinkToBearingTop-encoderBearingHeight)
.movex(-thirdarmBoltBackSetDistance)
.roty(90)
)
.union(screwTotal
.movez((-centerLinkToBearingTop-encoderBearingHeight)*2)
.union(new Cylinder(boltHeadKeepaway/2,boltHeadKeepaway/2,screwLength*2,(int)8).toCSG()
.movez(thirdPinStandoff-drivenLinkThickness+centerLinkToBearingTop-encoderBearingHeight)
)
.movex(-thirdarmBoltBackSetDistance+22)
.roty(90)
)
.roty(-90)
.movez(centerLinkToBearingTop-screwHeadKeepaway*1.5)
screwWithNut = screwTotal.union(LockNutCentered.makeKeepaway(printerOffset.getMM())
.rotx(180)
.union(wrenchKeepaway)
.rotz(90)
)
.movez(-58)
gearScrew =screwTotal
.union(nutAndDriverKeepaway.roty(180))
.movez(-gearHeightValue+washerThickness+nutInsetDistance)
LoadCellScrews = gearScrew
.movey(-screwCenterLine+screwHeadKeepaway)
.union(gearScrew
.movey(screwCenterLine-screwHeadKeepaway))
.movex(loadCellBoltCenter)
.movez(-distanceToTopOfGear+2)
loadBearingPinBearing =new Cylinder( brassBearingRadius,
brassBearingRadius,
drivenLinkThickness+encoderBearingHeight,
(int)30).toCSG()
.toZMin()
.movez(-pinLength/2)
loadBearingPin =new Cylinder(pinRadius,pinRadius,pinLength,(int)30).toCSG()
.movez(-pinLength/2)
.union( loadBearingPinBearing)
}
double centerOfRobotToBackEdgeOfBoard = 222.357
int linkResolution = 6
double boardX = 530*2
double boardY = 330*2
boolean showVitamins =false
boolean showRightPrintedParts = true
boolean showLeftPrintedParts = true
int[] version = com.neuronrobotics.javacad.JavaCadBuildInfo.getBuildInfo();
HashMap<String , HashMap<String,ArrayList<CSG>>> map = new HashMap<>();
HashMap<String,ArrayList<CSG>> bodyMap = new HashMap<>();
LengthParameter thickness = new LengthParameter("Material Thickness",6.1,[10,1])
LengthParameter ballRadius = new LengthParameter("ballRadius",(1.1*25.4)/2,[20,0.001])
LengthParameter ballCenter = new LengthParameter("ballCenter",30.72,[20,0.001])
LengthParameter printerOffset = new LengthParameter("printerOffset",0.5,[1.2,0])
StringParameter boltSizeParam = new StringParameter("Bolt Size","M5",Vitamins.listVitaminSizes("capScrew"))
StringParameter bearingSizeParam = new StringParameter("Encoder Board Bearing","R8-60355K505",Vitamins.listVitaminSizes("ballBearing"))
//StringParameter gearBParam = new StringParameter("Gear B","HS60T",Vitamins.listVitaminSizes("vexGear"))
//StringParameter gearBParam = new StringParameter("Gear B","HS84T",Vitamins.listVitaminSizes("vexGear"))
//StringParameter gearBParam = new StringParameter("Gear B","HS36T",Vitamins.listVitaminSizes("vexGear"))
//StringParameter gearBParam = new StringParameter("Gear B","HS12T",Vitamins.listVitaminSizes("vexGear"))
//String springType = "Torsion-9271K133"
//HashMap<String, Object> springData = Vitamins.getConfiguration("torsionSpring",springType)
HashMap<String, Object> bearingData = Vitamins.getConfiguration("ballBearing",bearingSizeParam.getStrValue())
HashMap<String, Object> boltMeasurments = Vitamins.getConfiguration( "capScrew",boltSizeParam.getStrValue())
HashMap<String, Object> nutMeasurments = Vitamins.getConfiguration( "nut",boltSizeParam.getStrValue())
double workcellSize = 700
double cameraLocation =(workcellSize-20)/2
TransformNR cameraLocationNR = new TransformNR(cameraLocation+20,0,cameraLocation+20,new RotationNR(0,-180,-35))
Transform cameraLocationCSG =TransformFactory.nrToCSG(cameraLocationNR)
//println boltMeasurments.toString() +" and "+nutMeasurments.toString()
double springHeight = 26
double motorBackSetDistance =5
double boltDimeMeasurment = boltMeasurments.get("outerDiameter")
double boltHeadThickness =boltMeasurments.headHeight
double boltHeadKeepaway = boltMeasurments.headDiameter*1.25
double nutDimeMeasurment = nutMeasurments.get("width")
double nutThickMeasurment = nutMeasurments.get("height")
//pin https://www.mcmaster.com/#98381a516/=19n8j9z
// PN: 98381A516
double pinRadius = ((3/16)*25.4+printerOffset.getMM())/2
double pinExtraDepth = 1.0/2.0*25.4
double pinLength = (1.5*25.4)+pinExtraDepth + (printerOffset.getMM()*2)
// bushing
//https://www.mcmaster.com/#6391k123/=16s6one
//double brassBearingRadius = ((1/4)*25.4+printerOffset.getMM())/2
double brassBearingRadius = pinRadius
double brassBearingLength = (5/8)*25.4
double linkMaterialThickness = pinLength/2-3-(pinExtraDepth/2)
// #8x 1-5/8 wood screw
double screwDrillHole=((boltMeasurments.outerDiameter-1.2)+printerOffset.getMM())/2
double screwthreadKeepAway= (boltMeasurments.outerDiameter+(printerOffset.getMM()*2))/2
double screwHeadKeepaway =boltMeasurments.headDiameter/2 + printerOffset.getMM()
double screwLength = 200 //1-5/8
//Encoder Cap mesurments
double encoderCapRodRadius =7
double cornerRadius =1
//double capPinSpacing = gearAMeasurments.diameter*0.75+encoderCapRodRadius
//double pinOffset =gearBMeasurments.diameter/2+encoderCapRodRadius*2
//double mountPlatePinAngle =Math.toDegrees(Math.atan2(capPinSpacing,pinOffset))
double bearingDiameter = bearingData.outerDiameter
double washerThickness = 2.0
double washerOd = 17
double washerId = 12.75
double encoderToEncoderDistance = (springHeight/2)+linkMaterialThickness + (washerThickness*2)
CSG washerInner =new Cylinder(washerId/2,washerId/2,washerThickness,(int)30).toCSG() // a one line Cylinder
CSG washerOuter =new Cylinder(washerOd/2,washerOd/2,washerThickness,(int)30).toCSG() // a one line Cylinder
CSG washer = washerOuter.difference(washerInner)
CSG washerWithKeepaway = washerOuter
.difference(washerInner
.makeKeepaway(printerOffset.getMM()*1.5
))
DHParameterKinematics neck=null;
CSG tmpNut= Vitamins.get( "lockNut",boltSizeParam.getStrValue())
.rotz(30)
CSG bolt = Vitamins.get( "capScrew",boltSizeParam.getStrValue());
CSG previousServo = null;
CSG previousEncoder = null
CSG encoderCapCache=null
CSG encoderServoPlate=null;
HashMap<Double,CSG> springLinkBlockLocal=new HashMap<Double,CSG>();
HashMap<Double,ArrayList<CSG>> sidePlateLocal=new HashMap<Double,ArrayList<CSG>>();
double rectParam = 0.1*25.4
CSG part = new Cube(rectParam,rectParam,2*rectParam).toCSG()
def loadCellCutoutLocal = CSG.unionAll( Extrude.bezier( part,
[(double)20.0,(double)0.0,(double)0.0], // Control point one
[(double)20.0,(double)0.0,(double)25.0], // Control point two
[(double)0.0,(double)0.0,(double)(20.0+(3.0*rectParam)+4.0)], // Endpoint
(int)10)
).movex(-21.5)
.movez(-2.0-rectParam)
CSG encoderSimple = (CSG) ScriptingEngine
.gitScriptRun(
"https://github.com/madhephaestus/SeriesElasticActuator.git", // git location of the library
"encoderBoard.groovy" , // file to load
null// no parameters (see next tutorial)
)
List<CSG> nucleo = (List<CSG>) ScriptingEngine
.gitScriptRun(
"https://github.com/madhephaestus/SeriesElasticActuator.git", // git location of the library
"nucleo-144.groovy" , // file to load
null
)
CSG encoderKeepaway = (CSG) ScriptingEngine
.gitScriptRun(
"https://github.com/madhephaestus/SeriesElasticActuator.git", // git location of the library
"encoderBoard.groovy" , // file to load
[10]// create a keepaway version
)
.union(loadCellCutoutLocal)
.movez(-encoderToEncoderDistance)
CSG encoder1 = encoderSimple.union(loadCellCutoutLocal).movez(-encoderToEncoderDistance)
CSG screwHole = new Cylinder(screwDrillHole,screwDrillHole,screwLength,(int)8).toCSG() // a one line Cylinder
.toZMax()
CSG screwHoleKeepaway = new Cylinder(screwthreadKeepAway,screwthreadKeepAway,100+(washerThickness*4),(int)8).toCSG() // a one line Cylinder
.toZMin()
CSG screwHead= new Cylinder(boltHeadKeepaway/2,boltHeadKeepaway/2,screwLength*2,(int)8).toCSG() // a one line Cylinder
.movez(screwHoleKeepaway.getMaxZ())
CSG screwChampher = new Cylinder(screwDrillHole,screwthreadKeepAway,printerOffset.getMM()*4,(int)8).toCSG() // a one line Cylinder
.toZMax()
CSG screwTotal = CSG.unionAll([screwHead,screwChampher,screwHoleKeepaway,screwHole])
//.movez()
//.movez(-encoderSimple.getMaxZ())
double centerHoleRad=(20)/2
CSG centerHole =new Cylinder(centerHoleRad,centerHoleRad,20,(int)30)
.toCSG()
.movez(-10)
.roty(90)
double loadCellwidth = 12.7
double screwOffsetFromSides = 5
double screwCenterLine = boltHeadKeepaway+loadCellwidth-screwOffsetFromSides
double encoderBearingHeight = encoderSimple.getMaxZ()
double topPlateOffset = encoderToEncoderDistance*2-encoderBearingHeight*2
double centerLinkToBearingTop = encoderToEncoderDistance-encoderBearingHeight
double totalSpringLength = 47.5
double drivenLinkWidth = screwCenterLine*1.5+encoderCapRodRadius+screwOffsetFromSides
double drivenLinkX = totalSpringLength+encoderCapRodRadius
double legLength = totalSpringLength
double drivenLinkXFromCenter = legLength+encoderCapRodRadius
double loadCellBoltCenter = -(40.0-5.0-(15.0/2))
double thirdarmBoltBackSetDistance = 16.0
CSG LockNutKeepaway = tmpNut.movey(thickness.getMM())
.union(tmpNut.movey(-thickness.getMM()))
.hull()
CSG LockNutCentered = LockNutKeepaway.movey(thickness.getMM())
double nutDriverRadius = (0.75*25.4)/2
double nutInsetDistance =tmpNut.getMaxZ();
CSG nutDriver = new Cylinder(nutDriverRadius,nutInsetDistance*2).toCSG()
CSG nutAndDriverKeepaway = nutDriver.union(tmpNut.movez(-1))
CSG wrenchKeepaway=new Cube(20,40,6).toCSG()
.toYMax()
.movey(3)
.toZMax()
.movez(printerOffset.getMM())
.union(tmpNut
.makeKeepaway(printerOffset.getMM())
.rotx(180)
.movez(1)
)
double thirdPinStandoff =37
// Loading the gear bolts for the load cell
CSG loadCell = (CSG) ScriptingEngine
.gitScriptRun(
"https://github.com/madhephaestus/SeriesElasticActuator.git", // git location of the library
"loadCell.groovy" , // file to load
null// no parameters (see next tutorial)
)
.rotx(-90)
//.movey(-drivenLinkWidth/2)
.movez(1)
CSG standoffBLock=null
ArrayList<CSG> manipulationParts = []
CSG manipulationBall=null
/**
* Gets the all dh chains.
*
* @return the all dh chains
*/
public ArrayList<DHParameterKinematics> getLimbDHChains(MobileBase base) {
ArrayList<DHParameterKinematics> copy = new ArrayList<DHParameterKinematics>();
for(DHParameterKinematics l:base.getLegs()){
copy.add(l);
}
for(DHParameterKinematics l:base.getAppendages() ){
copy.add(l);
}
return copy;
}
@Override
public ArrayList<CSG> generateBody(MobileBase base ){
setGearing(gearRatios[0])
ArrayList<CSG> attachmentParts = new ArrayList<CSG>()
double maxz = 0.001
for(DHParameterKinematics l:getLimbDHChains(base)){
double thisZ = l.getRobotToFiducialTransform().getZ()
if(thisZ>maxz)
maxz=thisZ
}
DHParameterKinematics sourceLimb=base.getAppendages() .get(0)
TransformNR step = sourceLimb.calcHome();
Transform tipatHome = TransformFactory.nrToCSG(step)
LinkConfiguration conf = sourceLimb.getLinkConfiguration(0);
ArrayList<DHLink> dhLinks=sourceLimb.getChain().getLinks();
DHLink dh = dhLinks.get(0);
HashMap<String, Object> servoMeasurments = Vitamins.getConfiguration(conf.getElectroMechanicalType(),conf.getElectroMechanicalSize())
double totalFlangLen = (servoMeasurments.flangeLongDimention-servoMeasurments.servoThickDimentionThickness)/2
double shaftToShortSideFlandgeEdge = servoMeasurments.shaftToShortSideDistance+totalFlangLen
LengthParameter tailLength = new LengthParameter("Cable Cut Out Length",maxz,[500,0.01])
tailLength.setMM(maxz)
//CSG servoReference= Vitamins.get(conf.getElectroMechanicalType(),conf.getElectroMechanicalSize())
// .rotz(180+Math.toDegrees(dh.getTheta()))
// .movez(-motorBackSetDistance)
double servoNub = servoMeasurments.tipOfShaftToBottomOfFlange - servoMeasurments.bottomOfFlangeToTopOfBody
//double servoTop = servoReference.getMaxZ()-servoNub
double topLevel = maxz -(springHeight/2)-linkMaterialThickness +encoderBearingHeight-(washerThickness*2)
double servoPlane = topLevel - servoMeasurments.bottomOfFlangeToTopOfBody
double servoEncoderPlane = topLevel - encoderBearingHeight
double basexLength = gearDistance + servoMeasurments.servoThinDimentionThickness/2
//double baseyLength = servoMeasurments.flangeLongDimention
double servoCentering = servoMeasurments.flangeLongDimention -shaftToShortSideFlandgeEdge
double minimumWidth = (capPinSpacing-encoderCapRodRadius-cornerRadius)
if(servoCentering<minimumWidth)
servoCentering=minimumWidth
double baseyLength = servoCentering*2
double keepAwayDistance =10
CSG gearHole = gearKeepaway
.movez(topLevel+washerThickness)
//servoReference=servoReference
// .movez(servoPlane)
// .movex(-gearDistance)
CSG baseServo = Vitamins.get(conf.getElectroMechanicalType(),conf.getElectroMechanicalSize())
.rotz(180)
.movez(maxz-centerLinkToBearingTop-encoderBearingHeight)
.movex(-gearDistance)
CSG encoderBaseKeepaway = (CSG) ScriptingEngine
.gitScriptRun(
"https://github.com/madhephaestus/SeriesElasticActuator.git", // git location of the library
"encoderBoard.groovy" , // file to load
[topLevel+5]// create a keepaway version
)
.movez(servoEncoderPlane)
double encoderKeepawayDistance= 20
double sidePlateclearenceHeight = 10*24.5
/*
for (int i=1;i<3;i++){
servoReference=servoReference
.union(servoReference
.movez(servoMeasurments.flangeThickness*i))
}
*/
println "Base cross height "+(baseyLength+(keepAwayDistance*3))
CSG keepawayBottomX = new Cube(basexLength+(keepAwayDistance*3)+encoderKeepawayDistance,
baseyLength-(keepAwayDistance*2),
keepAwayDistance)
.toCSG()
.toZMin()
CSG keepawayBottomY = new Cube(basexLength+encoderKeepawayDistance-(keepAwayDistance*2),
baseyLength+(keepAwayDistance*3),
keepAwayDistance)
.toCSG()
.toZMin()
CSG baseShapeCutter = new Cube(basexLength+(keepAwayDistance*2)+encoderKeepawayDistance,
baseyLength+(keepAwayDistance*2),
topLevel)
.toCSG()
.toXMax()
.toYMin()
.toZMin()
.movex(keepAwayDistance+encoderKeepawayDistance)
CSG baseShape = new RoundedCube(basexLength+(keepAwayDistance*2)+encoderKeepawayDistance,
baseyLength+(keepAwayDistance*2),
topLevel)
.cornerRadius(cornerRadius)
.toCSG()
.toZMin()
.difference([keepawayBottomY])
/*
CSG sidePlate = new Cube( basexLength+(keepAwayDistance*2)+encoderKeepawayDistance,
1.0,
topLevel)
.toCSG()
.movey((baseyLength+(keepAwayDistance*2))/2)
.toZMin()
sidePlate=sidePlate
.union(sidePlate.movez(sidePlateclearenceHeight))
.union(sidePlate.movez(-20*25.4))
.hull()
CSG strapSlot = new Cube(5,
(baseyLength+(keepAwayDistance*2))*2,
25.4
).toCSG()
.toXMax()
.movex((basexLength+(keepAwayDistance*2)+encoderKeepawayDistance)/2 - 10)
CSG strapSlots = strapSlot
for(int i=1;i<13;i++){
strapSlots=strapSlots.union(strapSlot.movez(-38*i))
}
sidePlate=sidePlate.difference(strapSlots)
*/
CSG screws = screwSet
//.movez(topLevel)
CSG screwAcross = screwTotal
.movez(-topLevel)
.rotx(90)
.movez(topLevel/2)
screwAcross=CSG.unionAll([
//screwAcross,// middle bolt
screwAcross.movez(topLevel/2-(keepAwayDistance/2+screwHeadKeepaway))// Frontmost bolt
.movex(baseShape.getMaxX()-(keepAwayDistance/2+screwHeadKeepaway)-7-printerOffset.getMM()),
//screwAcross.movex(baseShape.getMinX()+(keepAwayDistance/2+screwHeadKeepaway)), Back most bolt
screwAcross.movez(topLevel/2-(keepAwayDistance/2+screwHeadKeepaway))
.movex(screwHeadKeepaway)
])
CSG bottomScrews = screwTotal.rotx(180)
.union(tmpNut
.toZMax()
.movez(-10)
.union(tmpNut)
.hull()
.makeKeepaway(printerOffset.getMM())
)
// Originally calculated, fixed to make sure maunfactured parts mesh
//Bottom Bolt hole pattern x= 97.78700180053711 y = 77.5 inset = 9.75
//double inset = (keepAwayDistance/2+screwHeadKeepaway)
//double screwX = baseShape.toXMin().getMaxX()-(inset*2)
//double screwY = baseShape.toYMin().getMaxY()-(inset*2)
double inset = 9.75
double screwX = 97.78700180053711
double screwY = 77.5
double distanceFromCenterToBolt = baseShape.getMaxX() - inset
println "Bottom Bolt hole pattern x total= "+screwX+
" y total= "+screwY+
" inset from edge= "+inset+
" Center to forward Robot Bolts=" +(distanceFromCenterToBolt/2)+
" center distance to calibration hole ="+tipatHome.getX()
CSG bottomScrewSet =bottomScrews
.movex(-screwX)
.movey(screwY/2)
.union(
bottomScrews
.movex(-screwX)
.movey(-screwY/2)
)
.union(
bottomScrews
.movey(screwY/2)
)
.union(
bottomScrews
.movey(-screwY/2)
)
.movex(distanceFromCenterToBolt)
.movez(topLevel)
baseShape = baseShape.difference([bottomScrewSet,screwAcross])
double boardKeepaway =50
CSG nucleoBoard = nucleo.get(0).movey(-boardKeepaway)
double baseBackSet = -baseShape.getMaxX()+keepAwayDistance+encoderKeepawayDistance
double spacing = 75
double nucleoMountPlacement = spacing+baseBackSet+nucleoBoard.getMaxX()
CSG boxCut = new Cube((workcellSize/2)+nucleoMountPlacement+boardKeepaway,workcellSize,thickness.getMM()*2).toCSG()
.toXMax()
.movex(workcellSize/2)
manipulationParts.clear()
def parts =(ArrayList<CSG>)ScriptingEngine
.gitScriptRun(
"https://github.com/WPIRoboticsEngineering/RBELabCustomParts.git", // git location of the library
"3001TrackingObjects.groovy" , // file to load
null// no parameters (see next tutorial)
)
manipulationBall=parts.get(0)
.movez(-ballCenter.getMM())
.roty(90)
manipulationParts.addAll(parts.collect{
it.movez(-ballCenter.getMM())
.roty(90)
.transformed(tipatHome)
})
//CSG tipHole =new Cylinder(10,10,thickness.getMM()*3,(int)90).toCSG()
// .movez(-thickness.getMM()*1.5)
double footingWidth = 330
double insetForMakerbeam =15
CSG footing =new Cube(workcellSize,footingWidth,thickness.getMM()).toCSG()
.toXMin()
.movex(-centerOfRobotToBackEdgeOfBoard)
CSG hole = new Cylinder(1.5, // Radius at the bottom
1.5, // Radius at the top
thickness.getMM()*4, // Height
(int)30 //resolution
).toCSG()//convert to CSG to display
.movez(thickness.getMM()*-2)
def holeset = hole.movey( footingWidth/2-insetForMakerbeam)
.union(hole.movey( -footingWidth/2+insetForMakerbeam))
def allSideHoles=holeset
for(int i= -workcellSize+insetForMakerbeam;i< workcellSize-insetForMakerbeam;i+= workcellSize/6){
//allSideHoles= allSideHoles.union( holeset.movex(i))
}
double etchWith =0.5
//etchX = (workcellSize/2)-2
//CSG etchX =new Cube((workcellSize/2)-2,etchWith,thickness.getMM()).toCSG()
// .toXMin()
//CSG etchY =new Cube(etchWith,footingWidth-2,thickness.getMM()).toCSG()
def etchParts = []
double gridDimention =25
CSG etch =new Cube(10,10,thickness.getMM()).toCSG()
.toXMin()
.toYMin()
etch=etch
int x =0
//def cameraParts = getCameraMount()
CSG basePlate = footing
.toZMax()
.difference(nucleoBoard
.rotz(90)
.movey(nucleoBoard.getMaxX()/2)
.movex(-spacing-nucleoBoard.getMaxX()/2)
.movex(baseBackSet)
)
.difference( bottomScrewSet.movex(baseBackSet))
.intersect(boxCut)
.difference(manipulationParts)
//.difference(cameraParts)
.difference(etchParts)
//.union(allSideHoles)
def basePlateUpper=basePlate.intersect(footing)
def basePlateLower=basePlate.difference(footing) /*
CSG sidePlateA=sidePlate
.difference(screwAcross)
.difference(screwAcross.movez(sidePlateclearenceHeight))
.movex(baseBackSet)
CSG sidePlateB = sidePlateA
.movey(-(baseyLength+(keepAwayDistance*2)))
*/
baseShape = baseShape
.toYMin()
.movey(-servoCentering-keepAwayDistance)
.movex(baseBackSet)
.difference([encoderBaseKeepaway,baseServo,screws,gearHole])
CSG baseCap = getEncoderCap()
.movez(topLevel)
CSG baseShapeA = baseShape.difference(baseShapeCutter)
.setColor(javafx.scene.paint.Color.CYAN);
CSG baseShapeB = baseShape.intersect(baseShapeCutter)
.setColor(javafx.scene.paint.Color.GREEN);
baseCap.setColor(javafx.scene.paint.Color.LIGHTBLUE);
baseCap.setManufacturing({ toMfg ->
return toMfg
.roty(180)
.toZMin()
})
baseShapeB.setManufacturing({ toMfg ->
return toMfg
.rotx(90)
.toZMin()
})
baseShapeA.setManufacturing({ toMfg ->
return toMfg
.rotx(-90)
.toZMin()
})
basePlateUpper.setManufacturing({ toMfg ->
p= toMfg
.toXMin()
.toYMin()
.toZMin()
p.addExportFormat("svg")
//Transform t=new Transform()
return p
})
basePlateLower.setManufacturing({ toMfg ->
p= toMfg
.toXMin()
.toYMin()
.toZMin()
p.addExportFormat("svg")
//Transform t=new Transform()
return p
})
/*
sidePlateA.setManufacturing({ toMfg ->
return toMfg
.rotx(-90)
.toZMin()
.toXMin()
.movex(basePlate.getMaxX())
})
sidePlateB.setManufacturing({ toMfg ->
return toMfg
.rotx(-90)
.toZMin()
.toXMin()
.movex(basePlate.getMaxX())
})
*/
//if(showRightPrintedParts)attachmentParts.add(sidePlateA)
//if(showRightPrintedParts)attachmentParts.add(sidePlateB)
//if(showLeftPrintedParts)attachmentParts.add(baseShapeA)
//if(showRightPrintedParts)attachmentParts.add(baseShapeB)
//if(showRightPrintedParts)attachmentParts.add(basePlate)
//if(showLeftPrintedParts)attachmentParts.add(baseCap)
// for (int i=0;i<cameraParts.size();i++){
// CSG p = cameraParts.get(i)
// p.addExportFormat("svg")
// }
//cameraParts.forEach{
// it.addExportFormat("svg")
// add(attachmentParts,it,null,"cameraStand_SVG")
//}
basePlateUpper.addExportFormat("svg")
basePlateLower.addExportFormat("svg")
add(attachmentParts,baseShapeA,null,"baseLeft")
add(attachmentParts,baseShapeB,null,"baseRight")
add(attachmentParts,basePlateUpper,null,"basePlateEtching_SVG")
add(attachmentParts,basePlateLower,null,"basePlateCut_SVG")
add(attachmentParts,baseCap,null,"baseCap")
add(attachmentParts,manipulationParts.get(0),null,"colorObject")
add(attachmentParts,manipulationParts.get(1),null,"coaster")
add(attachmentParts,manipulationParts.get(2),null,"calibrationObject")
return attachmentParts;
}
@Override
public ArrayList<CSG> generateCad(DHParameterKinematics sourceLimb, int linkIndex) {
def parts =(ArrayList<CSG>)ScriptingEngine
.gitScriptRun(
"https://github.com/WPIRoboticsEngineering/RBELabCustomParts.git", // git location of the library
"3001TrackingObjects.groovy" , // file to load
null// no parameters (see next tutorial)
)
manipulationBall=parts.get(0)
.movez(-ballCenter.getMM())
.roty(90)
//return new ArrayList<CSG>()
//Creating the horn
ArrayList<DHLink> dhLinks=sourceLimb.getChain().getLinks();
String legStr = sourceLimb.getXml()
LinkConfiguration conf = sourceLimb.getLinkConfiguration(linkIndex);
LinkConfiguration nextLink=null;
if(linkIndex<dhLinks.size()-1){
nextLink=sourceLimb.getLinkConfiguration(linkIndex+1);
}
setGearing(gearRatios[linkIndex])
String linkStr =conf.getXml()
ArrayList<CSG> csg = null;
HashMap<String,ArrayList<CSG>> legmap=null;
if(map.get(legStr)==null){
map.put(legStr, new HashMap<String,ArrayList<CSG>>())
// now load the cad and return it.
}
legmap=map.get(legStr)
if(legmap.get(linkStr) == null ){
legmap.put(linkStr,new ArrayList<CSG>())
}
csg = legmap.get(linkStr)
if(csg.size()>linkIndex){
// this link is cached
println "This link is cached"
return csg;
}
DHLink dh = dhLinks.get(linkIndex);
CSG springBlockPartRaw=springBlock(drivenLinkThickness)
CSG springBlockPart =springBlockPartRaw
.rotz(-Math.toDegrees(dh.getTheta()))
CSG springBlockPartGear = springBlockPin(gearHeightValue)
.rotx(180)
.rotz(-Math.toDegrees(dh.getTheta()))
// creating the servo
CSG springMoved = moveDHValues(loadCell
//.movez(washerThickness)
.rotz(-Math.toDegrees(dh.getTheta()))
.movez(springBlockPart.getMinZ())
//.rotz(linkIndex==0?180:0)
,dh)
CSG washerMoved = washerWithKeepaway
.movez(centerLinkToBearingTop-washerThickness)
CSG tmpMyGear = gearB
.rotz(5)
.union(washer.toZMax())
.movez(-centerLinkToBearingTop+washerThickness)
tmpMyGear = tmpMyGear
.difference(springBlockPartGear
.intersect(tmpMyGear)
.hull()
)
.union(springBlockPartGear)
CSG loadCellBolts = moveDHValues(LoadCellScrews
.rotz(-Math.toDegrees(dh.getTheta()))
,dh)
CSG myArmScrews = moveDHValues(armScrews
.rotz(-Math.toDegrees(dh.getTheta()))
,dh)
.movex(springBlockPartRaw.getMaxX())
CSG myGearB = moveDHValues(tmpMyGear
.difference(loadBearingPin)
,dh)
.difference(loadCellBolts)
.difference(myArmScrews)
.setColor(javafx.scene.paint.Color.LIGHTGREEN);
CSG myPin = moveDHValues(loadBearingPin,dh)
CSG myspringBlockPart = moveDHValues(springBlockPart
.difference(loadBearingPin)
,dh)
.difference(loadCellBolts)
.difference(myGearB)
.setColor(javafx.scene.paint.Color.BROWN);
CSG handMountPart=null;
if(linkIndex<dhLinks.size()-1){
//HashMap<String, Object> shaftmap = Vitamins.getConfiguration(nextLink.getShaftType(),nextLink.getShaftSize())
//HashMap<String, Object> servoMeasurments = Vitamins.getConfiguration(nextLink.getElectroMechanicalType(),nextLink.getElectroMechanicalSize())
//println conf.getShaftType() +" "+conf.getShaftSize()+" "+shaftmap
CSG servoReference= Vitamins.get(nextLink.getElectroMechanicalType(),nextLink.getElectroMechanicalSize())
.rotz(90)
double servoTop = servoReference.getMaxZ()
servoReference=servoReference
.movez(-centerLinkToBearingTop-encoderBearingHeight)
.movex(-gearDistance)
//.rotz(90+Math.toDegrees(dh.getTheta()))
double gearPlacementVSMotor = -(motorBackSetDistance+washerThickness)
def myGearA = getGearWithSpline( nextLink );
if(linkIndex==0){
CSG baseServo = Vitamins.get(nextLink.getElectroMechanicalType(),nextLink.getElectroMechanicalSize())
.rotz(180)
.movez(-centerLinkToBearingTop-encoderBearingHeight)
.movex(-gearDistance)
CSG secondLinkServo =servoReference.clone()
CSG baseForceSenseEncoder = encoder1
CSG baseEncoder = encoder1
previousEncoder = baseEncoder
previousServo = baseServo
CSG baseMyGearA = getGearWithSpline( conf )
.setColor(javafx.scene.paint.Color.BLUE);
baseMyGearA.setManufacturing({ toMfg ->
return toMfg
.toXMin()
.toZMin()
})
add(csg,baseMyGearA,sourceLimb.getRootListener(),"servoGear")
if(showVitamins)add(csg,baseServo,sourceLimb.getRootListener(),"servo")
if(showVitamins)add(csg,baseEncoder,sourceLimb.getRootListener(),"encoder")
if(showVitamins)add(csg,baseForceSenseEncoder,sourceLimb.getRootListener(),"encoder")
}
println "Link Hardware: using from index "+
(linkIndex+1)+
" "+nextLink.getElectroMechanicalSize() +
" "+nextLink.getShaftSize()
CSG forceSenseEncoder = encoder1
.rotz(180-Math.toDegrees(dh.getTheta()))
.rotx(180)
CSG baseEncoderCap = getEncoderCap()
.movez(-centerLinkToBearingTop)
CSG thirdPlusLinkServo =servoReference.clone()
CSG linkEncoder = encoder1
.rotz(-Math.toDegrees(dh.getTheta()))
ArrayList<CSG> esp = getServoCap(nextLink)
double linkCconnectorOffset = drivenLinkXFromCenter-(encoderCapRodRadius+bearingDiameter)/2
def end = [(double)-dh.getR()+linkCconnectorOffset,(double)dh.getD()*0.98,(double)0]
def controlOne = [(double)-2 ,(double)end.get(1)*0.8,(double)0]
def controlTwo = [(double)end.get(0),(double)0,(double)end.get(2)*1.1]
CSG connectorArmCross = new RoundedCube(cornerRadius*2,
encoderCapRodRadius+bearingDiameter -cornerRadius-5,
encoderBearingHeight)
.cornerRadius(cornerRadius)
.toCSG()
def ribs = Extrude.moveBezier( connectorArmCross,
controlOne, // Control point one
controlTwo, // Control point two
end ,// Endpoint
(int)5
)
CSG mountLug = new RoundedCube(encoderCapRodRadius+bearingDiameter,drivenLinkWidth,drivenLinkThickness)
.cornerRadius(cornerRadius)
.toCSG()
.toXMax()
.toZMax()
.movez(centerLinkToBearingTop)
.movex(drivenLinkX)
mountLug = moveDHValues(mountLug.rotz(-Math.toDegrees(dh.getTheta()))
,dh)
mountLug=mountLug.union(
mountLug
.toZMax()
.movez(centerLinkToBearingTop+encoderBearingHeight)
)
CSG bounding = ribs.get(ribs.size()-2).getBoundingBox()
/*
CSG supportRib = ribs.get(ribs.size()-2)
//.intersect(bounding.movex(-5))
//.intersect(bounding.movex(5))
.movez(encoderBearingHeight -cornerRadius*2)
//.union(ribs.get(ribs.size()-2))
.union(ribs.get(ribs.size()-1)
*/
CSG upperRib = ribs.get(ribs.size()-2)
.movez(encoderBearingHeight -cornerRadius*2)
//.movex(-2)
.movey(12)
CSG supportRib = ribs.get(ribs.size()-1)
.union(upperRib)
.toZMin()
.movez(centerLinkToBearingTop-encoderBearingHeight+ cornerRadius*2)
.union(mountLug)
.hull()
.movex(5)// offset to avoid hitting pervious link
//.movey(-1)// offset to avoid hitting pervious link
//.movez(-2)// adjust support to met previous gear
def linkParts = Extrude.bezier( connectorArmCross,
controlOne, // Control point one
controlTwo, // Control point two
end ,// Endpoint
linkResolution
)
print "\r\nUnioning link..."
long start = System.currentTimeMillis()
CSG bracketBezier = CSG.unionAll(linkParts)
.toZMin()
.movez(centerLinkToBearingTop )
.movex(5)// offset to avoid hitting pervious link
.movey(-2)// offset to avoid hitting pervious link
CSG sidePlateWithServo =esp.get(0)
CSG linkSection = bracketBezier
linkSection = linkSection
.union(supportRib)
double xSize= (-linkSection.getMinX()+linkSection.getMaxX())
double ySize= (-linkSection.getMinY()+linkSection.getMaxY())
double zSize= (-linkSection.getMinZ()+linkSection.getMaxZ())
CSG bottomCut = new Cube(xSize*2, ySize*2,zSize).toCSG()
.toZMax()
.toXMin()
.movez(springBlockPart.getMinZ()+cornerRadius)
bottomCut=moveDHValues(bottomCut
.rotz(-Math.toDegrees(dh.getTheta()))
,dh)
CSG otherEncoder = linkEncoder.rotx(180)
//if(linkIndex==0){
CSG rightSIdeSupport =bracketBezier
.toZMin()
.movez(sidePlateWithServo.getMinZ())
.union([supportRib
.mirrorz()
.movex(5)
]
)
.difference(sidePlateWithServo.hull())
.minkowskiDifference(
springBlockPart.hull(),// the part we want to fit into a cutout
6.0// the offset distance to fit
)
.minkowskiDifference(
myGearB.hull(),// the part we want to fit into a cutout
6.0// the offset distance to fit
)
sidePlateWithServo =sidePlateWithServo
.union(rightSIdeSupport)
.difference(linkEncoder)
//.difference(baseEncoderCap)
.difference([springBlockPart,
tmpMyGear,myGearB])
.difference(myArmScrews)
.difference(springMoved)
//.difference(bottomCut)
.difference(linkSection)
//}
linkSection = linkSection
.difference(myspringBlockPart
.intersect(linkSection)
.hull()