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