clean up code to use abstraction
authordaniel watson <ozzloy@gmail.com>
Sun, 8 Sep 2013 01:20:01 +0000 (18:20 -0700)
committerdaniel watson <ozzloy@gmail.com>
Sun, 8 Sep 2013 01:20:19 +0000 (18:20 -0700)
schematic-3d-printable.scad

index 6b5831016210f4c83a8911972ff021fd9448a2a6..b78304afea86cb19e80013d699001acf77cd5988 100644 (file)
@@ -1,4 +1,4 @@
-// challenge-bot phase-2
+// challenge-bot
 // GNU AGPLv3 (or later at your option)
 // project available at these locations:
 // https://gitorious.org/ozzloy/challenge-bot
@@ -36,43 +36,40 @@ module wheel_mount_reinforcement(scale){
         translate([0, -(diagonal * 1.1 - deck_depth) / 2, 0])
           cube([diagonal * 2, diagonal * 2 * 1.1, deck_depth * 2] * scale);}}
 
+module wheel_motor_holes(scale){
+  translate([0.5, 0.938, -1/16] * scale) {
+    collar_hole(scale);}
+  translate([0.5 + 0.875 - 0.425, 0.938, -1/16] * scale){
+    nubbin_hole(scale);}
+  translate([0.5 + 1.213 - 0.425, 0.938 - 0.687/2, -1/16] * scale){
+    mounting_screw_hole(scale);}
+  translate([0.5 + 1.213 - 0.425, 0.938 + 0.687/2, -1/16] * scale){
+    mounting_screw_hole(scale);}}
+
 module wheel_mount(scale){
-  difference(){
-    cube([1.5, 2, 3/16] * scale);
-    // motor shaft collar hole
-    translate([0.5, 0.938, -1/16] * scale) {
-      collar_hole(scale);}
-    // nubbin hole
-    translate([0.5 + 0.875 - 0.425, 0.938, -1/16] * scale){
-      nubbin_hole(scale);}
-    // mounting screw hole
-    translate([0.5 + 1.213 - 0.425, 0.938 - 0.687/2, -1/16] * scale){
-      mounting_screw_hole(scale);}
-    translate([0.5 + 1.213 - 0.425, 0.938 + 0.687/2, -1/16] * scale){
-      mounting_screw_hole(scale);}}}
+  width = 1.5;
+  length = 2;
+  depth = deck_depth;
 
-translate([0, 0, (3/16)/2 * scale]){
-  color("blue") deck(scale);
-  rotate([90, 0, 0])
-    translate([1.5, (deck_depth)/2, -4] * scale) wheel_mount(scale);
-  rotate([90, 0, 0])
-    translate([1.5, (deck_depth)/2, 4 - deck_depth] * scale)
-      wheel_mount(scale);}
+  difference(){
+    cube([width, length, depth] * scale);
+    wheel_motor_holes(scale);}
+  translate([2 * depth, 2 * depth, depth] * scale)
+    rotate([0, 0, 180])
+      wheel_mount_reinforcement(scale);
+  translate([width, 2 * depth, depth] * scale)
+    rotate([0, 0, 180])
+      wheel_mount_reinforcement(scale);}
 
-translate([1.5, deck_length/2 - deck_depth * 3, deck_depth] * scale){
-  wheel_mount_reinforcement(scale);}
-translate([1.5 * 2 - deck_depth * 2,
-           deck_length / 2 - deck_depth * 3,
-           deck_depth]
-          * scale){
-  wheel_mount_reinforcement(scale);}
+module robot(scale){
+  translate([0, 0, (deck_depth)/2 * scale]){
+    color("blue") deck(scale);
+    translate([1.5, 4, (deck_depth)/2] * scale)
+      rotate([90, 0, 0])
+        wheel_mount(scale);
+    mirror([0, 1, 0])
+      translate([1.5, 4, (deck_depth)/2] * scale)
+        rotate([90, 0, 0])
+          wheel_mount(scale);}}
 
-translate([1.5 + deck_depth * 2,
-           3 * deck_depth - deck_length / 2,
-           deck_depth]
-          * scale){
-  rotate([0, 0, 180]){
-    wheel_mount_reinforcement(scale);}}
-translate([1.5 * 2, 3 * deck_depth - deck_length / 2, deck_depth] * scale){
-  rotate([0, 0, 180]){
-    wheel_mount_reinforcement(scale);}}
+robot(scale);