blob: 1480e4e31eb5882c5f02e44c77ba79c071440190 [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 Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800109 ],
Alex Perry731b4602019-02-02 22:13:01 -0800110)
111
112cc_library(
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800113 name = "line_follow_drivetrain",
114 srcs = [
115 "line_follow_drivetrain.cc",
116 ],
117 hdrs = [
118 "line_follow_drivetrain.h",
119 ],
120 deps = [
121 ":drivetrain_config",
122 ":drivetrain_queue",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800123 ":localizer",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800124 "//aos:math",
125 "//aos/util:math",
126 "//frc971/control_loops:c2d",
127 "//frc971/control_loops:dlqr",
128 "//frc971/control_loops:pose",
129 "//third_party/eigen",
130 ],
131)
132
133cc_test(
134 name = "line_follow_drivetrain_test",
135 srcs = ["line_follow_drivetrain_test.cc"],
136 linkstatic = True,
137 restricted_to = ["//tools:k8"],
138 deps = [
139 ":drivetrain_config",
140 ":drivetrain_test_lib",
141 ":line_follow_drivetrain",
142 ":trajectory",
143 "//aos/testing:googletest",
144 "//aos/testing:test_shm",
145 "//third_party/matplotlib-cpp",
146 "@com_github_gflags_gflags//:gflags",
147 ],
148)
149
150cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700151 name = "ssdrivetrain",
152 srcs = [
153 "ssdrivetrain.cc",
154 ],
155 hdrs = [
156 "ssdrivetrain.h",
157 ],
158 deps = [
159 ":drivetrain_config",
160 ":drivetrain_queue",
161 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800162 ":localizer",
John Park33858a32018-09-28 23:05:48 -0700163 "//aos:math",
164 "//aos/controls:control_loop",
165 "//aos/controls:polytope",
166 "//aos/logging:matrix_logging",
167 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100168 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700169 "//aos/util:log_interval",
170 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700171 "//frc971:shifter_hall_effect",
172 "//frc971/control_loops:coerce_goal",
173 "//frc971/control_loops:state_feedback_loop",
174 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000175)
176
177cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700178 name = "polydrivetrain",
179 srcs = [
180 "polydrivetrain.cc",
181 ],
182 hdrs = [
183 "polydrivetrain.h",
184 ],
185 deps = [
186 ":drivetrain_config",
187 ":drivetrain_queue",
188 ":gear",
John Park33858a32018-09-28 23:05:48 -0700189 "//aos:math",
190 "//aos/controls:polytope",
191 "//aos/logging:matrix_logging",
192 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100193 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700194 "//aos/util:log_interval",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700195 "//frc971/control_loops:coerce_goal",
196 "//frc971/control_loops:state_feedback_loop",
197 ],
198)
199
200cc_library(
201 name = "drivetrain_config_uc",
202 hdrs = [
203 "drivetrain_config.h",
204 ],
205 restricted_to = mcu_cpus,
206 deps = [
207 "//frc971:shifter_hall_effect",
208 "//frc971/control_loops:state_feedback_loop_uc",
209 ],
210)
211
212cc_library(
213 name = "polydrivetrain_uc",
214 srcs = [
215 "drivetrain_uc.q.cc",
216 "polydrivetrain.cc",
217 ],
218 hdrs = [
219 "drivetrain_uc.q.h",
220 "polydrivetrain.h",
221 ],
222 restricted_to = mcu_cpus,
223 deps = [
224 ":drivetrain_config_uc",
225 ":gear",
John Park33858a32018-09-28 23:05:48 -0700226 "//aos:math",
227 "//aos/controls:polytope_uc",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700228 "//frc971/control_loops:coerce_goal_uc",
229 "//frc971/control_loops:state_feedback_loop_uc",
230 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000231)
232
Austin Schuh05c5a612016-04-02 15:10:25 -0700233genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700234 name = "genrule_down_estimator",
235 outs = [
236 "down_estimator.h",
237 "down_estimator.cc",
238 ],
239 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
240 tools = [
241 "//frc971/control_loops/python:down_estimator",
242 ],
243 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700244)
245
246cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700247 name = "down_estimator",
248 srcs = [
249 "down_estimator.cc",
250 ],
251 hdrs = [
252 "down_estimator.h",
253 ],
254 deps = [
255 "//frc971/control_loops:state_feedback_loop",
256 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700257)
258
Comran Morshed5323ecb2015-12-26 20:50:55 +0000259cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700260 name = "drivetrain_lib",
261 srcs = [
262 "drivetrain.cc",
263 ],
264 hdrs = [
265 "drivetrain.h",
266 ],
267 deps = [
268 ":down_estimator",
269 ":drivetrain_queue",
270 ":gear",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800271 ":line_follow_drivetrain",
James Kuszmaul3431d622019-02-17 17:07:44 -0800272 ":localizer",
James Kuszmaulef428a02019-03-02 22:19:41 -0800273 ":localizer_queue",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700274 ":polydrivetrain",
Alex Perry731b4602019-02-02 22:13:01 -0800275 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800276 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700277 "//aos/controls:control_loop",
278 "//aos/logging:matrix_logging",
279 "//aos/logging:queue_logging",
280 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800281 "//frc971/control_loops:runge_kutta",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700282 "//frc971/queues:gyro",
283 "//frc971/wpilib:imu_queue",
284 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000285)
286
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800287cc_library(
288 name = "drivetrain_test_lib",
289 testonly = True,
290 srcs = ["drivetrain_test_lib.cc"],
291 hdrs = ["drivetrain_test_lib.h"],
292 deps = [
293 ":drivetrain_config",
294 ":drivetrain_queue",
295 ":trajectory",
296 "//aos/testing:googletest",
297 "//frc971/control_loops:state_feedback_loop",
298 "//frc971/queues:gyro",
299 "//y2016:constants",
300 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
301 ],
302)
303
Comran Morshed5323ecb2015-12-26 20:50:55 +0000304cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700305 name = "drivetrain_lib_test",
306 srcs = [
307 "drivetrain_lib_test.cc",
308 ],
Alex Perry04300d62019-02-17 14:37:04 -0800309 defines =
310 cpu_select({
311 "amd64": [
312 "SUPPORT_PLOT=1",
313 ],
314 "arm": [],
315 }),
316 linkstatic = True,
Austin Schuhbcce26a2018-03-26 23:41:24 -0700317 deps = [
318 ":drivetrain_config",
319 ":drivetrain_lib",
James Kuszmaulef428a02019-03-02 22:19:41 -0800320 ":localizer_queue",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700321 ":drivetrain_queue",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800322 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700323 "//aos:queues",
324 "//aos/controls:control_loop_test",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700325 "//aos/testing:googletest",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700326 "//frc971/queues:gyro",
Alex Perry04300d62019-02-17 14:37:04 -0800327 ] + cpu_select({
328 "amd64": [
329 "//third_party/matplotlib-cpp",
330 ],
331 "arm": [],
332 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000333)
Brian Silverman6260c092018-01-14 15:21:36 -0800334
335genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700336 name = "genrule_haptic_wheel",
337 outs = [
338 "haptic_wheel.h",
339 "haptic_wheel.cc",
340 "integral_haptic_wheel.h",
341 "integral_haptic_wheel.cc",
342 "haptic_trigger.h",
343 "haptic_trigger.cc",
344 "integral_haptic_trigger.h",
345 "integral_haptic_trigger.cc",
346 ],
347 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
348 compatible_with = mcu_cpus,
349 tools = [
350 "//frc971/control_loops/python:haptic_wheel",
351 ],
352 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800353)
354
355cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700356 name = "haptic_input_uc",
357 srcs = [
358 "haptic_trigger.cc",
359 "haptic_wheel.cc",
360 "integral_haptic_trigger.cc",
361 "integral_haptic_wheel.cc",
362 ],
363 hdrs = [
364 "haptic_trigger.h",
365 "haptic_wheel.h",
366 "integral_haptic_trigger.h",
367 "integral_haptic_wheel.h",
368 ],
369 restricted_to = mcu_cpus,
370 deps = [
371 "//frc971/control_loops:state_feedback_loop_uc",
372 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800373)
374
375cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700376 name = "haptic_wheel",
377 srcs = [
378 "haptic_trigger.cc",
379 "haptic_wheel.cc",
380 "integral_haptic_trigger.cc",
381 "integral_haptic_wheel.cc",
382 ],
383 hdrs = [
384 "haptic_trigger.h",
385 "haptic_wheel.h",
386 "integral_haptic_trigger.h",
387 "integral_haptic_wheel.h",
388 ],
389 deps = [
390 "//frc971/control_loops:state_feedback_loop",
391 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800392)
Austin Schuhc2b08772018-12-19 18:05:06 +1100393
394cc_library(
395 name = "spline",
396 srcs = ["spline.cc"],
397 hdrs = ["spline.h"],
398 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800399 "//frc971/control_loops:binomial",
Austin Schuhc2b08772018-12-19 18:05:06 +1100400 "//third_party/eigen",
401 ],
402)
403
Alex Perrya60da442019-01-21 19:00:27 -0500404cc_binary(
405 name = "spline.so",
406 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800407 linkshared = True,
Alex Perrya60da442019-01-21 19:00:27 -0500408 deps = [
409 ":distance_spline",
410 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800411 ":trajectory",
412 "//aos/logging:implementations",
413 "//aos/network:team_number",
Alex Perrya60da442019-01-21 19:00:27 -0500414 "//third_party/eigen",
Alex Perry0603b542019-01-25 20:29:51 -0800415 "//y2019/control_loops/drivetrain:drivetrain_base",
Alex Perrya60da442019-01-21 19:00:27 -0500416 ],
Alex Perrya60da442019-01-21 19:00:27 -0500417)
418
Austin Schuhc2b08772018-12-19 18:05:06 +1100419cc_test(
420 name = "spline_test",
421 srcs = [
422 "spline_test.cc",
423 ],
424 restricted_to = ["//tools:k8"],
425 deps = [
426 ":spline",
427 "//aos/testing:googletest",
428 "//third_party/matplotlib-cpp",
429 "@com_github_gflags_gflags//:gflags",
430 ],
431)
Austin Schuh941b46d2018-12-19 18:06:05 +1100432
433cc_library(
434 name = "distance_spline",
435 srcs = ["distance_spline.cc"],
436 hdrs = ["distance_spline.h"],
437 deps = [
438 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800439 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100440 "//frc971/control_loops:fixed_quadrature",
441 "//third_party/eigen",
442 ],
443)
444
445cc_test(
446 name = "distance_spline_test",
447 srcs = [
448 "distance_spline_test.cc",
449 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800450 defines =
451 cpu_select({
452 "amd64": [
453 "SUPPORT_PLOT=1",
454 ],
455 "arm": [],
456 }),
457 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100458 deps = [
459 ":distance_spline",
460 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800461 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100462 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800463 ] + cpu_select({
464 "amd64": [
465 "//third_party/matplotlib-cpp",
466 ],
467 "arm": [],
468 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100469)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100470
471cc_library(
472 name = "trajectory",
473 srcs = ["trajectory.cc"],
474 hdrs = ["trajectory.h"],
475 deps = [
476 ":distance_spline",
477 ":drivetrain_config",
478 "//aos/logging:matrix_logging",
479 "//frc971/control_loops:c2d",
480 "//frc971/control_loops:dlqr",
481 "//frc971/control_loops:hybrid_state_feedback_loop",
482 "//frc971/control_loops:runge_kutta",
483 "//frc971/control_loops:state_feedback_loop",
484 "//third_party/eigen",
485 ],
486)
487
488cc_binary(
489 name = "trajectory_plot",
490 srcs = [
491 "trajectory_plot.cc",
492 ],
493 restricted_to = ["//tools:k8"],
494 deps = [
495 ":distance_spline",
496 ":trajectory",
497 "//aos/logging:implementations",
498 "//aos/logging:matrix_logging",
499 "//aos/network:team_number",
500 "//third_party/eigen",
501 "//third_party/matplotlib-cpp",
Austin Schuh11043182019-03-23 22:29:12 -0700502 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100503 "@com_github_gflags_gflags//:gflags",
504 ],
505)
506
507cc_test(
508 name = "trajectory_test",
509 srcs = [
510 "trajectory_test.cc",
511 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800512 defines =
513 cpu_select({
514 "amd64": [
515 "SUPPORT_PLOT=1",
516 ],
517 "arm": [],
518 }),
519 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100520 deps = [
521 ":trajectory",
522 "//aos/testing:googletest",
523 "//aos/testing:test_shm",
524 "//y2016:constants",
525 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800526 ] + cpu_select({
527 "amd64": [
528 "//third_party/matplotlib-cpp",
529 ],
530 "arm": [],
531 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100532)