blob: a1b96be9aa53dc8b7dd5fe0da3ea587ef59d3eca [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",
297 "//aos/testing:googletest",
298 "//frc971/control_loops:state_feedback_loop",
299 "//frc971/queues:gyro",
300 "//y2016:constants",
301 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
302 ],
303)
304
Comran Morshed5323ecb2015-12-26 20:50:55 +0000305cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700306 name = "drivetrain_lib_test",
307 srcs = [
308 "drivetrain_lib_test.cc",
309 ],
Alex Perry04300d62019-02-17 14:37:04 -0800310 defines =
311 cpu_select({
312 "amd64": [
313 "SUPPORT_PLOT=1",
314 ],
315 "arm": [],
316 }),
317 linkstatic = True,
Austin Schuhbcce26a2018-03-26 23:41:24 -0700318 deps = [
319 ":drivetrain_config",
320 ":drivetrain_lib",
James Kuszmaulef428a02019-03-02 22:19:41 -0800321 ":localizer_queue",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700322 ":drivetrain_queue",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800323 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700324 "//aos:queues",
325 "//aos/controls:control_loop_test",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700326 "//aos/testing:googletest",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700327 "//frc971/queues:gyro",
Alex Perry04300d62019-02-17 14:37:04 -0800328 ] + cpu_select({
329 "amd64": [
330 "//third_party/matplotlib-cpp",
331 ],
332 "arm": [],
333 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000334)
Brian Silverman6260c092018-01-14 15:21:36 -0800335
336genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700337 name = "genrule_haptic_wheel",
338 outs = [
339 "haptic_wheel.h",
340 "haptic_wheel.cc",
341 "integral_haptic_wheel.h",
342 "integral_haptic_wheel.cc",
343 "haptic_trigger.h",
344 "haptic_trigger.cc",
345 "integral_haptic_trigger.h",
346 "integral_haptic_trigger.cc",
347 ],
348 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
349 compatible_with = mcu_cpus,
350 tools = [
351 "//frc971/control_loops/python:haptic_wheel",
352 ],
353 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800354)
355
356cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700357 name = "haptic_input_uc",
358 srcs = [
359 "haptic_trigger.cc",
360 "haptic_wheel.cc",
361 "integral_haptic_trigger.cc",
362 "integral_haptic_wheel.cc",
363 ],
364 hdrs = [
365 "haptic_trigger.h",
366 "haptic_wheel.h",
367 "integral_haptic_trigger.h",
368 "integral_haptic_wheel.h",
369 ],
370 restricted_to = mcu_cpus,
371 deps = [
372 "//frc971/control_loops:state_feedback_loop_uc",
373 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800374)
375
376cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700377 name = "haptic_wheel",
378 srcs = [
379 "haptic_trigger.cc",
380 "haptic_wheel.cc",
381 "integral_haptic_trigger.cc",
382 "integral_haptic_wheel.cc",
383 ],
384 hdrs = [
385 "haptic_trigger.h",
386 "haptic_wheel.h",
387 "integral_haptic_trigger.h",
388 "integral_haptic_wheel.h",
389 ],
390 deps = [
391 "//frc971/control_loops:state_feedback_loop",
392 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800393)
Austin Schuhc2b08772018-12-19 18:05:06 +1100394
395cc_library(
396 name = "spline",
397 srcs = ["spline.cc"],
398 hdrs = ["spline.h"],
399 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800400 "//frc971/control_loops:binomial",
Austin Schuhc2b08772018-12-19 18:05:06 +1100401 "//third_party/eigen",
402 ],
403)
404
Alex Perrya60da442019-01-21 19:00:27 -0500405cc_binary(
406 name = "spline.so",
407 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800408 linkshared = True,
Alex Perrya60da442019-01-21 19:00:27 -0500409 deps = [
410 ":distance_spline",
411 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800412 ":trajectory",
413 "//aos/logging:implementations",
414 "//aos/network:team_number",
Alex Perrya60da442019-01-21 19:00:27 -0500415 "//third_party/eigen",
Alex Perry0603b542019-01-25 20:29:51 -0800416 "//y2019/control_loops/drivetrain:drivetrain_base",
Alex Perrya60da442019-01-21 19:00:27 -0500417 ],
Alex Perrya60da442019-01-21 19:00:27 -0500418)
419
Austin Schuhc2b08772018-12-19 18:05:06 +1100420cc_test(
421 name = "spline_test",
422 srcs = [
423 "spline_test.cc",
424 ],
425 restricted_to = ["//tools:k8"],
426 deps = [
427 ":spline",
428 "//aos/testing:googletest",
429 "//third_party/matplotlib-cpp",
430 "@com_github_gflags_gflags//:gflags",
431 ],
432)
Austin Schuh941b46d2018-12-19 18:06:05 +1100433
434cc_library(
435 name = "distance_spline",
436 srcs = ["distance_spline.cc"],
437 hdrs = ["distance_spline.h"],
438 deps = [
439 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800440 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100441 "//frc971/control_loops:fixed_quadrature",
442 "//third_party/eigen",
443 ],
444)
445
446cc_test(
447 name = "distance_spline_test",
448 srcs = [
449 "distance_spline_test.cc",
450 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800451 defines =
452 cpu_select({
453 "amd64": [
454 "SUPPORT_PLOT=1",
455 ],
456 "arm": [],
457 }),
458 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100459 deps = [
460 ":distance_spline",
461 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800462 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100463 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800464 ] + cpu_select({
465 "amd64": [
466 "//third_party/matplotlib-cpp",
467 ],
468 "arm": [],
469 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100470)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100471
472cc_library(
473 name = "trajectory",
474 srcs = ["trajectory.cc"],
475 hdrs = ["trajectory.h"],
476 deps = [
477 ":distance_spline",
478 ":drivetrain_config",
479 "//aos/logging:matrix_logging",
480 "//frc971/control_loops:c2d",
481 "//frc971/control_loops:dlqr",
482 "//frc971/control_loops:hybrid_state_feedback_loop",
483 "//frc971/control_loops:runge_kutta",
484 "//frc971/control_loops:state_feedback_loop",
485 "//third_party/eigen",
486 ],
487)
488
489cc_binary(
490 name = "trajectory_plot",
491 srcs = [
492 "trajectory_plot.cc",
493 ],
494 restricted_to = ["//tools:k8"],
495 deps = [
496 ":distance_spline",
497 ":trajectory",
498 "//aos/logging:implementations",
499 "//aos/logging:matrix_logging",
500 "//aos/network:team_number",
501 "//third_party/eigen",
502 "//third_party/matplotlib-cpp",
Austin Schuh11043182019-03-23 22:29:12 -0700503 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100504 "@com_github_gflags_gflags//:gflags",
505 ],
506)
507
508cc_test(
509 name = "trajectory_test",
510 srcs = [
511 "trajectory_test.cc",
512 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800513 defines =
514 cpu_select({
515 "amd64": [
516 "SUPPORT_PLOT=1",
517 ],
518 "arm": [],
519 }),
520 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100521 deps = [
522 ":trajectory",
523 "//aos/testing:googletest",
524 "//aos/testing:test_shm",
525 "//y2016:constants",
526 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800527 ] + cpu_select({
528 "amd64": [
529 "//third_party/matplotlib-cpp",
530 ],
531 "arm": [],
532 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100533)