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