separate dimensions from form
[challenge-bot] / 3d-printables / wheel.scad
index 0a922fd6c302dbfdb1a2ca7fefdbe7c05324a8be..a37008333ae1207805cfa88ead7d60b11277d41e 100644 (file)
 //  100 will make printing smooth
 $fn = 100;
 
+include <wheel-dimensions.scad>
 use <qr.scad>
 
-qr_size = 54;
-qr_height = 2;
+module mounting_screw_flat() {
+  circle(0.9); }
 
-wall_width = 3;
-
-wheel_width = 6;
-wheel_radius = sqrt(2 * pow(qr_size / 2, 2)) + wall_width / 2;
-
-motor_shaft_radius = 3.7;
-motor_shaft_flat_width = 4.8;
-
-module mounting_screw_flat(){
-  square(2, center = true);}
-
-module motor_shaft_flat(radius, flat_width){
-  intersection(){
+module motor_shaft_flat(radius, flat_width) {
+  intersection() {
     circle(radius);
-    square([flat_width, radius * 2], center = true);}}
+    square([flat_width, radius * 2], center = true); } }
 
 module motor_shaft(radius,
                    flat_width,
-                   shaft_length){
-  linear_extrude(height = shaft_length){
-    motor_shaft_flat(radius, flat_width);}}
+                   shaft_length) {
+  linear_extrude(height = shaft_length) {
+    motor_shaft_flat(radius, flat_width); } }
 
-module rim(radius, wall_width, wheel_width){
-  linear_extrude(height = wheel_width){
-    difference(){
+module rim(radius, wall_width, wheel_width) {
+  linear_extrude(height = wheel_width) {
+    difference() {
       circle(radius);
-      circle(radius - wall_width);}}}
+      circle(radius - wall_width); } } }
 
-module motor_shaft_holder_flat(radius, flat_width, wall_width){
-  difference(){
+module motor_shaft_holder_flat(radius, flat_width, wall_width) {
+  difference() {
     motor_shaft_flat(radius + wall_width,
                      flat_width + wall_width);
-    motor_shaft_flat(radius, flat_width);}}
-
-module motor_shaft_holder(radius, flat_width, wall_width, height){
-  linear_extrude(height = height){
-    motor_shaft_holder_flat(radius, flat_width, wall_width);}}
-
-module wheel_black(radius, width, shaft_radius, shaft_flat_width, wall_width){
-  color("black"){
-    rim(radius, wall_width, width);
-    linear_extrude(height = qr_height){
-      difference(){
+    motor_shaft_flat(radius, flat_width); } }
+
+module motor_shaft_holder(radius, flat_width, wall_width, height) {
+  linear_extrude(height = height) {
+    motor_shaft_holder_flat(radius, flat_width, wall_width); } }
+
+module tread(wheel_radius, tread_radius) {
+  rotate_extrude(convexity = 10) {
+    translate([wheel_radius, 0]) {
+      circle(tread_radius); } } }
+
+module wheel_black(radius,
+                   width,
+                   shaft_radius,
+                   shaft_flat_width,
+                   wall_width,
+                   tread_radius) {
+  color("black") {
+    difference() {
+      rim(radius, wall_width, width);
+      translate([0, 0, width / 2]) {
+        tread(radius, tread_radius); } }
+    linear_extrude(height = qr_height) {
+      difference() {
         qr_black_flat();
-        mounting_screw_flat();}}
-    translate([0, 0, qr_height]){
+        mounting_screw_flat(); } }
+    translate([0, 0, qr_height]) {
       motor_shaft_holder(shaft_radius,
                          shaft_flat_width,
                          wall_width,
-                         width - qr_height);}}}
+                         width - qr_height); } } }
 
-module wheel_white(){
-  color("white"){
-    linear_extrude(height = qr_height){
-      difference(){
+module wheel_white() {
+  color("white") {
+    linear_extrude(height = qr_height) {
+      difference() {
         qr_white_flat();
-        mounting_screw_flat();}}}}
-
-module wheel(radius, width, shaft_radius, shaft_flat_width, wall_width){
+        mounting_screw_flat(); } } } }
+
+module wheel(radius,
+             width,
+             shaft_radius,
+             shaft_flat_width,
+             wall_width,
+             tread_radius) {
   wheel_black(radius,
               width,
               shaft_radius,
               shaft_flat_width,
-              wall_width);
-  wheel_white();}
-
+              wall_width,
+              tread_radius);
+  wheel_white(); }
+
+module wheel_solid(radius,
+                   width,
+                   shaft_radius,
+                   shaft_flat_width,
+                   wall_width,
+                   tread_radius) {
+  difference() {
+    rim(radius, wall_width * 2, width);
+    translate([0, 0, width / 2]) {
+      tread(radius, tread_radius); } }
+  linear_extrude(height = qr_height) {
+    difference() {
+      square(qr_size, center = true);
+      mounting_screw_flat(); } }
+  translate([0, 0, qr_height]) {
+    motor_shaft_holder(shaft_radius,
+                       shaft_flat_width,
+                       wall_width,
+                       width - qr_height); } }
+
+/*
 wheel(wheel_radius,
       wheel_width,
       motor_shaft_radius,
       motor_shaft_flat_width,
-      wall_width);
+      wall_width,
+      tread_radius);
+*/
+
+wheel_solid(wheel_radius,
+            wheel_width,
+            motor_shaft_radius,
+            motor_shaft_flat_width,
+            wall_width,
+            tread_radius);