blob: d95e1013c7ece3089507533b7d8db995ec3c3e40 [file] [log] [blame]
Austin Schuhbcce26a2018-03-26 23:41:24 -07001package(default_visibility = ["//visibility:public"])
Comran Morshed5323ecb2015-12-26 20:50:55 +00002
Austin Schuhbcce26a2018-03-26 23:41:24 -07003load("//aos/build:queues.bzl", "queue_library")
4load("//tools:environments.bzl", "mcu_cpus")
Austin Schuh719a33e2019-01-07 15:13:34 -08005load("//tools/build_rules:select.bzl", "cpu_select", "compiler_select")
Comran Morshed5323ecb2015-12-26 20:50:55 +00006
7cc_binary(
Austin Schuhbcce26a2018-03-26 23:41:24 -07008 name = "replay_drivetrain",
9 srcs = [
10 "replay_drivetrain.cc",
11 ],
12 deps = [
13 ":drivetrain_queue",
John Park398c74a2018-10-20 21:17:39 -070014 "//aos:init",
Austin Schuhc2b08772018-12-19 18:05:06 +110015 "//aos/controls:replay_control_loop",
Austin Schuhbcce26a2018-03-26 23:41:24 -070016 "//frc971/queues:gyro",
17 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +000018)
19
20queue_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070021 name = "drivetrain_queue",
22 srcs = [
23 "drivetrain.q",
24 ],
25 deps = [
John Park33858a32018-09-28 23:05:48 -070026 "//aos/controls:control_loop_queues",
Austin Schuhbcce26a2018-03-26 23:41:24 -070027 "//frc971/control_loops:queues",
28 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +000029)
30
31cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070032 name = "drivetrain_config",
33 hdrs = [
34 "drivetrain_config.h",
35 ],
36 deps = [
37 "//frc971:shifter_hall_effect",
Austin Schuha062edb2019-01-03 13:17:13 -080038 "//frc971/control_loops:hybrid_state_feedback_loop",
Austin Schuhbcce26a2018-03-26 23:41:24 -070039 "//frc971/control_loops:state_feedback_loop",
40 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +000041)
42
43cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070044 name = "gear",
45 hdrs = [
46 "gear.h",
47 ],
48 compatible_with = mcu_cpus,
Austin Schuh093535c2016-03-05 23:21:00 -080049)
50
51cc_library(
Alex Perry731b4602019-02-02 22:13:01 -080052 name = "splinedrivetrain",
53 srcs = [
54 "splinedrivetrain.cc",
55 ],
56 hdrs = [
57 "splinedrivetrain.h",
58 ],
59 deps = [
60 ":drivetrain_config",
61 ":drivetrain_queue",
62 ":spline",
63 ":distance_spline",
64 ":trajectory",
65 ]
66)
67
68cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070069 name = "ssdrivetrain",
70 srcs = [
71 "ssdrivetrain.cc",
72 ],
73 hdrs = [
74 "ssdrivetrain.h",
75 ],
76 deps = [
77 ":drivetrain_config",
78 ":drivetrain_queue",
79 ":gear",
John Park33858a32018-09-28 23:05:48 -070080 "//aos:math",
81 "//aos/controls:control_loop",
82 "//aos/controls:polytope",
83 "//aos/logging:matrix_logging",
84 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +110085 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -070086 "//aos/util:log_interval",
87 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -070088 "//frc971:shifter_hall_effect",
89 "//frc971/control_loops:coerce_goal",
90 "//frc971/control_loops:state_feedback_loop",
91 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +000092)
93
94cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070095 name = "polydrivetrain",
96 srcs = [
97 "polydrivetrain.cc",
98 ],
99 hdrs = [
100 "polydrivetrain.h",
101 ],
102 deps = [
103 ":drivetrain_config",
104 ":drivetrain_queue",
105 ":gear",
John Park33858a32018-09-28 23:05:48 -0700106 "//aos:math",
107 "//aos/controls:polytope",
108 "//aos/logging:matrix_logging",
109 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100110 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700111 "//aos/util:log_interval",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700112 "//frc971/control_loops:coerce_goal",
113 "//frc971/control_loops:state_feedback_loop",
114 ],
115)
116
117cc_library(
118 name = "drivetrain_config_uc",
119 hdrs = [
120 "drivetrain_config.h",
121 ],
122 restricted_to = mcu_cpus,
123 deps = [
124 "//frc971:shifter_hall_effect",
125 "//frc971/control_loops:state_feedback_loop_uc",
126 ],
127)
128
129cc_library(
130 name = "polydrivetrain_uc",
131 srcs = [
132 "drivetrain_uc.q.cc",
133 "polydrivetrain.cc",
134 ],
135 hdrs = [
136 "drivetrain_uc.q.h",
137 "polydrivetrain.h",
138 ],
139 restricted_to = mcu_cpus,
140 deps = [
141 ":drivetrain_config_uc",
142 ":gear",
John Park33858a32018-09-28 23:05:48 -0700143 "//aos:math",
144 "//aos/controls:polytope_uc",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700145 "//frc971/control_loops:coerce_goal_uc",
146 "//frc971/control_loops:state_feedback_loop_uc",
147 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000148)
149
Austin Schuh05c5a612016-04-02 15:10:25 -0700150genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700151 name = "genrule_down_estimator",
152 outs = [
153 "down_estimator.h",
154 "down_estimator.cc",
155 ],
156 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
157 tools = [
158 "//frc971/control_loops/python:down_estimator",
159 ],
160 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700161)
162
163cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700164 name = "down_estimator",
165 srcs = [
166 "down_estimator.cc",
167 ],
168 hdrs = [
169 "down_estimator.h",
170 ],
171 deps = [
172 "//frc971/control_loops:state_feedback_loop",
173 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700174)
175
Comran Morshed5323ecb2015-12-26 20:50:55 +0000176cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700177 name = "drivetrain_lib",
178 srcs = [
179 "drivetrain.cc",
180 ],
181 hdrs = [
182 "drivetrain.h",
183 ],
184 deps = [
185 ":down_estimator",
186 ":drivetrain_queue",
187 ":gear",
188 ":polydrivetrain",
189 ":ssdrivetrain",
Alex Perry731b4602019-02-02 22:13:01 -0800190 ":splinedrivetrain",
John Park33858a32018-09-28 23:05:48 -0700191 "//aos/controls:control_loop",
192 "//aos/logging:matrix_logging",
193 "//aos/logging:queue_logging",
194 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800195 "//frc971/control_loops:runge_kutta",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700196 "//frc971/queues:gyro",
197 "//frc971/wpilib:imu_queue",
198 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000199)
200
201cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700202 name = "drivetrain_lib_test",
203 srcs = [
204 "drivetrain_lib_test.cc",
205 ],
206 deps = [
207 ":drivetrain_config",
208 ":drivetrain_lib",
209 ":drivetrain_queue",
John Park33858a32018-09-28 23:05:48 -0700210 "//aos:queues",
211 "//aos/controls:control_loop_test",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700212 "//aos/testing:googletest",
213 "//frc971/control_loops:state_feedback_loop",
214 "//frc971/queues:gyro",
215 "//y2016:constants",
216 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
217 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000218)
Brian Silverman6260c092018-01-14 15:21:36 -0800219
220genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700221 name = "genrule_haptic_wheel",
222 outs = [
223 "haptic_wheel.h",
224 "haptic_wheel.cc",
225 "integral_haptic_wheel.h",
226 "integral_haptic_wheel.cc",
227 "haptic_trigger.h",
228 "haptic_trigger.cc",
229 "integral_haptic_trigger.h",
230 "integral_haptic_trigger.cc",
231 ],
232 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
233 compatible_with = mcu_cpus,
234 tools = [
235 "//frc971/control_loops/python:haptic_wheel",
236 ],
237 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800238)
239
240cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700241 name = "haptic_input_uc",
242 srcs = [
243 "haptic_trigger.cc",
244 "haptic_wheel.cc",
245 "integral_haptic_trigger.cc",
246 "integral_haptic_wheel.cc",
247 ],
248 hdrs = [
249 "haptic_trigger.h",
250 "haptic_wheel.h",
251 "integral_haptic_trigger.h",
252 "integral_haptic_wheel.h",
253 ],
254 restricted_to = mcu_cpus,
255 deps = [
256 "//frc971/control_loops:state_feedback_loop_uc",
257 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800258)
259
260cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700261 name = "haptic_wheel",
262 srcs = [
263 "haptic_trigger.cc",
264 "haptic_wheel.cc",
265 "integral_haptic_trigger.cc",
266 "integral_haptic_wheel.cc",
267 ],
268 hdrs = [
269 "haptic_trigger.h",
270 "haptic_wheel.h",
271 "integral_haptic_trigger.h",
272 "integral_haptic_wheel.h",
273 ],
274 deps = [
275 "//frc971/control_loops:state_feedback_loop",
276 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800277)
Austin Schuhc2b08772018-12-19 18:05:06 +1100278
279cc_library(
280 name = "spline",
281 srcs = ["spline.cc"],
282 hdrs = ["spline.h"],
283 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800284 "//frc971/control_loops:binomial",
Austin Schuhc2b08772018-12-19 18:05:06 +1100285 "//third_party/eigen",
286 ],
287)
288
Alex Perrya60da442019-01-21 19:00:27 -0500289cc_binary(
290 name = "spline.so",
291 srcs = ["libspline.cc"],
292 deps = [
293 ":distance_spline",
294 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800295 ":trajectory",
296 "//aos/logging:implementations",
297 "//aos/network:team_number",
Alex Perrya60da442019-01-21 19:00:27 -0500298 "//third_party/eigen",
Alex Perry0603b542019-01-25 20:29:51 -0800299 "//y2019/control_loops/drivetrain:drivetrain_base",
Alex Perrya60da442019-01-21 19:00:27 -0500300 ],
301 linkshared=True,
302)
303
Austin Schuhc2b08772018-12-19 18:05:06 +1100304cc_test(
305 name = "spline_test",
306 srcs = [
307 "spline_test.cc",
308 ],
309 restricted_to = ["//tools:k8"],
310 deps = [
311 ":spline",
312 "//aos/testing:googletest",
313 "//third_party/matplotlib-cpp",
314 "@com_github_gflags_gflags//:gflags",
315 ],
316)
Austin Schuh941b46d2018-12-19 18:06:05 +1100317
318cc_library(
319 name = "distance_spline",
320 srcs = ["distance_spline.cc"],
321 hdrs = ["distance_spline.h"],
322 deps = [
323 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800324 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100325 "//frc971/control_loops:fixed_quadrature",
326 "//third_party/eigen",
327 ],
328)
329
330cc_test(
331 name = "distance_spline_test",
332 srcs = [
333 "distance_spline_test.cc",
334 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800335 defines =
336 cpu_select({
337 "amd64": [
338 "SUPPORT_PLOT=1",
339 ],
340 "arm": [],
341 }),
342 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100343 deps = [
344 ":distance_spline",
345 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800346 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100347 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800348 ] + cpu_select({
349 "amd64": [
350 "//third_party/matplotlib-cpp",
351 ],
352 "arm": [],
353 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100354)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100355
356cc_library(
357 name = "trajectory",
358 srcs = ["trajectory.cc"],
359 hdrs = ["trajectory.h"],
360 deps = [
361 ":distance_spline",
362 ":drivetrain_config",
363 "//aos/logging:matrix_logging",
364 "//frc971/control_loops:c2d",
365 "//frc971/control_loops:dlqr",
366 "//frc971/control_loops:hybrid_state_feedback_loop",
367 "//frc971/control_loops:runge_kutta",
368 "//frc971/control_loops:state_feedback_loop",
369 "//third_party/eigen",
370 ],
371)
372
373cc_binary(
374 name = "trajectory_plot",
375 srcs = [
376 "trajectory_plot.cc",
377 ],
378 restricted_to = ["//tools:k8"],
379 deps = [
380 ":distance_spline",
381 ":trajectory",
382 "//aos/logging:implementations",
383 "//aos/logging:matrix_logging",
384 "//aos/network:team_number",
385 "//third_party/eigen",
386 "//third_party/matplotlib-cpp",
387 "//y2016/control_loops/drivetrain:drivetrain_base",
388 "@com_github_gflags_gflags//:gflags",
389 ],
390)
391
392cc_test(
393 name = "trajectory_test",
394 srcs = [
395 "trajectory_test.cc",
396 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800397 defines =
398 cpu_select({
399 "amd64": [
400 "SUPPORT_PLOT=1",
401 ],
402 "arm": [],
403 }),
404 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100405 deps = [
406 ":trajectory",
407 "//aos/testing:googletest",
408 "//aos/testing:test_shm",
409 "//y2016:constants",
410 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800411 ] + cpu_select({
412 "amd64": [
413 "//third_party/matplotlib-cpp",
414 ],
415 "arm": [],
416 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100417)