3d90aff0 |
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 | /* |
8 | this holds an hc-sr04 sonar sensor to a 3/16 inch deck. |
9 | http://fritzing.org/projects/hc-sr04-project |
10 | it can hold the sonar sensor either facing down, or forwards. |
11 | when facing down, it can detect if it passes over the edge of a table. |
12 | when facing forwards, it can detect and follow something in front of it. |
13 | */ |
14 | |
15 | $fn = 60; |
16 | |
17 | include <oshw-data.scad> |
18 | |
19 | // 3/16 inch in mm deck_depth = 4.7625; |
20 | // 1/4 inch in mm = 6.35 |
21 | // subtract a little to be a squeeze fit |
22 | deck_depth = 4.7625 - 0.4; |
23 | // sonar sensor measurements taken with calipers: |
24 | // 10.82 in between, 42.33 outside, 15.82 diameter |
25 | // measured diameter of 15.82 with calipers, |
26 | // but when printed ends up being too small, so add some |
27 | sonar_diameter = 15.82 + 0.4; |
28 | sonar_radius = sonar_diameter / 2; |
29 | sonar_height = 13.8; |
30 | between_sonar_centers = sonar_diameter + 10.82; |
31 | // the sonar cylinders are placed on the pcb at slightly different positions |
32 | // from one sensor to the next, so this allows for that variance. |
33 | between_sonar_centers_variance = 2; |
34 | // keep at least this much plastic surrounding the sonar cylinder on all sides |
35 | buffer = 3; |
36 | sonar_holder_length = buffer + between_sonar_centers + sonar_diameter + buffer; |
37 | sonar_holder_width = buffer + sonar_diameter + buffer; |
38 | // sonar_holder_depth is deck_depth minus a little bit to make arm fit |
39 | // into deck holder |
40 | sonar_holder_depth = deck_depth - 0.7875; |
41 | |
42 | deck_holder_length = sonar_holder_depth * 2 + deck_depth + 15; |
43 | module sonar_holder_2d() { |
44 | difference() { |
45 | square([sonar_holder_length, sonar_holder_width]); } } |
46 | |
47 | module sonars() { |
48 | translate([between_sonar_centers / 2, 0, 0]) { |
49 | cylinder(r = sonar_radius, h = sonar_height); } |
50 | // for the variance with which the physical sonar cylinders are placed |
51 | translate([between_sonar_centers / 2 - between_sonar_centers_variance, 0, 0]) { |
52 | cylinder(r = sonar_radius, h = sonar_height); |
53 | translate([0, -sonar_radius, 0]) { |
54 | cube([between_sonar_centers_variance, sonar_diameter, sonar_height]); } } |
55 | translate([-between_sonar_centers / 2, 0, 0]) { |
56 | cylinder(r = sonar_radius, h = sonar_height); } } |
57 | |
58 | module sonar_holder() { |
59 | elbow_length = deck_depth - 0.5; |
60 | rounded_corner_radius = buffer; |
61 | difference() { |
62 | cube([sonar_holder_length, sonar_holder_width, sonar_holder_depth]); |
63 | translate([sonar_holder_length / 2, sonar_holder_width / 2, -0.05]) { |
64 | sonars(); } |
65 | translate([sonar_holder_length, |
66 | sonar_holder_width, |
67 | 0]) { |
68 | corner_rounder(rounded_corner_radius, |
69 | sonar_holder_depth, |
70 | "bottom-right"); } } |
71 | translate([sonar_holder_length, 0, 0]) { |
72 | cube([elbow_length, deck_depth, sonar_holder_depth]); |
73 | translate([elbow_length, 0, 0]) { |
74 | linear_extrude(height = sonar_holder_depth) { |
75 | polygon([[ 0, 0], |
76 | [sonar_holder_depth, 0], |
77 | [sonar_holder_depth, sonar_holder_width / 2], |
78 | [ 0, |
79 | sonar_holder_width / 2 + sonar_holder_depth]]); } |
80 | translate([0, (sonar_holder_width + sonar_holder_depth) / 2, 0]) { |
81 | cube([sonar_holder_depth / 2, |
82 | (sonar_holder_width - sonar_holder_depth) / 2 + 0.8, |
83 | sonar_holder_depth]); } |
84 | translate([-1.7, sonar_holder_width + 0.8, 0]) { |
85 | linear_extrude(height = sonar_holder_depth) { |
86 | polygon([[ 0, 0], |
87 | [sonar_holder_depth / 2 + 1.7, 4], |
88 | [sonar_holder_depth / 2 + 1.7, 0]]); } } } } } |
89 | |
90 | module deck_holder() { |
91 | deck_holder_width = sonar_holder_width - deck_depth; |
92 | deck_holder_height = sonar_holder_depth * 2 + deck_depth; |
93 | linear_extrude(height = deck_holder_width) { |
94 | difference() { |
95 | square([deck_holder_length, deck_holder_height]); |
96 | translate([sonar_holder_depth, sonar_holder_depth]) { |
97 | square(deck_depth); } |
98 | translate([deck_holder_height, sonar_holder_depth]) { |
99 | square([deck_holder_length - (deck_holder_height), deck_depth]); } } } |
100 | translate([deck_holder_length - oshw_dy * 0.05, 0, deck_holder_width / 2]) |
101 | scale([0.1, 1, 0.1]) |
102 | rotate(v = [1, 0, 0], a = 90) |
103 | rotate(90) |
104 | linear_extrude(height = 0.5) |
105 | oshw(); |
106 | translate([deck_holder_length - oshw_dy * 0.05, |
107 | deck_holder_height + 0.5, |
108 | deck_holder_width / 2]) |
109 | rotate(v = [1, 0, 0], a = 90) |
110 | rotate(90) |
111 | scale([0.1, 0.1, 1]) |
112 | linear_extrude(height = 0.5) |
113 | oshw(); } |
114 | |
115 | module corner_rounder_2d(radius, corner_name = "top-left") { |
116 | rotate_for_corner = (corner_name == "top-left") ? 0 : |
117 | ((corner_name == "top-right") ? -90 : |
118 | ((corner_name == "bottom-left") ? 90 : |
119 | ((corner_name == "bottom-right") ? 180 : |
120 | 1 / 0))); |
121 | rotate(rotate_for_corner) { |
122 | difference() { |
123 | square(radius); |
124 | translate([radius, radius]) { |
125 | circle(radius); } } } } |
126 | |
127 | module corner_rounder(radius, height, corner_name = "top-left") { |
128 | linear_extrude(height = height) { |
129 | corner_rounder_2d(radius, corner_name); } } |