| 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 <sonar-table-top-holder-dimensions.scad> |
| 18 | use <oshw.scad> |
| 19 | oshw_dy = 120.366; |
| 20 | oshw_dx = 133.888; |
| 21 | |
| 22 | module sonar_holder_2d() { |
| 23 | difference() { |
| 24 | square([sonar_holder_length, sonar_holder_width]); } } |
| 25 | |
| 26 | module sonars(){ |
| 27 | translate([between_sonar_centers / 2, 0, 0]){ |
| 28 | cylinder(r = sonar_radius, h = sonar_height);} |
| 29 | // for the variance with which the physical sonar cylinders are placed |
| 30 | translate([between_sonar_centers / 2 - between_sonar_centers_variance, 0, 0]){ |
| 31 | cylinder(r = sonar_radius, h = sonar_height); |
| 32 | translate([0, -sonar_radius, 0]){ |
| 33 | cube([between_sonar_centers_variance, sonar_diameter, sonar_height]);}} |
| 34 | translate([-between_sonar_centers / 2, 0, 0]){ |
| 35 | cylinder(r = sonar_radius, h = sonar_height);}} |
| 36 | |
| 37 | module sonar_holder(){ |
| 38 | elbow_length = deck_depth - 0.5; |
| 39 | rounded_corner_radius = buffer; |
| 40 | difference(){ |
| 41 | cube([sonar_holder_length, sonar_holder_width, sonar_holder_depth]); |
| 42 | translate([sonar_holder_length / 2, sonar_holder_width / 2, -0.05]){ |
| 43 | sonars();} |
| 44 | translate([sonar_holder_length, |
| 45 | sonar_holder_width, |
| 46 | 0]){ |
| 47 | corner_rounder(rounded_corner_radius, |
| 48 | sonar_holder_depth, |
| 49 | "bottom-right");}} |
| 50 | translate([sonar_holder_length, 0, 0]){ |
| 51 | cube([elbow_length, deck_depth, sonar_holder_depth]); |
| 52 | translate([elbow_length, 0, 0]){ |
| 53 | linear_extrude(height = sonar_holder_depth){ |
| 54 | polygon([[ 0, 0], |
| 55 | [sonar_holder_depth, 0], |
| 56 | [sonar_holder_depth, sonar_holder_width / 2], |
| 57 | [ 0, |
| 58 | sonar_holder_width / 2 + sonar_holder_depth]]);} |
| 59 | translate([0, (sonar_holder_width + sonar_holder_depth) / 2, 0]){ |
| 60 | cube([sonar_holder_depth / 2, |
| 61 | (sonar_holder_width - sonar_holder_depth) / 2 + 0.8, |
| 62 | sonar_holder_depth]);} |
| 63 | translate([-1.7, sonar_holder_width + 0.8, 0]){ |
| 64 | linear_extrude(height = sonar_holder_depth){ |
| 65 | polygon([[ 0, 0], |
| 66 | [sonar_holder_depth / 2 + 1.7, 4], |
| 67 | [sonar_holder_depth / 2 + 1.7, 0]]);}}}}} |
| 68 | |
| 69 | module deck_holder(){ |
| 70 | deck_holder_width = sonar_holder_width - deck_depth; |
| 71 | deck_holder_height = sonar_holder_depth * 2 + deck_depth; |
| 72 | linear_extrude(height = deck_holder_width){ |
| 73 | difference(){ |
| 74 | square([deck_holder_length, deck_holder_height]); |
| 75 | translate([sonar_holder_depth, sonar_holder_depth]){ |
| 76 | square(deck_depth);} |
| 77 | translate([deck_holder_height, sonar_holder_depth]){ |
| 78 | square([deck_holder_length - (deck_holder_height), deck_depth]);}}} |
| 79 | translate([deck_holder_length - oshw_dy * 0.05, 0, deck_holder_width / 2]) |
| 80 | scale([0.1, 1, 0.1]) |
| 81 | rotate(v = [1, 0, 0], a = 90) |
| 82 | rotate(90) |
| 83 | linear_extrude(height = 0.5) |
| 84 | oshw(); |
| 85 | translate([deck_holder_length - oshw_dy * 0.05, |
| 86 | deck_holder_height + 0.5, |
| 87 | deck_holder_width / 2]) |
| 88 | rotate(v = [1, 0, 0], a = 90) |
| 89 | rotate(90) |
| 90 | scale([0.1, 0.1, 1]) |
| 91 | linear_extrude(height = 0.5) |
| 92 | oshw();} |
| 93 | |
| 94 | module corner_rounder_2d(radius, corner_name="top-left"){ |
| 95 | rotate_for_corner = (corner_name == "top-left") ? 0 : |
| 96 | ((corner_name == "top-right") ? -90 : |
| 97 | ((corner_name == "bottom-left") ? 90 : |
| 98 | ((corner_name == "bottom-right") ? 180 : |
| 99 | 1 / 0))); |
| 100 | rotate(rotate_for_corner){ |
| 101 | difference (){ |
| 102 | square(radius); |
| 103 | translate([radius, radius]){ |
| 104 | circle(radius);}}}} |
| 105 | |
| 106 | module corner_rounder(radius, height, corner_name="top-left"){ |
| 107 | linear_extrude(height = height){ |
| 108 | corner_rounder_2d(radius, corner_name);}} |
| 109 | |
| 110 | sonar_holder(); |