blob: 5f89be1de1c4b1091994a0b16c805307482aeaaa [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",
James Kuszmaulfedc4612019-03-10 11:24:51 -070049 "//aos/util:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -080050 "//frc971/control_loops:c2d",
51 "//frc971/control_loops:runge_kutta",
52 "//third_party/eigen",
53 ],
54)
55
56cc_test(
57 name = "hybrid_ekf_test",
58 srcs = ["hybrid_ekf_test.cc"],
59 deps = [
60 ":drivetrain_test_lib",
61 ":hybrid_ekf",
62 ":trajectory",
63 "//aos/testing:googletest",
64 "//aos/testing:random_seed",
65 "//aos/testing:test_shm",
66 ],
67)
68
James Kuszmaulef428a02019-03-02 22:19:41 -080069queue_library(
70 name = "localizer_queue",
71 srcs = [
72 "localizer.q",
73 ],
74)
75
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -080076cc_library(
James Kuszmaul3431d622019-02-17 17:07:44 -080077 name = "localizer",
78 hdrs = ["localizer.h"],
79 deps = [
80 ":drivetrain_config",
81 ":hybrid_ekf",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -080082 "//frc971/control_loops:pose",
James Kuszmaul3431d622019-02-17 17:07:44 -080083 ],
84)
85
86cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070087 name = "gear",
88 hdrs = [
89 "gear.h",
90 ],
91 compatible_with = mcu_cpus,
Austin Schuh093535c2016-03-05 23:21:00 -080092)
93
94cc_library(
Alex Perry731b4602019-02-02 22:13:01 -080095 name = "splinedrivetrain",
96 srcs = [
97 "splinedrivetrain.cc",
98 ],
99 hdrs = [
100 "splinedrivetrain.h",
101 ],
102 deps = [
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800103 ":distance_spline",
Alex Perry731b4602019-02-02 22:13:01 -0800104 ":drivetrain_config",
105 ":drivetrain_queue",
106 ":spline",
Alex Perry731b4602019-02-02 22:13:01 -0800107 ":trajectory",
Alex Perry1ec34522019-02-17 22:44:10 -0800108 "//aos:init",
James Kuszmaulc73bb222019-04-07 12:15:35 -0700109 "//aos/util:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800110 ],
Alex Perry731b4602019-02-02 22:13:01 -0800111)
112
113cc_library(
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800114 name = "line_follow_drivetrain",
115 srcs = [
116 "line_follow_drivetrain.cc",
117 ],
118 hdrs = [
119 "line_follow_drivetrain.h",
120 ],
121 deps = [
122 ":drivetrain_config",
123 ":drivetrain_queue",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800124 ":localizer",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800125 "//aos:math",
126 "//aos/util:math",
127 "//frc971/control_loops:c2d",
128 "//frc971/control_loops:dlqr",
129 "//frc971/control_loops:pose",
130 "//third_party/eigen",
131 ],
132)
133
134cc_test(
135 name = "line_follow_drivetrain_test",
136 srcs = ["line_follow_drivetrain_test.cc"],
137 linkstatic = True,
138 restricted_to = ["//tools:k8"],
139 deps = [
140 ":drivetrain_config",
141 ":drivetrain_test_lib",
142 ":line_follow_drivetrain",
143 ":trajectory",
144 "//aos/testing:googletest",
145 "//aos/testing:test_shm",
146 "//third_party/matplotlib-cpp",
147 "@com_github_gflags_gflags//:gflags",
148 ],
149)
150
151cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700152 name = "ssdrivetrain",
153 srcs = [
154 "ssdrivetrain.cc",
155 ],
156 hdrs = [
157 "ssdrivetrain.h",
158 ],
159 deps = [
160 ":drivetrain_config",
161 ":drivetrain_queue",
162 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800163 ":localizer",
John Park33858a32018-09-28 23:05:48 -0700164 "//aos:math",
165 "//aos/controls:control_loop",
166 "//aos/controls:polytope",
167 "//aos/logging:matrix_logging",
168 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100169 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700170 "//aos/util:log_interval",
171 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700172 "//frc971:shifter_hall_effect",
173 "//frc971/control_loops:coerce_goal",
174 "//frc971/control_loops:state_feedback_loop",
175 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000176)
177
178cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700179 name = "polydrivetrain",
180 srcs = [
181 "polydrivetrain.cc",
182 ],
183 hdrs = [
184 "polydrivetrain.h",
185 ],
186 deps = [
187 ":drivetrain_config",
188 ":drivetrain_queue",
189 ":gear",
John Park33858a32018-09-28 23:05:48 -0700190 "//aos:math",
191 "//aos/controls:polytope",
192 "//aos/logging:matrix_logging",
193 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100194 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700195 "//aos/util:log_interval",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700196 "//frc971/control_loops:coerce_goal",
197 "//frc971/control_loops:state_feedback_loop",
198 ],
199)
200
201cc_library(
202 name = "drivetrain_config_uc",
203 hdrs = [
204 "drivetrain_config.h",
205 ],
206 restricted_to = mcu_cpus,
207 deps = [
208 "//frc971:shifter_hall_effect",
209 "//frc971/control_loops:state_feedback_loop_uc",
210 ],
211)
212
213cc_library(
214 name = "polydrivetrain_uc",
215 srcs = [
216 "drivetrain_uc.q.cc",
217 "polydrivetrain.cc",
218 ],
219 hdrs = [
220 "drivetrain_uc.q.h",
221 "polydrivetrain.h",
222 ],
223 restricted_to = mcu_cpus,
224 deps = [
225 ":drivetrain_config_uc",
226 ":gear",
John Park33858a32018-09-28 23:05:48 -0700227 "//aos:math",
228 "//aos/controls:polytope_uc",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700229 "//frc971/control_loops:coerce_goal_uc",
230 "//frc971/control_loops:state_feedback_loop_uc",
231 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000232)
233
Austin Schuh05c5a612016-04-02 15:10:25 -0700234genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700235 name = "genrule_down_estimator",
236 outs = [
237 "down_estimator.h",
238 "down_estimator.cc",
239 ],
240 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
241 tools = [
242 "//frc971/control_loops/python:down_estimator",
243 ],
244 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700245)
246
247cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700248 name = "down_estimator",
249 srcs = [
250 "down_estimator.cc",
251 ],
252 hdrs = [
253 "down_estimator.h",
254 ],
255 deps = [
256 "//frc971/control_loops:state_feedback_loop",
257 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700258)
259
Comran Morshed5323ecb2015-12-26 20:50:55 +0000260cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700261 name = "drivetrain_lib",
262 srcs = [
263 "drivetrain.cc",
264 ],
265 hdrs = [
266 "drivetrain.h",
267 ],
268 deps = [
269 ":down_estimator",
270 ":drivetrain_queue",
271 ":gear",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800272 ":line_follow_drivetrain",
James Kuszmaul3431d622019-02-17 17:07:44 -0800273 ":localizer",
James Kuszmaulef428a02019-03-02 22:19:41 -0800274 ":localizer_queue",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700275 ":polydrivetrain",
Alex Perry731b4602019-02-02 22:13:01 -0800276 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800277 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700278 "//aos/controls:control_loop",
279 "//aos/logging:matrix_logging",
280 "//aos/logging:queue_logging",
281 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800282 "//frc971/control_loops:runge_kutta",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700283 "//frc971/queues:gyro",
284 "//frc971/wpilib:imu_queue",
285 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000286)
287
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800288cc_library(
289 name = "drivetrain_test_lib",
290 testonly = True,
291 srcs = ["drivetrain_test_lib.cc"],
292 hdrs = ["drivetrain_test_lib.h"],
293 deps = [
294 ":drivetrain_config",
295 ":drivetrain_queue",
296 ":trajectory",
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800297 "//aos/events:event-loop",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800298 "//aos/testing:googletest",
299 "//frc971/control_loops:state_feedback_loop",
300 "//frc971/queues:gyro",
301 "//y2016:constants",
302 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
303 ],
304)
305
Comran Morshed5323ecb2015-12-26 20:50:55 +0000306cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700307 name = "drivetrain_lib_test",
308 srcs = [
309 "drivetrain_lib_test.cc",
310 ],
Alex Perry04300d62019-02-17 14:37:04 -0800311 defines =
312 cpu_select({
313 "amd64": [
314 "SUPPORT_PLOT=1",
315 ],
316 "arm": [],
317 }),
318 linkstatic = True,
Austin Schuhbcce26a2018-03-26 23:41:24 -0700319 deps = [
320 ":drivetrain_config",
321 ":drivetrain_lib",
James Kuszmaulef428a02019-03-02 22:19:41 -0800322 ":localizer_queue",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700323 ":drivetrain_queue",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800324 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700325 "//aos:queues",
326 "//aos/controls:control_loop_test",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700327 "//aos/testing:googletest",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700328 "//frc971/queues:gyro",
Alex Perry04300d62019-02-17 14:37:04 -0800329 ] + cpu_select({
330 "amd64": [
331 "//third_party/matplotlib-cpp",
332 ],
333 "arm": [],
334 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000335)
Brian Silverman6260c092018-01-14 15:21:36 -0800336
337genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700338 name = "genrule_haptic_wheel",
339 outs = [
340 "haptic_wheel.h",
341 "haptic_wheel.cc",
342 "integral_haptic_wheel.h",
343 "integral_haptic_wheel.cc",
344 "haptic_trigger.h",
345 "haptic_trigger.cc",
346 "integral_haptic_trigger.h",
347 "integral_haptic_trigger.cc",
348 ],
349 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
350 compatible_with = mcu_cpus,
351 tools = [
352 "//frc971/control_loops/python:haptic_wheel",
353 ],
354 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800355)
356
357cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700358 name = "haptic_input_uc",
359 srcs = [
360 "haptic_trigger.cc",
361 "haptic_wheel.cc",
362 "integral_haptic_trigger.cc",
363 "integral_haptic_wheel.cc",
364 ],
365 hdrs = [
366 "haptic_trigger.h",
367 "haptic_wheel.h",
368 "integral_haptic_trigger.h",
369 "integral_haptic_wheel.h",
370 ],
371 restricted_to = mcu_cpus,
372 deps = [
373 "//frc971/control_loops:state_feedback_loop_uc",
374 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800375)
376
377cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700378 name = "haptic_wheel",
379 srcs = [
380 "haptic_trigger.cc",
381 "haptic_wheel.cc",
382 "integral_haptic_trigger.cc",
383 "integral_haptic_wheel.cc",
384 ],
385 hdrs = [
386 "haptic_trigger.h",
387 "haptic_wheel.h",
388 "integral_haptic_trigger.h",
389 "integral_haptic_wheel.h",
390 ],
391 deps = [
392 "//frc971/control_loops:state_feedback_loop",
393 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800394)
Austin Schuhc2b08772018-12-19 18:05:06 +1100395
396cc_library(
397 name = "spline",
398 srcs = ["spline.cc"],
399 hdrs = ["spline.h"],
400 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800401 "//frc971/control_loops:binomial",
Austin Schuhc2b08772018-12-19 18:05:06 +1100402 "//third_party/eigen",
403 ],
404)
405
Alex Perrya60da442019-01-21 19:00:27 -0500406cc_binary(
407 name = "spline.so",
408 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800409 linkshared = True,
Alex Perrya60da442019-01-21 19:00:27 -0500410 deps = [
411 ":distance_spline",
412 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800413 ":trajectory",
414 "//aos/logging:implementations",
415 "//aos/network:team_number",
Alex Perrya60da442019-01-21 19:00:27 -0500416 "//third_party/eigen",
Alex Perry0603b542019-01-25 20:29:51 -0800417 "//y2019/control_loops/drivetrain:drivetrain_base",
Alex Perrya60da442019-01-21 19:00:27 -0500418 ],
Alex Perrya60da442019-01-21 19:00:27 -0500419)
420
Austin Schuhc2b08772018-12-19 18:05:06 +1100421cc_test(
422 name = "spline_test",
423 srcs = [
424 "spline_test.cc",
425 ],
426 restricted_to = ["//tools:k8"],
427 deps = [
428 ":spline",
429 "//aos/testing:googletest",
430 "//third_party/matplotlib-cpp",
431 "@com_github_gflags_gflags//:gflags",
432 ],
433)
Austin Schuh941b46d2018-12-19 18:06:05 +1100434
435cc_library(
436 name = "distance_spline",
437 srcs = ["distance_spline.cc"],
438 hdrs = ["distance_spline.h"],
439 deps = [
440 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800441 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100442 "//frc971/control_loops:fixed_quadrature",
443 "//third_party/eigen",
444 ],
445)
446
447cc_test(
448 name = "distance_spline_test",
449 srcs = [
450 "distance_spline_test.cc",
451 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800452 defines =
453 cpu_select({
454 "amd64": [
455 "SUPPORT_PLOT=1",
456 ],
457 "arm": [],
458 }),
459 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100460 deps = [
461 ":distance_spline",
462 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800463 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100464 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800465 ] + cpu_select({
466 "amd64": [
467 "//third_party/matplotlib-cpp",
468 ],
469 "arm": [],
470 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100471)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100472
473cc_library(
474 name = "trajectory",
475 srcs = ["trajectory.cc"],
476 hdrs = ["trajectory.h"],
477 deps = [
478 ":distance_spline",
479 ":drivetrain_config",
480 "//aos/logging:matrix_logging",
481 "//frc971/control_loops:c2d",
482 "//frc971/control_loops:dlqr",
483 "//frc971/control_loops:hybrid_state_feedback_loop",
484 "//frc971/control_loops:runge_kutta",
485 "//frc971/control_loops:state_feedback_loop",
486 "//third_party/eigen",
487 ],
488)
489
490cc_binary(
491 name = "trajectory_plot",
492 srcs = [
493 "trajectory_plot.cc",
494 ],
495 restricted_to = ["//tools:k8"],
496 deps = [
497 ":distance_spline",
498 ":trajectory",
499 "//aos/logging:implementations",
500 "//aos/logging:matrix_logging",
501 "//aos/network:team_number",
502 "//third_party/eigen",
503 "//third_party/matplotlib-cpp",
Austin Schuh11043182019-03-23 22:29:12 -0700504 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100505 "@com_github_gflags_gflags//:gflags",
506 ],
507)
508
509cc_test(
510 name = "trajectory_test",
511 srcs = [
512 "trajectory_test.cc",
513 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800514 defines =
515 cpu_select({
516 "amd64": [
517 "SUPPORT_PLOT=1",
518 ],
519 "arm": [],
520 }),
521 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100522 deps = [
523 ":trajectory",
524 "//aos/testing:googletest",
525 "//aos/testing:test_shm",
526 "//y2016:constants",
527 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800528 ] + cpu_select({
529 "amd64": [
530 "//third_party/matplotlib-cpp",
531 ],
532 "arm": [],
533 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100534)