blob: a4d2ca6ce72246e075175abfe941c0d5a5133d28 [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(
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -080044 name = "hybrid_ekf",
45 hdrs = ["hybrid_ekf.h"],
46 deps = [
47 ":drivetrain_config",
48 "//aos/containers:priority_queue",
49 "//frc971/control_loops:c2d",
50 "//frc971/control_loops:runge_kutta",
51 "//third_party/eigen",
52 ],
53)
54
55cc_test(
56 name = "hybrid_ekf_test",
57 srcs = ["hybrid_ekf_test.cc"],
58 deps = [
59 ":drivetrain_test_lib",
60 ":hybrid_ekf",
61 ":trajectory",
62 "//aos/testing:googletest",
63 "//aos/testing:random_seed",
64 "//aos/testing:test_shm",
65 ],
66)
67
James Kuszmaulef428a02019-03-02 22:19:41 -080068queue_library(
69 name = "localizer_queue",
70 srcs = [
71 "localizer.q",
72 ],
73)
74
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -080075cc_library(
James Kuszmaul3431d622019-02-17 17:07:44 -080076 name = "localizer",
77 hdrs = ["localizer.h"],
78 deps = [
79 ":drivetrain_config",
80 ":hybrid_ekf",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -080081 "//frc971/control_loops:pose",
James Kuszmaul3431d622019-02-17 17:07:44 -080082 ],
83)
84
85cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070086 name = "gear",
87 hdrs = [
88 "gear.h",
89 ],
90 compatible_with = mcu_cpus,
Austin Schuh093535c2016-03-05 23:21:00 -080091)
92
93cc_library(
Alex Perry731b4602019-02-02 22:13:01 -080094 name = "splinedrivetrain",
95 srcs = [
96 "splinedrivetrain.cc",
97 ],
98 hdrs = [
99 "splinedrivetrain.h",
100 ],
101 deps = [
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800102 ":distance_spline",
Alex Perry731b4602019-02-02 22:13:01 -0800103 ":drivetrain_config",
104 ":drivetrain_queue",
105 ":spline",
Alex Perry731b4602019-02-02 22:13:01 -0800106 ":trajectory",
Alex Perry1ec34522019-02-17 22:44:10 -0800107 "//aos:init",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800108 ],
Alex Perry731b4602019-02-02 22:13:01 -0800109)
110
111cc_library(
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800112 name = "line_follow_drivetrain",
113 srcs = [
114 "line_follow_drivetrain.cc",
115 ],
116 hdrs = [
117 "line_follow_drivetrain.h",
118 ],
119 deps = [
120 ":drivetrain_config",
121 ":drivetrain_queue",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800122 ":localizer",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800123 "//aos:math",
124 "//aos/util:math",
125 "//frc971/control_loops:c2d",
126 "//frc971/control_loops:dlqr",
127 "//frc971/control_loops:pose",
128 "//third_party/eigen",
129 ],
130)
131
132cc_test(
133 name = "line_follow_drivetrain_test",
134 srcs = ["line_follow_drivetrain_test.cc"],
135 linkstatic = True,
136 restricted_to = ["//tools:k8"],
137 deps = [
138 ":drivetrain_config",
139 ":drivetrain_test_lib",
140 ":line_follow_drivetrain",
141 ":trajectory",
142 "//aos/testing:googletest",
143 "//aos/testing:test_shm",
144 "//third_party/matplotlib-cpp",
145 "@com_github_gflags_gflags//:gflags",
146 ],
147)
148
149cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700150 name = "ssdrivetrain",
151 srcs = [
152 "ssdrivetrain.cc",
153 ],
154 hdrs = [
155 "ssdrivetrain.h",
156 ],
157 deps = [
158 ":drivetrain_config",
159 ":drivetrain_queue",
160 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800161 ":localizer",
John Park33858a32018-09-28 23:05:48 -0700162 "//aos:math",
163 "//aos/controls:control_loop",
164 "//aos/controls:polytope",
165 "//aos/logging:matrix_logging",
166 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100167 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700168 "//aos/util:log_interval",
169 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700170 "//frc971:shifter_hall_effect",
171 "//frc971/control_loops:coerce_goal",
172 "//frc971/control_loops:state_feedback_loop",
173 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000174)
175
176cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700177 name = "polydrivetrain",
178 srcs = [
179 "polydrivetrain.cc",
180 ],
181 hdrs = [
182 "polydrivetrain.h",
183 ],
184 deps = [
185 ":drivetrain_config",
186 ":drivetrain_queue",
187 ":gear",
John Park33858a32018-09-28 23:05:48 -0700188 "//aos:math",
189 "//aos/controls:polytope",
190 "//aos/logging:matrix_logging",
191 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100192 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700193 "//aos/util:log_interval",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700194 "//frc971/control_loops:coerce_goal",
195 "//frc971/control_loops:state_feedback_loop",
196 ],
197)
198
199cc_library(
200 name = "drivetrain_config_uc",
201 hdrs = [
202 "drivetrain_config.h",
203 ],
204 restricted_to = mcu_cpus,
205 deps = [
206 "//frc971:shifter_hall_effect",
207 "//frc971/control_loops:state_feedback_loop_uc",
208 ],
209)
210
211cc_library(
212 name = "polydrivetrain_uc",
213 srcs = [
214 "drivetrain_uc.q.cc",
215 "polydrivetrain.cc",
216 ],
217 hdrs = [
218 "drivetrain_uc.q.h",
219 "polydrivetrain.h",
220 ],
221 restricted_to = mcu_cpus,
222 deps = [
223 ":drivetrain_config_uc",
224 ":gear",
John Park33858a32018-09-28 23:05:48 -0700225 "//aos:math",
226 "//aos/controls:polytope_uc",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700227 "//frc971/control_loops:coerce_goal_uc",
228 "//frc971/control_loops:state_feedback_loop_uc",
229 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000230)
231
Austin Schuh05c5a612016-04-02 15:10:25 -0700232genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700233 name = "genrule_down_estimator",
234 outs = [
235 "down_estimator.h",
236 "down_estimator.cc",
237 ],
238 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
239 tools = [
240 "//frc971/control_loops/python:down_estimator",
241 ],
242 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700243)
244
245cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700246 name = "down_estimator",
247 srcs = [
248 "down_estimator.cc",
249 ],
250 hdrs = [
251 "down_estimator.h",
252 ],
253 deps = [
254 "//frc971/control_loops:state_feedback_loop",
255 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700256)
257
Comran Morshed5323ecb2015-12-26 20:50:55 +0000258cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700259 name = "drivetrain_lib",
260 srcs = [
261 "drivetrain.cc",
262 ],
263 hdrs = [
264 "drivetrain.h",
265 ],
266 deps = [
267 ":down_estimator",
268 ":drivetrain_queue",
269 ":gear",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800270 ":line_follow_drivetrain",
James Kuszmaul3431d622019-02-17 17:07:44 -0800271 ":localizer",
James Kuszmaulef428a02019-03-02 22:19:41 -0800272 ":localizer_queue",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700273 ":polydrivetrain",
Alex Perry731b4602019-02-02 22:13:01 -0800274 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800275 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700276 "//aos/controls:control_loop",
277 "//aos/logging:matrix_logging",
278 "//aos/logging:queue_logging",
279 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800280 "//frc971/control_loops:runge_kutta",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700281 "//frc971/queues:gyro",
282 "//frc971/wpilib:imu_queue",
283 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000284)
285
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800286cc_library(
287 name = "drivetrain_test_lib",
288 testonly = True,
289 srcs = ["drivetrain_test_lib.cc"],
290 hdrs = ["drivetrain_test_lib.h"],
291 deps = [
292 ":drivetrain_config",
293 ":drivetrain_queue",
294 ":trajectory",
295 "//aos/testing:googletest",
296 "//frc971/control_loops:state_feedback_loop",
297 "//frc971/queues:gyro",
298 "//y2016:constants",
299 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
300 ],
301)
302
Comran Morshed5323ecb2015-12-26 20:50:55 +0000303cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700304 name = "drivetrain_lib_test",
305 srcs = [
306 "drivetrain_lib_test.cc",
307 ],
Alex Perry04300d62019-02-17 14:37:04 -0800308 defines =
309 cpu_select({
310 "amd64": [
311 "SUPPORT_PLOT=1",
312 ],
313 "arm": [],
314 }),
315 linkstatic = True,
Austin Schuhbcce26a2018-03-26 23:41:24 -0700316 deps = [
317 ":drivetrain_config",
318 ":drivetrain_lib",
James Kuszmaulef428a02019-03-02 22:19:41 -0800319 ":localizer_queue",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700320 ":drivetrain_queue",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800321 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700322 "//aos:queues",
323 "//aos/controls:control_loop_test",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700324 "//aos/testing:googletest",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700325 "//frc971/queues:gyro",
Alex Perry04300d62019-02-17 14:37:04 -0800326 ] + cpu_select({
327 "amd64": [
328 "//third_party/matplotlib-cpp",
329 ],
330 "arm": [],
331 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000332)
Brian Silverman6260c092018-01-14 15:21:36 -0800333
334genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700335 name = "genrule_haptic_wheel",
336 outs = [
337 "haptic_wheel.h",
338 "haptic_wheel.cc",
339 "integral_haptic_wheel.h",
340 "integral_haptic_wheel.cc",
341 "haptic_trigger.h",
342 "haptic_trigger.cc",
343 "integral_haptic_trigger.h",
344 "integral_haptic_trigger.cc",
345 ],
346 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
347 compatible_with = mcu_cpus,
348 tools = [
349 "//frc971/control_loops/python:haptic_wheel",
350 ],
351 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800352)
353
354cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700355 name = "haptic_input_uc",
356 srcs = [
357 "haptic_trigger.cc",
358 "haptic_wheel.cc",
359 "integral_haptic_trigger.cc",
360 "integral_haptic_wheel.cc",
361 ],
362 hdrs = [
363 "haptic_trigger.h",
364 "haptic_wheel.h",
365 "integral_haptic_trigger.h",
366 "integral_haptic_wheel.h",
367 ],
368 restricted_to = mcu_cpus,
369 deps = [
370 "//frc971/control_loops:state_feedback_loop_uc",
371 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800372)
373
374cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700375 name = "haptic_wheel",
376 srcs = [
377 "haptic_trigger.cc",
378 "haptic_wheel.cc",
379 "integral_haptic_trigger.cc",
380 "integral_haptic_wheel.cc",
381 ],
382 hdrs = [
383 "haptic_trigger.h",
384 "haptic_wheel.h",
385 "integral_haptic_trigger.h",
386 "integral_haptic_wheel.h",
387 ],
388 deps = [
389 "//frc971/control_loops:state_feedback_loop",
390 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800391)
Austin Schuhc2b08772018-12-19 18:05:06 +1100392
393cc_library(
394 name = "spline",
395 srcs = ["spline.cc"],
396 hdrs = ["spline.h"],
397 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800398 "//frc971/control_loops:binomial",
Austin Schuhc2b08772018-12-19 18:05:06 +1100399 "//third_party/eigen",
400 ],
401)
402
Alex Perrya60da442019-01-21 19:00:27 -0500403cc_binary(
404 name = "spline.so",
405 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800406 linkshared = True,
Alex Perrya60da442019-01-21 19:00:27 -0500407 deps = [
408 ":distance_spline",
409 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800410 ":trajectory",
411 "//aos/logging:implementations",
412 "//aos/network:team_number",
Alex Perrya60da442019-01-21 19:00:27 -0500413 "//third_party/eigen",
Alex Perry0603b542019-01-25 20:29:51 -0800414 "//y2019/control_loops/drivetrain:drivetrain_base",
Alex Perrya60da442019-01-21 19:00:27 -0500415 ],
Alex Perrya60da442019-01-21 19:00:27 -0500416)
417
Austin Schuhc2b08772018-12-19 18:05:06 +1100418cc_test(
419 name = "spline_test",
420 srcs = [
421 "spline_test.cc",
422 ],
423 restricted_to = ["//tools:k8"],
424 deps = [
425 ":spline",
426 "//aos/testing:googletest",
427 "//third_party/matplotlib-cpp",
428 "@com_github_gflags_gflags//:gflags",
429 ],
430)
Austin Schuh941b46d2018-12-19 18:06:05 +1100431
432cc_library(
433 name = "distance_spline",
434 srcs = ["distance_spline.cc"],
435 hdrs = ["distance_spline.h"],
436 deps = [
437 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800438 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100439 "//frc971/control_loops:fixed_quadrature",
440 "//third_party/eigen",
441 ],
442)
443
444cc_test(
445 name = "distance_spline_test",
446 srcs = [
447 "distance_spline_test.cc",
448 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800449 defines =
450 cpu_select({
451 "amd64": [
452 "SUPPORT_PLOT=1",
453 ],
454 "arm": [],
455 }),
456 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100457 deps = [
458 ":distance_spline",
459 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800460 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100461 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800462 ] + cpu_select({
463 "amd64": [
464 "//third_party/matplotlib-cpp",
465 ],
466 "arm": [],
467 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100468)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100469
470cc_library(
471 name = "trajectory",
472 srcs = ["trajectory.cc"],
473 hdrs = ["trajectory.h"],
474 deps = [
475 ":distance_spline",
476 ":drivetrain_config",
477 "//aos/logging:matrix_logging",
478 "//frc971/control_loops:c2d",
479 "//frc971/control_loops:dlqr",
480 "//frc971/control_loops:hybrid_state_feedback_loop",
481 "//frc971/control_loops:runge_kutta",
482 "//frc971/control_loops:state_feedback_loop",
483 "//third_party/eigen",
484 ],
485)
486
487cc_binary(
488 name = "trajectory_plot",
489 srcs = [
490 "trajectory_plot.cc",
491 ],
492 restricted_to = ["//tools:k8"],
493 deps = [
494 ":distance_spline",
495 ":trajectory",
496 "//aos/logging:implementations",
497 "//aos/logging:matrix_logging",
498 "//aos/network:team_number",
499 "//third_party/eigen",
500 "//third_party/matplotlib-cpp",
501 "//y2016/control_loops/drivetrain:drivetrain_base",
502 "@com_github_gflags_gflags//:gflags",
503 ],
504)
505
506cc_test(
507 name = "trajectory_test",
508 srcs = [
509 "trajectory_test.cc",
510 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800511 defines =
512 cpu_select({
513 "amd64": [
514 "SUPPORT_PLOT=1",
515 ],
516 "arm": [],
517 }),
518 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100519 deps = [
520 ":trajectory",
521 "//aos/testing:googletest",
522 "//aos/testing:test_shm",
523 "//y2016:constants",
524 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800525 ] + cpu_select({
526 "amd64": [
527 "//third_party/matplotlib-cpp",
528 ],
529 "arm": [],
530 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100531)