separate data into *-data.scad for 3d models
[challenge-bot] / 3d-printables / wheel-data.scad
1 // challenge-bot
2 // GNU AGPLv3 (or later at your option)
3 // project available at these locations:
4 // https://gitorious.org/ozzloy/challenge-bot
5 // https://github.com/waynegramlich/challenge-bot
6
7 // use $fn = 20 while developing, 100 when about to print
8 // 20 will make previews fast
9 // 100 will make printing smooth
10 $fn = 100;
11
12 qr_size = 45;
13 qr_height = 2;
14
15 wall_width = 3;
16
17 wheel_width = 9;
18 wheel_radius = sqrt(2 * pow(qr_size / 2, 2)) + wall_width / 2;
19
20 motor_shaft_radius = 3.7;
21 motor_shaft_flat_width = 4.8;
22
23 tread_radius = 4 / 2;
24
25 module mounting_screw_flat() {
26 circle(0.9); }
27
28 module motor_shaft_flat(radius, flat_width) {
29 intersection() {
30 circle(radius);
31 square([flat_width, radius * 2], center = true); } }
32
33 module motor_shaft(radius,
34 flat_width,
35 shaft_length) {
36 linear_extrude(height = shaft_length) {
37 motor_shaft_flat(radius, flat_width); } }
38
39 module rim(radius, wall_width, wheel_width) {
40 linear_extrude(height = wheel_width) {
41 difference() {
42 circle(radius);
43 circle(radius - wall_width); } } }
44
45 module motor_shaft_holder_flat(radius, flat_width, wall_width) {
46 difference() {
47 motor_shaft_flat(radius + wall_width,
48 flat_width + wall_width);
49 motor_shaft_flat(radius, flat_width); } }
50
51 module motor_shaft_holder(radius, flat_width, wall_width, height) {
52 linear_extrude(height = height) {
53 motor_shaft_holder_flat(radius, flat_width, wall_width); } }
54
55 module tread(wheel_radius, tread_radius) {
56 rotate_extrude(convexity = 10) {
57 translate([wheel_radius, 0]) {
58 circle(tread_radius); } } }
59
60 module wheel_black(radius,
61 width,
62 shaft_radius,
63 shaft_flat_width,
64 wall_width,
65 tread_radius) {
66 color("black") {
67 difference() {
68 rim(radius, wall_width, width);
69 translate([0, 0, width / 2]) {
70 tread(radius, tread_radius); } }
71 linear_extrude(height = qr_height) {
72 difference() {
73 qr_black_flat();
74 mounting_screw_flat(); } }
75 translate([0, 0, qr_height]) {
76 motor_shaft_holder(shaft_radius,
77 shaft_flat_width,
78 wall_width,
79 width - qr_height); } } }
80
81 module wheel_white() {
82 color("white") {
83 linear_extrude(height = qr_height) {
84 difference() {
85 qr_white_flat();
86 mounting_screw_flat(); } } } }
87
88 module wheel(radius,
89 width,
90 shaft_radius,
91 shaft_flat_width,
92 wall_width,
93 tread_radius) {
94 wheel_black(radius,
95 width,
96 shaft_radius,
97 shaft_flat_width,
98 wall_width,
99 tread_radius);
100 wheel_white(); }
101
102 module wheel_solid(radius,
103 width,
104 shaft_radius,
105 shaft_flat_width,
106 wall_width,
107 tread_radius) {
108 difference() {
109 rim(radius, wall_width * 2, width);
110 translate([0, 0, width / 2]) {
111 tread(radius, tread_radius); } }
112 linear_extrude(height = qr_height) {
113 difference() {
114 square(qr_size, center = true);
115 mounting_screw_flat(); } }
116 translate([0, 0, qr_height]) {
117 motor_shaft_holder(shaft_radius,
118 shaft_flat_width,
119 wall_width,
120 width - qr_height); } }