845aa5f9 |
1 | #! /usr/bin/env racket |
2 | #lang racket |
3 | |
4 | (module+ main |
5 | (displayln total-cost)) |
6 | |
8de07f0f |
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. |
5e2e135e |
10 | (struct item |
8de07f0f |
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 | |
da968d15 |
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 | |
8de07f0f |
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, "". |
5e2e135e |
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)) |
8de07f0f |
47 | |
8de07f0f |
48 | ;; TODO: add actual cost for screws, nuts, and other estimated parts |
49 | ;; TODO: add male-female jump wires for connecting sonar sensors |
8de07f0f |
50 | ;; TODO: add ball caster |
8de07f0f |
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!! |
845aa5f9 |
56 | (define bill-of-materials |
57 | (list |
8de07f0f |
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")) |
558c4ef8 |
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" |
8de07f0f |
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.")) |
0ffb8883 |
187 | (make-item "Arduino(tm) Uno board" |
5e2e135e |
188 | 1 16.98 8 |
189 | (string-append |
8de07f0f |
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.")) |
64818921 |
195 | (make-item "gm3 motor 224:1 90 degree shaft" |
196 | 2 6 7 |
197 | "https://solarbotics.com/product/gm3/") |
5e2e135e |
198 | (make-item "transparent 400 point (half) BreadBoard" |
199 | 1 5.95 1 |
200 | (string-append |
201 | "http://www.jameco.com/webapp/wcs/stores/servlet/" |
202 | "Product_10001_10001_2123830_-1")) |
203 | (make-item "jumper wire female/male" 1/5 6 2 |
8de07f0f |
204 | (string-append "http://www.nexuscyber.com/7-premium-40-" |
205 | "pin-male-to-female-jumper-wires")) |
a6cd9a01 |
206 | (make-item "deck 8x8 inches" |
207 | 1 |
208 | ;; cost of entire 24x48 inch pegboard is 55.25 |
209 | ;; each deck is only 8x8 inch |
210 | (/ 55.25 (* (/ 24 8) (/ 48 8))) |
211 | 1 |
212 | (string-append |
213 | "http://www.homedepot.com/p/" |
214 | "Triton-1-4-in-Custom-Painted-Blissful-White-Pegboard" |
215 | "-Wall-Organizer-Set-of-2-TPB-2W/205192313#specifications")) |
5e2e135e |
216 | (make-item "small squares of double sided tape" |
217 | 1/30 12 1 |
218 | (string-append |
8de07f0f |
219 | "http://www.officedepot.com/a/products/495242/" |
220 | "Scotch-Permanent-Double-Sided-Foam-Tape/")) |
5e2e135e |
221 | ;; TODO: get actual cost of #4-40 phillips 1&1/4" screws |
222 | (make-item "#4-40 Phillips 1 1/4 inch screws" |
0ffb8883 |
223 | 4 0.1 1 |
5e2e135e |
224 | "olander" "price is an estimate. can pick up in person") |
225 | ;; TODO: get actual cost of #4-40 hex lock nuts |
226 | (make-item "#4-40 hex lock nuts" |
0ffb8883 |
227 | 6 0.1 1 |
5e2e135e |
228 | "olander" "price is an estimate. can pick up in person") |
229 | ;; TODO: get actual cost of #6-32 3/8" screws |
230 | (make-item "#6-32 button hex head socket 3/8 inch" |
0ffb8883 |
231 | 12 0.1 1 |
5e2e135e |
232 | "olander" "price is an estimate. can pick up in person") |
233 | (make-item "motor controller" |
234 | 1 (/ 5.2 5) 10 |
235 | "http://www.ebay.com/itm/like/180976411359?lpid=82") |
236 | (make-item "sonar sensor hc-sr04" |
237 | 2 1.39 7 |
da968d15 |
238 | "http://www.ebay.com/itm/161156018270") |
239 | (make-item "caster standoff" |
240 | 1 (* 8.2 pla-$/cm^3) 1 |
241 | "3d print at home") |
242 | (make-item "wheel" |
243 | 2 (* 11.3 pla-$/cm^3) 1 |
244 | "3d print at home") |
245 | (make-item "deck holder" |
246 | 2 (* 4.0 pla-$/cm^3) 1 |
247 | "3d print at home") |
248 | (make-item "sonar holder" |
249 | 2 (* 2.4 pla-$/cm^3) 1 |
250 | "3d print at home" "price of filament is an estimate") |
251 | (make-item "motor mount" |
252 | 2 (* 3.1 pla-$/cm^3) 1 |
253 | "3d print at home"))) |
845aa5f9 |
254 | |
255 | (define total-cost |
256 | (apply + (for/list ([thing bill-of-materials]) |
257 | (* (item-quantity thing) (item-unit-cost thing))))) |