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