-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMarcosCad.groovy
1729 lines (1548 loc) · 67.5 KB
/
MarcosCad.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
// https://mvnrepository.com/artifact/fr.brouillard.oss/jgitver
@Grapes(
@Grab(group='fr.brouillard.oss', module='jgitver', version='0.14.0')
)
import fr.brouillard.oss.jgitver.*;
import eu.mihosoft.vrl.v3d.*;
import javafx.scene.text.Font;
import com.google.gson.reflect.TypeToken
import com.neuronrobotics.bowlerstudio.creature.ICadGenerator
import com.neuronrobotics.bowlerstudio.creature.IgenerateBed
import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine
//import com.neuronrobotics.bowlerstudio.vitamins.VitaminBomManager
import com.neuronrobotics.bowlerstudio.vitamins.Vitamins
import com.neuronrobotics.sdk.addons.kinematics.AbstractLink
import com.neuronrobotics.sdk.addons.kinematics.DHLink
import com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics
import com.neuronrobotics.sdk.addons.kinematics.LinkConfiguration
import com.neuronrobotics.sdk.addons.kinematics.MobileBase
import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR
import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR
import eu.mihosoft.vrl.v3d.CSG
import eu.mihosoft.vrl.v3d.ChamferedCube
import eu.mihosoft.vrl.v3d.Cube
import eu.mihosoft.vrl.v3d.Cylinder
import eu.mihosoft.vrl.v3d.FileUtil
import eu.mihosoft.vrl.v3d.PrepForManufacturing
import eu.mihosoft.vrl.v3d.RoundedCube
import eu.mihosoft.vrl.v3d.Sphere
import eu.mihosoft.vrl.v3d.Transform
import eu.mihosoft.vrl.v3d.parametrics.LengthParameter
import javafx.scene.paint.Color
import javafx.scene.transform.Affine
import eu.mihosoft.vrl.v3d.ChamferedCylinder
import java.lang.reflect.Type
import java.nio.file.Paths
import javax.xml.transform.TransformerFactory
import org.apache.commons.math3.analysis.function.Atan
import org.apache.commons.math3.analysis.function.Sqrt
import org.apache.commons.math3.genetics.GeneticAlgorithm
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.neuronrobotics.bowlerstudio.creature.MobileBaseCadManager
import com.neuronrobotics.bowlerstudio.physics.TransformFactory
import com.neuronrobotics.sdk.common.DeviceManager
import com.neuronrobotics.sdk.addons.kinematics.VitaminLocation;
import javafx.application.Platform
CSG ChamferedCylinder(double r, double h, double chamferHeight) {
CSG cube1 = new Cylinder(r - chamferHeight,r - chamferHeight, h,40).toCSG();
CSG cube2 = new Cylinder(r,r, h - chamferHeight * 2,40).toCSG().movez(chamferHeight);
return cube1.union(cube2).hull()
}
double computeGearPitch(double diameterAtCrown,double numberOfTeeth){
return ((diameterAtCrown/2)*((360.0)/numberOfTeeth)*Math.PI/180)
}
// Load the devices to map the kinematics of the gear wrist
// this is loaded here in case in the future we need to pass the gear ratio to the gear wrist kinematics.
//ScriptingEngine.gitScriptRun("https://github.com/OperationSmallKat/Marcos.git", "GearWristKinematics.groovy")
url = "https://github.com/OperationSmallKat/Marcos.git"
File parametricsCSV = ScriptingEngine.fileFromGit(url, "parametrics.csv")
HashMap<String,Double> numbers;
BufferedReader reader;
String code="HashMap<String,Double> numbers = new HashMap<>()\n"
String vars=""
String equs=""
try {
reader = new BufferedReader(new FileReader(parametricsCSV.getAbsolutePath()));
String line = reader.readLine();
while ((line = reader.readLine() )!= null) {
if(line.length()>3) {
//System.out.println(line);
String[] parts = line.split(",");
String value=(parts[2].replaceAll(parts[1], "")).trim()
String reconstructed =parts[0]+"="+value;
try {
Double.parseDouble(value)
vars+= reconstructed+"\n"
vars+="numbers.put(\""+parts[0]+"\","+parts[0]+");\n"
}catch(NumberFormatException ex) {
equs+= reconstructed+"\n"
equs+="numbers.put(\""+parts[0]+"\","+parts[0]+");\n"
}
}
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
code+=vars;
code+=equs;
code+="return numbers"
//println code
numbers=(HashMap<String,Double>) ScriptingEngine.inlineScriptStringRun(code, null, "Groovy");
//for(String key :numbers.keySet()) {
// println key+" : "+numbers.get(key)
//}
def honrConfig = Vitamins.getConfiguration("hobbyServoHorn", "standardMicro1")
double hornDiam = honrConfig.hornBaseDiameter
// Begin creating the resin print horn piece withn a chamfered cylendar
CSG core= ChamferedCylinder(hornDiam/2.0,hornDiam,numbers.Chamfer2)
//calculate the depth of the screw head based on the given measurments
double cutoutDepth = numbers.ServoHornHeight-numbers.ServoMountingScrewSpace - numbers.ServoHornSplineHeight
// the cutout for the head of the screw on the resin horn
CSG screwHeadCutOut = new Cylinder(numbers.ServoHornScrewHeadDiamter/2.0,numbers.ServoHornScrewHeadDiamter/2.0, cutoutDepth,30).toCSG()
.toZMax()
.movez(numbers.ServoHornHeight)
// cutout for the hole the shaft of the mount screw passes through
CSG screwHoleCutOut = new Cylinder(numbers.ServoHornScrewDiamter/2.0,numbers.ServoHornScrewDiamter/2.0, numbers.ServoMountingScrewSpace,30).toCSG()
.toZMax()
.movez(numbers.ServoHornHeight-cutoutDepth)
// Cut the holes from the core
CSG cutcore=core.difference([
screwHeadCutOut,
screwHoleCutOut
])
double spineDiameter=4.68+0.2
// use the gear maker to generate the spline
//def gears = ScriptingEngine.gitScriptRun(
// "https://github.com/madhephaestus/GearGenerator.git", // git location of the library
// "bevelGear.groovy" , // file to load
// // Parameters passed to the funcetion
// [
// numbers.ServoHornNumberofTeeth,
// // Number of teeth gear a
// numbers.ServoHornNumberofTeeth,
// // Number of teeth gear b
// numbers.ServoHornSplineHeight,
// // thickness of gear A
// computeGearPitch(spineDiameter,numbers.ServoHornNumberofTeeth),
// // 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
// ]
// )
//// get just the pinion of the set
//CSG spline = gears.get(0)
// cut the spline from the core
CSG resinPrintServoMount=cutcore//.difference(spline)
resinPrintServoMount.setColor(Color.DARKGREY)
resinPrintServoMount.setName("ResinHorn")
//return resinPrintServoMount
class cadGenMarcos implements ICadGenerator{
String url = "https://github.com/OperationSmallKat/Marcos.git"
LengthParameter offset = new LengthParameter("printerOffset",0.0,[2, 0])
CSG resinPrintServoMount
HashMap<String,Double> numbers
LengthParameter tailLength = new LengthParameter("Cable Cut Out Length",30,[500, 0.01])
double endOfPassiveLinkToBolt = 4.5
double hornDiam;
Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
//VitaminBomManager bom;
CSG cachedGearLink =null;
public cadGenMarcos(CSG res,HashMap<String,Double> n,double h) {
resinPrintServoMount=res
numbers=n
hornDiam=h
}
ArrayList<CSG> cache = new ArrayList<CSG>()
private MobileBase mb;
CSG moveDHValues(CSG incoming,DHParameterKinematics d, int linkIndex ){
TransformNR step = new TransformNR(d.getChain().getLinks().get(linkIndex).DhStep(0)).inverse()
Transform move = com.neuronrobotics.bowlerstudio.physics.TransformFactory.nrToCSG(step)
return incoming.transformed(move)
}
CSG reverseDHValues(CSG incoming,DHParameterKinematics d, int linkIndex ){
TransformNR step = new TransformNR(d.getChain().getLinks().get(linkIndex).DhStep(0))
Transform move = com.neuronrobotics.bowlerstudio.physics.TransformFactory.nrToCSG(step)
return incoming.transformed(move)
}
CSG footBallSection() {
def capThickness=2.25
def ballRadius = 10
def radius = ballRadius-(capThickness/2.0)
def neckRad = 6
def arclen=16.5
def neckThicknes =3.5
def theta = (arclen*360)/(2.0*3.14159*radius)
def internalAngle = (90-(theta/2))
def d = Math.sin(Math.toRadians(internalAngle))*radius
//println d +" "+theta+" cir="+(3.14159*radius)+ " ind angle="+internalAngle
CSG slicer = new Cylinder(radius*2, neckThicknes).toCSG()
.difference(new Cylinder(neckRad,neckRad+neckThicknes, neckThicknes,15).toCSG())
.toZMax()
.movez(d)
CSG slicer2 = new Cylinder(radius*2, radius*2).toCSG()
CSG foot = new Sphere(ballRadius,32, 16).toCSG()
.difference(slicer2.movez(d-neckThicknes))
CSG ball = new Sphere(radius,32, 16).toCSG()
.difference(slicer)
//.difference(slicer2)
.union(foot)
//.union(new Cylinder(radius-2, ballRadius).toCSG().toZMax())
}
CSG toBed(ArrayList<CSG> parts, String name) {
CSG bedOne=null
for(CSG p:parts) {
if(bedOne==null)
bedOne=p
else {
bedOne=bedOne.dumbUnion(p)
}
}
if(bedOne!=null)
bedOne.setName(name)
else {
bedOne = new Cube().toCSG()
bedOne.setManufacturing({return null})
}
return bedOne
}
CSG ChamferedCylinder(double r, double h, double chamferHeight) {
CSG c1 = new Cylinder(r - chamferHeight,r - chamferHeight, h,40).toCSG()
CSG c2 = new Cylinder(r,r, h - chamferHeight * 2,40).toCSG().movez(chamferHeight)
return c1.union(c2).hull()
}
CSG ChamferedCylinderHR(double r, double h, double chamferHeight) {
CSG c1 = new Cylinder(r - chamferHeight,r - chamferHeight, h,80).toCSG()
CSG c2 = new Cylinder(r,r, h - chamferHeight * 2,80).toCSG().movez(chamferHeight)
return c1.union(c2).hull()
}
CSG StraightChamfer(double x, double y, double chamferHeight) {
CSG c1 = new Cube(x, y, chamferHeight).toCSG().movez(chamferHeight)
CSG c2 = new Cube(x+chamferHeight,y+chamferHeight, chamferHeight).toCSG()
CSG c3 = c1.union(c2).hull()
return c3.difference(c2).toZMin()
}
CSG StraightChamfer(double x, double y,double z, double xycham,double zcham) {
CSG lower = new ChamferedCube(x, y, z+xycham*2, xycham).toCSG()
lower = lower.intersect(lower.getBoundingBox().movez(xycham))
lower = lower.intersect(lower.getBoundingBox().movez(-xycham))
.movez(-xycham+zcham)
CSG upper = new ChamferedCube(x, y, z, zcham).toCSG()
return new ChamferedCube(x, y, z, zcham).toCSG()
}
CSG ChamferedRoundCornerLug(double x, double y,double r, double h, double chamferHeight) {
CSG corners = ChamferedCylinder(r,h,chamferHeight)
CSG xSec= corners.union(corners.movex(x-r*2))
return xSec.union(xSec.movey(y-(r*2))).hull().toXMin().toYMin().movex(-x/2).movey(-y/2)
}
public CSG calibrationLink(double rotationCenterToBoltCenter,CSG bolt) {
CSG core= linkCore(rotationCenterToBoltCenter, bolt,numbers.LooseTolerance)
double defaultValue = numbers.LinkLength - endOfPassiveLinkToBolt
CSG stl= Vitamins.get(ScriptingEngine.fileFromGit(
"https://github.com/OperationSmallKat/Marcos.git",
"DriveLink.stl"))
double chamfer = numbers.Chamfer2
double smallChamfer = numbers.Chamfer1/1.5
double linkWidth = numbers.LinkWidth
double linkRadius = linkWidth/2
double linkThickness = numbers.LinkHeight
double filletRad=numbers.Fillet3
double LinkMountingCutOutWidth=numbers.LinkMountingCutOutWidth
double blockx=rotationCenterToBoltCenter-numbers.LinkMountingCutOutLength-numbers.Tolerance+endOfPassiveLinkToBolt+filletRad
double ServoHornRad=(hornDiam+numbers.ServoHornHoleTolerance/2)/2.0
double ServoHornHeight =numbers.ServoHornHeight+numbers.LooseTolerance
double mountHeadRad =( numbers.MountingScrewHeadDiamter+numbers.LooseTolerance)/2.0
double mountRad=(numbers.MountingScrewDiamter+numbers.LooseTolerance)/2.0
double decritiveRad = numbers.ServoHornDiameter/4.0
double SetscrewLength = numbers.SetScrewLength
double SetscrewSize = numbers.SetScrewSize
double SquareNutWidth = numbers.SquareNutWidth + numbers.LooseTolerance
double SquareNutHeight = numbers.SquareNutHeight + numbers.LooseTolerance
double SquareNutCutOutHeight = linkThickness/2+SquareNutWidth/2
double LinkSqaureNutSpacing = numbers.LinkSqaureNutSpacing-3
//Solving for Angle of setscrew.
double hypot1 = Math.hypot(ServoHornRad + SetscrewLength + numbers.LooseTolerance, SetscrewSize/2)
double angle1 = Math.asin(linkRadius/hypot1)
double angle2 = Math.asin((ServoHornRad + SetscrewLength + numbers.LooseTolerance)/hypot1)
double angle3 = (Math.PI/2)-angle1
double angle4 = (Math.PI/2)-angle2
double SetScrewAngle = Math.toDegrees((Math.PI/2)-(angle3+angle4))
double SetScrewChamferLength = linkRadius/Math.sin((Math.PI/2)-(angle3+angle4))
double SetScrewCutOutLength = numbers.LinkLength/Math.cos((Math.PI/2)-(angle3+angle4))
println(SetScrewChamferLength)
println(SetScrewCutOutLength)
CSG screwHole = new Cylinder(4.2/2.0, core.getTotalZ()).toCSG()
CSG ServoHornCutoutChamfer = ChamferedCylinder(ServoHornRad+smallChamfer,ServoHornHeight+smallChamfer,smallChamfer)
.toZMax()
.movez(smallChamfer)
// Idle pin cutout
CSG ServoHornCutout = ChamferedCylinder(ServoHornRad,ServoHornHeight,smallChamfer)
//.movez(-smallChamfer)
.union(ServoHornCutoutChamfer)
.union(screwHole)
double distanceOfSquareNut = (LinkSqaureNutSpacing+linkRadius)-(SquareNutHeight/2)
CSG SquareNutCutOut = new Cube(SquareNutHeight,SquareNutWidth, SquareNutCutOutHeight).toCSG()
.toZMin()
.movex(distanceOfSquareNut)
CSG SquareNutChamfer = StraightChamfer(SquareNutHeight,SquareNutWidth,smallChamfer)
.movex(distanceOfSquareNut)
CSG SetScrewCutOut = new Cylinder(SetscrewSize/2, SetScrewCutOutLength).toCSG()
.toZMin()
.roty(-90)
.movez(linkThickness/2)
//Chamfer for set screw
CSG cutout1 = new Cylinder((SetscrewSize)/2, SetScrewCutOutLength).toCSG()
.toZMax()
.roty(90)
.movez(linkThickness/2)
.rotz(SetScrewAngle)
CSG cutout2 = new Cylinder((SetscrewSize)/2+chamfer, SetScrewCutOutLength/2).toCSG()
.toZMax()
.roty(90)
.movez(linkThickness/2)
.movex(linkRadius)
.rotz(SetScrewAngle)
CSG Flatwall = new Cube(numbers.LinkLength,linkWidth,linkThickness).toCSG()
.toZMax()
.movez(linkThickness)
.movex(numbers.LinkLength/2)
CSG Flatwall2 = new Cube(numbers.LinkLength,linkWidth,linkThickness).toCSG()
.toZMax()
.movez(linkThickness)
.movex(numbers.LinkLength/2)
.movey(chamfer)
CSG Flatwall3 = new Cube(numbers.LinkLength,linkWidth,linkThickness).toCSG()
.toZMax()
.movez(linkThickness)
.movex(numbers.LinkLength/2)
.movey(-linkWidth)
.movey(-chamfer)
CSG p1 = ((Flatwall.intersect(cutout1)).difference(Flatwall2))
CSG p2 = (cutout2.difference(Flatwall).difference(Flatwall3))
CSG SetScrewChamferleft = p2.union(p1).hull()
CSG SetScrewChamferright = SetScrewChamferleft.mirrory()
// Assemble the whole link
CSG link = core
.difference(ServoHornCutout)
.difference(SquareNutCutOut.rotz(SetScrewAngle))
.difference(SquareNutCutOut.rotz(-SetScrewAngle))
.difference(SetScrewCutOut.rotz(SetScrewAngle))
.difference(SetScrewCutOut.rotz(-SetScrewAngle))
.difference(SquareNutChamfer.rotz(SetScrewAngle))
.difference(SetScrewChamferleft)
.difference(SetScrewChamferright)
//link.setIsWireFrame(true)
link.setColor(Color.DARKRED)
return link//.union(stl)
//return stl
}
public CSG linkCore(double rotationCenterToBoltCenter,CSG bolt,double tollerence) {
double defaultValue = numbers.LinkLength - endOfPassiveLinkToBolt
double chamfer = numbers.Chamfer2
double smallChamfer = numbers.Chamfer1
double linkWidth = numbers.LinkWidth
double linkThickness = numbers.LinkHeight
double filletRad=numbers.Fillet3
double LinkMountingCutOutWidth=numbers.LinkMountingCutOutWidth
double blockx=rotationCenterToBoltCenter-numbers.LinkMountingCutOutLength-numbers.Tolerance+endOfPassiveLinkToBolt+filletRad
double IdlePinRad=(numbers.IdlePinDiamter+tollerence)/2.0
double idlePinHeight =numbers.IdlePinThickness+tollerence
double mountHeadRad =( numbers.MountingScrewHeadDiamter+tollerence)/2.0
double mountRad=( numbers.MountingScrewDiamter+tollerence)/2.0
double decritiveRad = numbers.ServoHornDiameter/4.0
double zipTieLugDepth = 4
double zipTieWidth=3
double zipTieLugDIstanceFromEnd = 3.7
double zipTieClerence =1.2
double zipTieLugX=rotationCenterToBoltCenter-endOfPassiveLinkToBolt-zipTieLugDIstanceFromEnd
// Hull together a toolshape to make the cutter to make the shape appropratly
CSG cornerFilletCutter = new Cylinder(filletRad, linkThickness, 30).toCSG()
// cut from the corner to the ege of the link
cornerFilletCutter=cornerFilletCutter.union(cornerFilletCutter.movey(LinkMountingCutOutWidth)).hull()
// cut from the corner to the end of where the fillet should end
cornerFilletCutter=cornerFilletCutter.union(cornerFilletCutter.movex(chamfer)).hull()
CSG leftCorner = cornerFilletCutter.movex(blockx).movey(linkWidth/2-LinkMountingCutOutWidth+filletRad)
CSG rightCorner = cornerFilletCutter.movex(blockx).movey(-linkWidth/2-filletRad)
CSG lowerEnd = ChamferedCylinder(linkWidth/2, linkThickness, chamfer)
CSG linkBlock = new ChamferedCube(blockx+chamfer, linkWidth, linkThickness, chamfer).toCSG()
.toZMin()
.toXMin()
// Trim the end chamfer off the end of the link block to make the end flat
linkBlock=linkBlock.intersect(linkBlock.getBoundingBox().movex(-chamfer))
// Use chamferd cylendars to make the lug at the end of the link
CSG mountLug = ChamferedRoundCornerLug(blockx, linkWidth-(LinkMountingCutOutWidth*2),filletRad, linkThickness+chamfer, chamfer)
.toZMin()
.toXMax()
// Make a champfered cylendar to make the inner chamfer radius'
CSG LowerInnerCornerChamferCutLeft= ChamferedCylinder(filletRad+chamfer, chamfer*2+1, chamfer)
.movex(blockx)
.movey(linkWidth/2-LinkMountingCutOutWidth+filletRad)
.toZMax()
.movez(chamfer)
LowerInnerCornerChamferCutLeft=LowerInnerCornerChamferCutLeft.union(LowerInnerCornerChamferCutLeft.movey(LinkMountingCutOutWidth)).hull()
CSG LowerInnerCornerChamferCutRight = LowerInnerCornerChamferCutLeft.movey(-linkWidth)
// trim off the top chamfers and mofe the block end to the tip of the link block
mountLug=mountLug.difference(mountLug.getBoundingBox().movez(linkThickness))
.movex(rotationCenterToBoltCenter+endOfPassiveLinkToBolt)
CSG MountHeadHoleCutoutChamfer = ChamferedCylinder(mountHeadRad+smallChamfer,linkThickness+smallChamfer,smallChamfer)
.toZMin()
.movez(linkThickness-smallChamfer)
CSG MountHoleCutoutChamfer = ChamferedCylinder(mountRad+smallChamfer,linkThickness+smallChamfer,smallChamfer)
.toZMax()
.movez(smallChamfer)
CSG mountAssebmbly = MountHoleCutoutChamfer
//.union(MountHeadHoleCutoutChamfer)
.movex(rotationCenterToBoltCenter)
if(bolt!=null) {
CSG boltHole = bolt.toZMax()
.movez(linkThickness)
mountAssebmbly=mountAssebmbly
.union(boltHole)
}
CSG decritiveDivit = ChamferedCylinder(decritiveRad+chamfer,chamfer*2+1,chamfer)
.movez(linkThickness-chamfer)
CSG decoration = decorationGen(rotationCenterToBoltCenter)
// Assemble the whole link
CSG link = lowerEnd
.union(linkBlock)
.hull()
.union(mountLug)
.difference(leftCorner)
.difference(rightCorner)
.difference(LowerInnerCornerChamferCutRight)
.difference(LowerInnerCornerChamferCutLeft)
.difference(decritiveDivit)
.difference(decoration)
if(bolt!=null)
link=link.difference(mountAssebmbly)
//link.setIsWireFrame(true)
link.setColor(Color.DARKRED)
return link//.union(stl)
}
public CSG passiveLink(double rotationCenterToBoltCenter,CSG bolt) {
CSG core= linkCore(rotationCenterToBoltCenter, bolt,numbers.LooseTolerance)
double defaultValue = numbers.LinkLength - endOfPassiveLinkToBolt
CSG stl= Vitamins.get(ScriptingEngine.fileFromGit(
"https://github.com/OperationSmallKat/Marcos.git",
"IdleLinkLeg.stl"))
double chamfer = numbers.Chamfer2
double smallChamfer = numbers.Chamfer1
double linkWidth = numbers.LinkWidth
double linkThickness = numbers.LinkHeight
double filletRad=numbers.Fillet3
double LinkMountingCutOutWidth=numbers.LinkMountingCutOutWidth
double blockx=rotationCenterToBoltCenter-numbers.LinkMountingCutOutLength-numbers.Tolerance+endOfPassiveLinkToBolt+filletRad
double IdlePinRad=(numbers.IdlePinDiamter+numbers.LooseTolerance)/2.0
double idlePinHeight =numbers.IdlePinThickness+numbers.LooseTolerance
double mountHeadRad =( numbers.MountingScrewHeadDiamter+numbers.LooseTolerance)/2.0
double mountRad=( numbers.MountingScrewDiamter+numbers.LooseTolerance)/2.0
double decritiveRad = numbers.ServoHornDiameter/4.0
double zipTieLugDepth = 4
double zipTieWidth=3
double zipTieLugDIstanceFromEnd = 3.7
double zipTieClerence =1.2
double zipTieLugX=rotationCenterToBoltCenter-endOfPassiveLinkToBolt-zipTieLugDIstanceFromEnd
CSG IdlePinCutoutChamfer = ChamferedCylinder(IdlePinRad+smallChamfer,idlePinHeight+smallChamfer,smallChamfer)
.toZMax()
.movez(smallChamfer)
// Idle pin cutout
CSG IdlePinCutout = ChamferedCylinder(IdlePinRad,idlePinHeight,smallChamfer)
//.movez(-smallChamfer)
.union(IdlePinCutoutChamfer)
CSG zipLug = new RoundedCube(zipTieWidth+chamfer*2,zipTieLugDepth-zipTieClerence,linkThickness-(zipTieClerence*2))
.cornerRadius(chamfer)
.toCSG()
.toZMin()
.toXMax()
.toYMax()
.movex(chamfer)
.movez(zipTieClerence)
CSG zipTieCut = new Cube(zipTieWidth,zipTieLugDepth,linkThickness).toCSG()
.toZMin()
.toXMax()
.toYMax()
.difference(zipLug)
CSG bottomChamfer = new ChamferedCube(zipTieWidth+smallChamfer*2,zipTieLugDepth+smallChamfer*2,linkThickness,smallChamfer).toCSG()
.toZMax()
.toXMax()
.toYMax()
.movez(smallChamfer)
.movex(smallChamfer)
.movey(smallChamfer)
zipTieCut=zipTieCut.union(bottomChamfer)
zipTieCut=zipTieCut.movey(linkWidth/2)
.movex(zipTieLugX)
CSG rightZipTie=zipTieCut.mirrory()
// Assemble the whole link
CSG link = core
.difference(IdlePinCutout)
.difference(zipTieCut)
.difference(rightZipTie)
//link.setIsWireFrame(true)
link.setColor(Color.DARKRED)
return link//.union(stl)
}
CSG decorationGen(double rotationCenterToBoltCenter) {
double backOffset = 4
double chamfer = numbers.Chamfer2
double x=rotationCenterToBoltCenter+chamfer-numbers.LinkDetailSize/2-backOffset-endOfPassiveLinkToBolt-0.5
double y=numbers.LinkWidth-numbers.LinkDetailSize*2+chamfer*2
double filletRad=numbers.Fillet3
CSG smallCut=ChamferedCylinder((numbers.LinkWidth-numbers.LinkDetailSize*2)/2, chamfer*2+1, chamfer)
.toZMax()
.movez(chamfer)
CSG largeCut=ChamferedCylinder(numbers.LinkWidth/2, chamfer*2+1, chamfer)
.toZMax()
.movez(chamfer)
.movex(rotationCenterToBoltCenter)
CSG lug = ChamferedRoundCornerLug(x,y,filletRad,chamfer*2+1,chamfer)
.toXMin()
.movex(-chamfer+backOffset)
.difference(largeCut)
.difference(smallCut)
.movez(numbers.LinkHeight-chamfer)
return lug
}
def getGearLink() {
if(cachedGearLink==null) {
// generate the link
double gearDiameter = 27.65
cachedGearLink= Vitamins.get(ScriptingEngine.fileFromGit(
"https://github.com/OperationSmallKat/Marcos.git",
"DriveGear.stl"))
.moveToCenterX()
.moveToCenterY()
.rotz(180)
.movez(0.15)
double ServoHornRad=(6.96+0.2)/2.0
double ServoHornDepth=5.15
double squareNutDepth = 2+ServoHornRad
double setScrewRadius = 3.3/2.0
double smallChamfer = numbers.Chamfer1
CSG stl = cachedGearLink
double setScrewLen = gearDiameter/2;
double lowerSectionHeight =Math.abs(stl.getMinZ())
double previousOffset = offset.getMM()
double nutDepth = -lowerSectionHeight+ServoHornDepth/2
offset.setMM(0.2);
CSG nutStart = Vitamins.get("squareNut", "M3")
.roty(-90)
offset.setMM(previousOffset);
CSG nutChamfer = new ChamferedCube(nutStart.getTotalX()+smallChamfer,
nutStart.getTotalY()+smallChamfer,
3*smallChamfer, smallChamfer).toCSG()
.toZMax()
.movex(nutStart.getTotalX()/2)
.movez(-lowerSectionHeight+smallChamfer)
CSG squareNut = nutStart
.movez(nutDepth)
.union(nutChamfer)
.movex(squareNutDepth)
CSG fill = ChamferedCylinder(setScrewLen, lowerSectionHeight+smallChamfer,smallChamfer)
.toZMax()
.movez(smallChamfer)
fill=fill.difference(fill.getBoundingBox().toZMin())
CSG setScrewChamfer = ChamferedCylinder(setScrewRadius+smallChamfer, 3*smallChamfer,smallChamfer)
.movez(setScrewLen-smallChamfer)
CSG setScrew = new Cylinder(setScrewRadius, setScrewLen).toCSG()
.union(setScrewChamfer)
.roty(-90)
.movez(-lowerSectionHeight+ServoHornDepth/2)
CSG ServoHornCutoutChamfer = ChamferedCylinder(ServoHornRad+smallChamfer,3*smallChamfer,smallChamfer)
.toZMax()
.movez(smallChamfer)
// Idle pin cutout
CSG ServoHornCutout = ChamferedCylinder(ServoHornRad,ServoHornDepth,smallChamfer)
.union(ServoHornCutoutChamfer)
.movez(-lowerSectionHeight)
CSG asm= fill.difference(setScrew)
.difference(setScrew.rotz(-90))
.difference(ServoHornCutout)
.difference(squareNut)
.difference(squareNut.rotz(-90))
//return [stl, asm]
//println "Cutting the bottom off the existing gear"
CSG cutGear = stl.difference(stl.getBoundingBox().toZMax())
//println "Adding lower Section Back On"
cachedGearLink=cutGear.union(asm)
}
cachedGearLink.setColor(Color.RED)
return cachedGearLink
}
CSG getGearLinkKeepaway() {
CSG gl = getGearLink() ;
CSG toCSGMovez = new Cylinder(gl.getTotalX()/2, gl.getTotalZ(),(int)40).toCSG().movez(gl.getMinZ())
toCSGMovez.setIsWireFrame(true);
return toCSGMovez
}
double getDistanceFromCenterToMotorTop(DHParameterKinematics d, int linkIndex) {
// read motor typ information out of the link configuration
LinkConfiguration conf = d.getLinkConfiguration(linkIndex);
CSG motor = Vitamins.get(conf.getElectroMechanicalType(),conf.getElectroMechanicalSize())
.toZMax()
.movez(numbers.JointSpacing/2.0+numbers.LooseTolerance)
// Is this value actually something in the CSV?
return motor.getMaxZ()-numbers.LooseTolerance;
}
@Override
public ArrayList<CSG> generateCad(DHParameterKinematics d, int linkIndex) {
if(d.getScriptingName().startsWith("Head")||d.getScriptingName().startsWith("Tail")) {
return generateCadHeadTail(d, linkIndex)
}
AbstractLink link =d.getAbstractLink(linkIndex)
// chaeck to see if this is the left side
boolean left=false;
boolean front=false;
boolean isDummyGearWrist = false;
double parametric = numbers.LinkLength-endOfPassiveLinkToBolt
double l0offset =38.0-(numbers.LinkLength-endOfPassiveLinkToBolt)
double l1offset = 55.0 -(numbers.LinkLength-endOfPassiveLinkToBolt)
if(linkIndex==0) {
parametric=d.getDH_R(linkIndex)-l0offset
}
if(linkIndex==1) {
parametric=d.getDH_R(linkIndex)-l1offset
}
if(d.getScriptingName().startsWith("Dummy")) {
isDummyGearWrist=true;
}
if(d.getRobotToFiducialTransform().getY()>0) {
left=true;
}
if(d.getRobotToFiducialTransform().getX()>0) {
front=true;
}
// read motor typ information out of the link configuration
LinkConfiguration conf = d.getLinkConfiguration(linkIndex);
// load the vitamin for the servo
tailLength.setMM(0.1);
CSG motor = Vitamins.get(conf.getElectroMechanicalType(),conf.getElectroMechanicalSize())
.toZMax()
.movez(numbers.JointSpacing/2.0+numbers.LooseTolerance)
// Is this value actually something in the CSV?
double distanceToMotorTop = getDistanceFromCenterToMotorTop(d,linkIndex);
println "Center to horn distance "+distanceToMotorTop
// a list of CSG objects to be rendered
ArrayList<CSG> back =[]
// get the UI manipulator for the link
Affine dGetLinkObjectManipulator = d.getLinkObjectManipulator(linkIndex)
// UI manipulator for the root of the limb
Affine root = d.getRootListener()
double link1Rotz=-90
double MototRetractDist =15
String motorKey = "Motor"+d.getScriptingName()+":"+linkIndex
String leftMotorScrewKey = "LeftMotorScrew"+d.getScriptingName()+":"+linkIndex
String rightMotorScrewKey = "RightMotorScrew"+d.getScriptingName()+":"+linkIndex
String leftLinkScrewKey = "LeftLinkScrew"+d.getScriptingName()+":"+linkIndex
String rightLinkScrewKey = "RightLinkScrew"+d.getScriptingName()+":"+linkIndex
String leftLinkNutKey = "LeftLinkNut"+d.getScriptingName()+":"+linkIndex
String rightLinkNutKey = "RightLinkNut"+d.getScriptingName()+":"+linkIndex
String leftCalibrationNutKey = "LeftCalibrationNut"+d.getScriptingName()+":"+linkIndex
String rightCalibrationNutKey = "RightCalibrationNut"+d.getScriptingName()+":"+linkIndex
String leftCalibrationScrewKey = "LeftCalibrationScrew"+d.getScriptingName()+":"+linkIndex
String rightCalibrationScrewKey = "RightCalibrationScrew"+d.getScriptingName()+":"+linkIndex
String motorDoorScrewKey = "MotorDoorScrew"+d.getScriptingName()+":"+linkIndex
String leftmotorDoorScrewKey = "LeftMotorDoorScrew"+d.getScriptingName()+":"+linkIndex
String rightmotorDoorScrewKey = "RightMotorDoorScrew"+d.getScriptingName()+":"+linkIndex
new VitaminLocation(false,motorKey,conf.getElectroMechanicalType(),conf.getElectroMechanicalSize(),new TransformNR(),link)
new VitaminLocation(false,leftMotorScrewKey,"PhillipsRoundedHeadThreadFormingScrews","M2x8",new TransformNR(),link)
new VitaminLocation(false,rightMotorScrewKey,"PhillipsRoundedHeadThreadFormingScrews","M2x8",new TransformNR(),link)
new VitaminLocation(false,leftLinkNutKey,"squareNut","M3",new TransformNR(),link)
new VitaminLocation(false,rightLinkNutKey,"squareNut","M3",new TransformNR(),link)
new VitaminLocation(false,leftCalibrationNutKey,"squareNut","M3",new TransformNR(),link)
new VitaminLocation(false,rightCalibrationNutKey,"squareNut","M3",new TransformNR(),link)
new VitaminLocation(false,leftCalibrationScrewKey,"conePointSetScrew","M3x8",new TransformNR(),link)
new VitaminLocation(false,rightCalibrationScrewKey,"conePointSetScrew","M3x8",new TransformNR(),link)
LengthParameter facets = new LengthParameter("Bolt Hole Facet Count",10,[40, 10])
facets.setMM(30)
offset.setMM(numbers.LooseTolerance)
if(linkIndex==0) {
new VitaminLocation(false,leftmotorDoorScrewKey,"PhillipsRoundedHeadThreadFormingScrews","M2x8",new TransformNR(),link)
new VitaminLocation(false,rightmotorDoorScrewKey,"PhillipsRoundedHeadThreadFormingScrews","M2x8",new TransformNR(),link)
motor=motor.rotz(left?180:0)
motor=motor.roty(front?180:0)
// the first link motor is located in the body
motor.setManipulator(root)
// pull the limb servos out the top
motor.addAssemblyStep(4, new Transform().movex(isDummyGearWrist?-30:MototRetractDist))
motor.addAssemblyStep(3, new Transform().movey(isDummyGearWrist?-30:left?-MototRetractDist*4:MototRetractDist*4))
}else {
new VitaminLocation(false,motorDoorScrewKey,"PhillipsRoundedHeadThreadFormingScrews","M2x8",new TransformNR(),link)
motor=motor.roty(left?180:0)
motor=motor.rotz(linkIndex==2?90:90+link1Rotz)
if(linkIndex==1) {
motor=motor.mirrory()
}
// the rest of the motors are located in the preior link's kinematic frame
motor.setManipulator(d.getLinkObjectManipulator(linkIndex-1))
// pull the link motors out the thin side
motor.addAssemblyStep(6, new Transform().movey(linkIndex==1?MototRetractDist*2:0).movey(linkIndex==2?-MototRetractDist*2:0))
motor.addAssemblyStep(7, new Transform().movex(linkIndex==1?MototRetractDist*2:0).movey(linkIndex==2?-MototRetractDist*2:0))
//motor.addAssemblyStep(8, new Transform().movex(-30))
}
// do not export the motors to STL for manufacturing
motor.setManufacturing({return null})
motor.setColor(Color.BLUE)
//Start the horn link
// move the horn from tip of the link space, to the Motor of the last link space
// note the hore is moved to the centerline distance value before the transform to link space
CSG movedHorn = resinPrintServoMount.movez(distanceToMotorTop)
if(linkIndex==0)
movedHorn=movedHorn.roty(front?180:0)
else
movedHorn=movedHorn.roty(left?180:0)
CSG myServoHorn = moveDHValues(movedHorn,d,linkIndex)
if(!isDummyGearWrist) {
if(linkIndex==0)
myServoHorn.addAssemblyStep(9, new Transform().movey(front?10:-10))
else
myServoHorn.addAssemblyStep(9, new Transform().movez(left?-10:10))
}else {
myServoHorn.addAssemblyStep(4, new Transform().movex(isDummyGearWrist?-30:30))
}
//reorent the horn for resin printing
myServoHorn.setManufacturing({incoming ->
return null;//reverseDHValues(incoming, d, linkIndex).roty(linkIndex==0?(front?180:0):(left?180:0)).toZMin()
//.roty(45)
//.movez(5)
})
//myServoHorn.getStorage().set("bedType", "resin")
//myServoHorn.setPrintBedNumber(4)
//myServoHorn.setName("Resin Horn "+linkIndex+" "+d.getScriptingName())
// attach this links manipulator
myServoHorn.setManipulator(dGetLinkObjectManipulator)
back.add(myServoHorn)
//end horn link
if(isDummyGearWrist) {
motor.addAssemblyStep(3, new Transform().movez(front?60:-60))
myServoHorn.addAssemblyStep(3, new Transform().movey(front?-50:50))
CSG tmp = getGearLink()
.roty(front?180:0)
if(front)
tmp=tmp.toZMax()
else
tmp=tmp.toZMin()
distanceToMotorTop+=1.5
tmp=tmp.movez((front?-1:1)*distanceToMotorTop)
CSG wrist= moveDHValues(tmp, d, linkIndex)
wrist.addAssemblyStep(4, new Transform().movex(isDummyGearWrist?-30:30))
wrist.addAssemblyStep(3, new Transform().movey(front?-20:20))
//.rotx(90)
wrist.setName("DriveGear"+d.getScriptingName())
wrist.setManufacturing({ incoming ->
return incoming.rotx(front?-90:90).toZMin().toXMin().toYMin()
})
wrist.getStorage().set("bedType", "ff-One")
wrist.setPrintBedNumber(1)
wrist.setManipulator(d.getLinkObjectManipulator(linkIndex))
back.add(wrist)
}else {
double coverDistance=80
if(linkIndex==1) {
// this section is a place holder to visualize the tip of the limb
CSG kneeCover = Vitamins.get(ScriptingEngine.fileFromGit(
"https://github.com/OperationSmallKat/Marcos.git",
"ShoulderCover.stl"))
.rotz(link1Rotz)
if(left)
kneeCover=kneeCover.mirrorz()
kneeCover=kneeCover.mirrory()
kneeCover.setManipulator(d.getLinkObjectManipulator(linkIndex-1))
kneeCover.setManufacturing({incoming->
return incoming.rotx(-90).toZMin().roty(90).toZMin()
})
kneeCover.getStorage().set("bedType", "ff-Two")
kneeCover.setPrintBedNumber(left?2:5)
kneeCover.setName("ShoulderCover"+d.getScriptingName())
kneeCover.addAssemblyStep(12, new Transform().movex(10))
kneeCover.addAssemblyStep(11, new Transform().movez(left?-coverDistance:coverDistance))
back.add(kneeCover)
CSG knee = Vitamins.get(ScriptingEngine.fileFromGit(
"https://github.com/OperationSmallKat/Marcos.git",
"Shoulder.stl"))
.rotz(link1Rotz)
if(left)
knee=knee.mirrorz()
knee=knee.mirrory()
knee.setManipulator(d.getLinkObjectManipulator(linkIndex-1))
knee.setManufacturing({incoming->
return incoming.rotx(-90).roty(-90).toZMin()
})
knee.getStorage().set("bedType", "ff-Two")
knee.setPrintBedNumber(2)
knee.setName("Shoulder"+d.getScriptingName())
back.add(knee)
}
if(linkIndex==2) {
// this section is a place holder to visualize the tip of the limb
CSG kneeCover = Vitamins.get(ScriptingEngine.fileFromGit(
"https://github.com/OperationSmallKat/Marcos.git",
"KneeCover.stl"))
.rotx(180)
if(!left)
kneeCover=kneeCover.mirrorz()
kneeCover.setManipulator(d.getLinkObjectManipulator(linkIndex-1))
kneeCover.setManufacturing({incoming->
return incoming.rotx(180).rotx(-90).toZMin()
})
kneeCover.getStorage().set("bedType", "ff-One")
kneeCover.setPrintBedNumber(1)
kneeCover.setName("KneeCover"+d.getScriptingName())
kneeCover.addAssemblyStep(12, new Transform().movey(-10))
kneeCover.addAssemblyStep(11, new Transform().movez(left?-coverDistance:coverDistance))
back.add(kneeCover)
CSG knee = Vitamins.get(ScriptingEngine.fileFromGit(
"https://github.com/OperationSmallKat/Marcos.git",
"Knee"+(left?"Left":"Right")+".stl"))
.rotx(180)
knee.setManipulator(d.getLinkObjectManipulator(linkIndex-1))
knee.setManufacturing({incoming->
return incoming.rotx(-180).rotx(-90).toZMin().rotz(left?180:0)
})
knee.getStorage().set("bedType", "ff-One")
knee.setPrintBedNumber(1)
knee.setName("Knee"+d.getScriptingName())
back.add(knee)
CSG foot = getFoot(d.getDH_R(linkIndex))
foot.setManipulator(dGetLinkObjectManipulator)
foot.setManufacturing({incoming->
return incoming.rotx(90).roty(90-numbers.FootAngle).toZMin().rotz(front?180:0)
})
foot.getStorage().set("bedType", "ff-Two")
foot.setPrintBedNumber(3)
foot.setName("Foot"+d.getScriptingName())
back.add(foot)
}
double zrotValDrive = -d.getDH_Theta(linkIndex)
if(linkIndex==1) {
zrotValDrive+=45
}
if(linkIndex==2) {
zrotValDrive+=(-90+numbers.FootAngle)+1
}
double zrotVal = -d.getDH_Theta(linkIndex)
if(linkIndex==1) {
zrotVal+=45
}
if(linkIndex==2) {
zrotVal+=(-90+numbers.FootAngle)
}
VitaminLocation vLLS=new VitaminLocation(false,leftLinkScrewKey,"chamferedScrew","M3x16",new TransformNR().translateX(parametric),link)
VitaminLocation vRLS=new VitaminLocation(false,rightLinkScrewKey,"chamferedScrew","M3x16",new TransformNR().translateX(parametric),link)
CSG boltlStart = MobileBaseCadManager.get(link).getVitamin(vLLS)
CSG boltrStart = MobileBaseCadManager.get(link).getVitamin(vRLS)
CSG boltl= moveDHValues(boltlStart
.rotx(180)
.toZMin()
.movez(-(distanceToMotorTop+numbers.LinkHeight))
.rotz(zrotVal)
,d,linkIndex)
CSG boltr= moveDHValues(boltrStart
.rotx(0)
.toZMax()
.movez((distanceToMotorTop+numbers.LinkHeight))
.rotz(zrotVal)
,d,linkIndex)
boltl.setManipulator(dGetLinkObjectManipulator)
boltr.setManipulator(dGetLinkObjectManipulator)
boltl.setManufacturing({return null})
boltr.setManufacturing({return null})
CSG movedDrive = calibrationLink(parametric,boltlStart)
.movez(distanceToMotorTop)//.rotz(180)
double xrotDrive=180
xrotDrive+=linkIndex==0&&(!front)?180:0
xrotDrive+=linkIndex!=0&&(!left)?180:0
movedDrive=movedDrive.rotx(xrotDrive)
movedDrive=movedDrive.rotz(zrotValDrive)
CSG myDriveLink = moveDHValues(movedDrive,d,linkIndex)
back.addAll([boltr, boltl])
if(linkIndex==0) {
boltl.addAssemblyStep(10, new Transform().movey(25))
myDriveLink.addAssemblyStep(9, new Transform().movey(front?20:-20))
}else {
boltl.addAssemblyStep(10, new Transform().movez(-25))
myDriveLink.addAssemblyStep(9, new Transform().movez(left?-20:20))
}
//reorent the horn for resin printing
myDriveLink.setManufacturing({incoming ->
return reverseDHValues(incoming.rotz(-zrotValDrive).rotx(-xrotDrive), d, linkIndex).toZMin()
})
myDriveLink.getStorage().set("bedType", "ff-Two")
myDriveLink.setPrintBedNumber(2)
myDriveLink.setName("DriveLink "+linkIndex+" "+d.getScriptingName())
// attach this links manipulator
myDriveLink.setManipulator(dGetLinkObjectManipulator)
back.add(myDriveLink)
double kinematicsLen = d.getDH_R(linkIndex)
double staticOffset = 55.500-numbers.LinkLength-endOfPassiveLinkToBolt
double calculated = kinematicsLen-staticOffset
double xrot=0
CSG linkCSG = passiveLink(parametric,boltrStart)
.movez(distanceToMotorTop)
xrot+=linkIndex==0&&(!front)?180:0
xrot+=linkIndex!=0&&(!left)?180:0
linkCSG=linkCSG.rotx(xrot)
linkCSG=linkCSG.rotz(zrotVal)
CSG wrist= moveDHValues(linkCSG, d, linkIndex)
if(linkIndex!=0) {
double dist = 25;
boltr.addAssemblyStep(10, new Transform().movez(dist))
wrist.addAssemblyStep(10, new Transform().movez(left?5:-5))
}else {
boltr.addAssemblyStep(10, new Transform().movey(-25))
wrist.addAssemblyStep(10, new Transform().movey(front?-5:5))
}
//.rotx(90)
wrist.setName("PassiveLink"+d.getScriptingName()+linkIndex)
wrist.setManufacturing({ incoming ->