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