| 1 | #! /usr/bin/env racket |
| 2 | #lang racket |
| 3 | |
| 4 | (module+ main |
| 5 | (displayln total-cost)) |
| 6 | |
| 7 | ;; the robot is made of a bunch of items, like a screw or a motor. |
| 8 | |
| 9 | ;; this is a description of items in general. |
| 10 | (struct item |
| 11 | (;; each item has a natural language description what the part is. |
| 12 | description |
| 13 | |
| 14 | ;; how many units of this item are on a single robot |
| 15 | quantity |
| 16 | |
| 17 | ;; how much does a single unit of these items cost |
| 18 | unit-cost |
| 19 | |
| 20 | ;; how many days will it take to get the item |
| 21 | max-lead-days |
| 22 | |
| 23 | ;; how to obtain the item |
| 24 | where-to-get |
| 25 | |
| 26 | ;; any special notes about the item |
| 27 | note)) |
| 28 | |
| 29 | ;; estimate of the cost of pla in dollars per cubic centimeter |
| 30 | (define pla-$/cm^3 |
| 31 | ;; this cost is an estimate taken from this site |
| 32 | ;; http://www.toybuilderlabs.com/ |
| 33 | ;; blogs/news/13053117-filament-volume-and-length |
| 34 | (/ 25 800)) |
| 35 | |
| 36 | ;; usually, the above code would be enough for describing a bunch of |
| 37 | ;; items. unfortunately, the last argument, for the parameter 'note', |
| 38 | ;; must be supplied in the default item constructor created above. |
| 39 | ;; this constructor below, called 'make-item', allows creating |
| 40 | ;; items without supplying the argument for the parameter 'note'. if |
| 41 | ;; the 'note' argument is not supplied, it will be replaced by the |
| 42 | ;; empty string, "". |
| 43 | (define (make-item |
| 44 | description quantity unit-cost max-lead-days where-to-get |
| 45 | [note ""]) |
| 46 | (item description quantity unit-cost max-lead-days where-to-get note)) |
| 47 | |
| 48 | ;; TODO: add actual cost for screws, nuts, and other estimated parts |
| 49 | ;; TODO: add male-female jump wires for connecting sonar sensors |
| 50 | ;; TODO: add ball caster |
| 51 | ;; TODO: checkout the following, if it's not a fraud, buy for next class |
| 52 | ;;; (string-append |
| 53 | ;;; "http://www.ebay.com/itm/UNO-R3-Development-Board-MEGA328P-" |
| 54 | ;;; "ATMEGA16U2-For-Arduino-Compatible-USB-Cable/201090526898") |
| 55 | ;;; only $9.99 for arduino uno r3 + usb!! |
| 56 | (define bill-of-materials |
| 57 | (list |
| 58 | ;; the construction of the first item is heavily commented. |
| 59 | ;; the higher amount of commenting is intended to make it clear |
| 60 | ;; how the code works to new readers |
| 61 | (make-item (string-append |
| 62 | ;; this is the argument for the parameter 'description'. |
| 63 | ;; it's a description of the orange wire. this is for |
| 64 | ;; documentation. |
| 65 | "solid core orange 22 awg wire, male-male jump wire." |
| 66 | " units in mm. makes electrical connection between" |
| 67 | " arduino and motor controller, used for backwards" |
| 68 | " enabling.") |
| 69 | |
| 70 | ;; this is the argument for the parameter 'quantity'. |
| 71 | ;; this is the number of millimeters of orange wire |
| 72 | ;; in a single robot kit. |
| 73 | ;; there are 2 orange wires, one for each wire. |
| 74 | ;; the 120 mm wire reaches to the far side of the |
| 75 | ;; motor controller |
| 76 | (+ 120 90) |
| 77 | |
| 78 | ;; this is the argument for the parameter 'unit-cost'. |
| 79 | ;; the cost on jameco is 7.95 for 100 feet. |
| 80 | ;; this calculation converts from dollars per foot to |
| 81 | ;; dollars per millimeter. |
| 82 | ;; there are 100 feet, 12 inches per foot, 2.54 cm / inch, |
| 83 | ;; and 10 mm / cm. |
| 84 | ;; the product of all these numbers is the number of |
| 85 | ;; millimeters purchased with $7.95 |
| 86 | (/ 7.95 (* 100 12 2.54 10)) |
| 87 | |
| 88 | ;; this is the argument for the parameter 'max-lead-days'. |
| 89 | ;; since the part is at jameco, i can pick it up same day. |
| 90 | 1 |
| 91 | |
| 92 | ;; this is the argument for the parameter 'where-to-get'. |
| 93 | ;; it is a url where the part can be purchased. |
| 94 | (string-append |
| 95 | "http://www.jameco.com/webapp/wcs/stores/servlet/Product" |
| 96 | "_10001_10001_2154871_-1")) |
| 97 | |
| 98 | (make-item (string-append |
| 99 | "solid core blue 22 awg wire, male-male jump wire." |
| 100 | " units in mm. connects motor controller and arduino," |
| 101 | " used for forwards enabling.") |
| 102 | (+ 120 90) |
| 103 | (/ 7.95 (* 100 12 25.4)) |
| 104 | 1 |
| 105 | (string-append |
| 106 | "http://www.jameco.com/webapp/wcs/stores/servlet/Product" |
| 107 | "_10001_10001_36768_-1")) |
| 108 | (make-item (string-append |
| 109 | "solid core white 22 awg wire, male-male jump wire." |
| 110 | " units in mm. connects motor controller and arduino," |
| 111 | " used for speed signal.") |
| 112 | (+ 120 90) |
| 113 | ;; cost of 1 mm |
| 114 | (/ 7.95 (* 100 12 25.4)) |
| 115 | 1 |
| 116 | (string-append |
| 117 | "http://www.jameco.com/webapp/wcs/stores/servlet/Product" |
| 118 | "_10001_10001_36881_-1") |
| 119 | (string-append "unit cost goes down for large orders," |
| 120 | " see page for specifics")) |
| 121 | (make-item (string-append |
| 122 | "solid core green 22 awg wire, male-male jump wire." |
| 123 | " units in mm. connects motor to breadboard.") |
| 124 | (* 2 175) |
| 125 | (/ 7.95 (* 100 12 25.4)) |
| 126 | 1 |
| 127 | (string-append |
| 128 | "http://www.jameco.com/webapp/wcs/stores/servlet/Product" |
| 129 | "_10001_10001_36822_-1")) |
| 130 | (make-item (string-append |
| 131 | "solid core yellow 22 awg wire, male-male jump wire." |
| 132 | " units in mm. connects motor to breadboard.") |
| 133 | (* 2 175) |
| 134 | (/ 7.95 (* 100 12 25.4)) |
| 135 | 1 |
| 136 | (string-append |
| 137 | "http://www.jameco.com/webapp/wcs/stores/servlet/Product" |
| 138 | "_10001_10001_36920_-1")) |
| 139 | (make-item (string-append |
| 140 | "solid core red 22 awg wire, male-male jump wire." |
| 141 | " units in mm. connects power for all components.") |
| 142 | (+ (* 2 30) 25 25) |
| 143 | (/ 7.95 (* 100 12 25.4)) |
| 144 | 1 |
| 145 | (string-append |
| 146 | "http://www.jameco.com/webapp/wcs/stores/servlet/Product" |
| 147 | "_10001_10001_36856_-1")) |
| 148 | (make-item (string-append |
| 149 | "solid core black 22 awg wire, male-male jump wire." |
| 150 | " units in mm. connects ground for all components.") |
| 151 | (+ (* 30 2) (* 4 25) 25 55) |
| 152 | (/ 7.95 (* 100 12 25.4)) |
| 153 | 1 |
| 154 | (string-append |
| 155 | "http://www.jameco.com/webapp/wcs/stores/servlet/Product" |
| 156 | "_10001_10001_36792_-1")) |
| 157 | (make-item "9v battery" |
| 158 | 1 (/ 9.99 5) 1 |
| 159 | "http://www.frys.com/product/5234117" |
| 160 | "can get in store") |
| 161 | (make-item "9v battery holder" |
| 162 | 1 (/ 1.25 10) 1 |
| 163 | (string-append |
| 164 | "http://www.jameco.com/webapp/wcs/stores/servlet/Product" |
| 165 | "_10001_10001_2128067_-1") |
| 166 | "can get in store") |
| 167 | (make-item "AA battery" |
| 168 | 4 (/ 17.99 100) 1 |
| 169 | "http://www.frys.com/product/6292850" |
| 170 | "can get in store") |
| 171 | (make-item "4xAA battery holder" |
| 172 | 1 2.25 1 |
| 173 | (string-append |
| 174 | "http://shop.evilmadscientist.com/" |
| 175 | "productsmenu/partsmenu/422") |
| 176 | (string-append |
| 177 | "can get in store. unit cost goes down for large orders" |
| 178 | ", see page for specifics.")) |
| 179 | (make-item "angle bracket, 1/2 inch sides with #6-32 threaded hole" |
| 180 | 4 0.75 1 |
| 181 | (string-append |
| 182 | "http://shop.evilmadscientist.com/productsmenu/partsmenu" |
| 183 | "/465-bracket") |
| 184 | (string-append |
| 185 | "can get in store. unit cost goes down for large orders" |
| 186 | ", see page for specifics.")) |
| 187 | (make-item "Arduino(tm) Uno board" |
| 188 | 1 16.98 8 |
| 189 | (string-append |
| 190 | "http://www.colorapples.com/2012-new-arduino-uno-r3-boar" |
| 191 | "d-atmega328-with-usb-cable-p-89818.html#.U3Lz5nJKyzA") |
| 192 | (string-append |
| 193 | "comes with USB A to B cable. unit cost goes down for" |
| 194 | " large orders, see page for specifics.")) |
| 195 | (make-item "motor" 2 6 7 "https://solarbotics.com/product/gm3/") |
| 196 | (make-item "transparent 400 point (half) BreadBoard" |
| 197 | 1 5.95 1 |
| 198 | (string-append |
| 199 | "http://www.jameco.com/webapp/wcs/stores/servlet/" |
| 200 | "Product_10001_10001_2123830_-1")) |
| 201 | (make-item "jumper wire female/male" 1/5 6 2 |
| 202 | (string-append "http://www.nexuscyber.com/7-premium-40-" |
| 203 | "pin-male-to-female-jumper-wires")) |
| 204 | (make-item "deck 8x8 inches" |
| 205 | 1 |
| 206 | ;; cost of entire 24x48 inch pegboard is 55.25 |
| 207 | ;; each deck is only 8x8 inch |
| 208 | (/ 55.25 (* (/ 24 8) (/ 48 8))) |
| 209 | 1 |
| 210 | (string-append |
| 211 | "http://www.homedepot.com/p/" |
| 212 | "Triton-1-4-in-Custom-Painted-Blissful-White-Pegboard" |
| 213 | "-Wall-Organizer-Set-of-2-TPB-2W/205192313#specifications")) |
| 214 | (make-item "small squares of double sided tape" |
| 215 | 1/30 12 1 |
| 216 | (string-append |
| 217 | "http://www.officedepot.com/a/products/495242/" |
| 218 | "Scotch-Permanent-Double-Sided-Foam-Tape/")) |
| 219 | ;; TODO: get actual cost of #4-40 phillips 1&1/4" screws |
| 220 | (make-item "#4-40 Phillips 1 1/4 inch screws" |
| 221 | 4 0.1 1 |
| 222 | "olander" "price is an estimate. can pick up in person") |
| 223 | ;; TODO: get actual cost of #4-40 hex lock nuts |
| 224 | (make-item "#4-40 hex lock nuts" |
| 225 | 6 0.1 1 |
| 226 | "olander" "price is an estimate. can pick up in person") |
| 227 | ;; TODO: get actual cost of #6-32 3/8" screws |
| 228 | (make-item "#6-32 button hex head socket 3/8 inch" |
| 229 | 12 0.1 1 |
| 230 | "olander" "price is an estimate. can pick up in person") |
| 231 | (make-item "motor controller" |
| 232 | 1 (/ 5.2 5) 10 |
| 233 | "http://www.ebay.com/itm/like/180976411359?lpid=82") |
| 234 | (make-item "sonar sensor hc-sr04" |
| 235 | 2 1.39 7 |
| 236 | "http://www.ebay.com/itm/161156018270") |
| 237 | (make-item "caster standoff" |
| 238 | 1 (* 8.2 pla-$/cm^3) 1 |
| 239 | "3d print at home") |
| 240 | (make-item "wheel" |
| 241 | 2 (* 11.3 pla-$/cm^3) 1 |
| 242 | "3d print at home") |
| 243 | (make-item "deck holder" |
| 244 | 2 (* 4.0 pla-$/cm^3) 1 |
| 245 | "3d print at home") |
| 246 | (make-item "sonar holder" |
| 247 | 2 (* 2.4 pla-$/cm^3) 1 |
| 248 | "3d print at home" "price of filament is an estimate") |
| 249 | (make-item "motor mount" |
| 250 | 2 (* 3.1 pla-$/cm^3) 1 |
| 251 | "3d print at home"))) |
| 252 | |
| 253 | (define total-cost |
| 254 | (apply + (for/list ([thing bill-of-materials]) |
| 255 | (* (item-quantity thing) (item-unit-cost thing))))) |