blob: 7dedc71fc235bc612e05c4551797edd231830e70 [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
68cc_library(
James Kuszmaul3431d622019-02-17 17:07:44 -080069 name = "localizer",
70 hdrs = ["localizer.h"],
71 deps = [
72 ":drivetrain_config",
73 ":hybrid_ekf",
74 ],
75)
76
77cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070078 name = "gear",
79 hdrs = [
80 "gear.h",
81 ],
82 compatible_with = mcu_cpus,
Austin Schuh093535c2016-03-05 23:21:00 -080083)
84
85cc_library(
Alex Perry731b4602019-02-02 22:13:01 -080086 name = "splinedrivetrain",
87 srcs = [
88 "splinedrivetrain.cc",
89 ],
90 hdrs = [
91 "splinedrivetrain.h",
92 ],
93 deps = [
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -080094 ":distance_spline",
Alex Perry731b4602019-02-02 22:13:01 -080095 ":drivetrain_config",
96 ":drivetrain_queue",
97 ":spline",
Alex Perry731b4602019-02-02 22:13:01 -080098 ":trajectory",
Alex Perry1ec34522019-02-17 22:44:10 -080099 "//aos:init",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800100 ],
Alex Perry731b4602019-02-02 22:13:01 -0800101)
102
103cc_library(
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800104 name = "line_follow_drivetrain",
105 srcs = [
106 "line_follow_drivetrain.cc",
107 ],
108 hdrs = [
109 "line_follow_drivetrain.h",
110 ],
111 deps = [
112 ":drivetrain_config",
113 ":drivetrain_queue",
114 "//aos:math",
115 "//aos/util:math",
116 "//frc971/control_loops:c2d",
117 "//frc971/control_loops:dlqr",
118 "//frc971/control_loops:pose",
119 "//third_party/eigen",
120 ],
121)
122
123cc_test(
124 name = "line_follow_drivetrain_test",
125 srcs = ["line_follow_drivetrain_test.cc"],
126 linkstatic = True,
127 restricted_to = ["//tools:k8"],
128 deps = [
129 ":drivetrain_config",
130 ":drivetrain_test_lib",
131 ":line_follow_drivetrain",
132 ":trajectory",
133 "//aos/testing:googletest",
134 "//aos/testing:test_shm",
135 "//third_party/matplotlib-cpp",
136 "@com_github_gflags_gflags//:gflags",
137 ],
138)
139
140cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700141 name = "ssdrivetrain",
142 srcs = [
143 "ssdrivetrain.cc",
144 ],
145 hdrs = [
146 "ssdrivetrain.h",
147 ],
148 deps = [
149 ":drivetrain_config",
150 ":drivetrain_queue",
151 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800152 ":localizer",
John Park33858a32018-09-28 23:05:48 -0700153 "//aos:math",
154 "//aos/controls:control_loop",
155 "//aos/controls:polytope",
156 "//aos/logging:matrix_logging",
157 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100158 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700159 "//aos/util:log_interval",
160 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700161 "//frc971:shifter_hall_effect",
162 "//frc971/control_loops:coerce_goal",
163 "//frc971/control_loops:state_feedback_loop",
164 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000165)
166
167cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700168 name = "polydrivetrain",
169 srcs = [
170 "polydrivetrain.cc",
171 ],
172 hdrs = [
173 "polydrivetrain.h",
174 ],
175 deps = [
176 ":drivetrain_config",
177 ":drivetrain_queue",
178 ":gear",
John Park33858a32018-09-28 23:05:48 -0700179 "//aos:math",
180 "//aos/controls:polytope",
181 "//aos/logging:matrix_logging",
182 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100183 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700184 "//aos/util:log_interval",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700185 "//frc971/control_loops:coerce_goal",
186 "//frc971/control_loops:state_feedback_loop",
187 ],
188)
189
190cc_library(
191 name = "drivetrain_config_uc",
192 hdrs = [
193 "drivetrain_config.h",
194 ],
195 restricted_to = mcu_cpus,
196 deps = [
197 "//frc971:shifter_hall_effect",
198 "//frc971/control_loops:state_feedback_loop_uc",
199 ],
200)
201
202cc_library(
203 name = "polydrivetrain_uc",
204 srcs = [
205 "drivetrain_uc.q.cc",
206 "polydrivetrain.cc",
207 ],
208 hdrs = [
209 "drivetrain_uc.q.h",
210 "polydrivetrain.h",
211 ],
212 restricted_to = mcu_cpus,
213 deps = [
214 ":drivetrain_config_uc",
215 ":gear",
John Park33858a32018-09-28 23:05:48 -0700216 "//aos:math",
217 "//aos/controls:polytope_uc",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700218 "//frc971/control_loops:coerce_goal_uc",
219 "//frc971/control_loops:state_feedback_loop_uc",
220 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000221)
222
Austin Schuh05c5a612016-04-02 15:10:25 -0700223genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700224 name = "genrule_down_estimator",
225 outs = [
226 "down_estimator.h",
227 "down_estimator.cc",
228 ],
229 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
230 tools = [
231 "//frc971/control_loops/python:down_estimator",
232 ],
233 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700234)
235
236cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700237 name = "down_estimator",
238 srcs = [
239 "down_estimator.cc",
240 ],
241 hdrs = [
242 "down_estimator.h",
243 ],
244 deps = [
245 "//frc971/control_loops:state_feedback_loop",
246 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700247)
248
Comran Morshed5323ecb2015-12-26 20:50:55 +0000249cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700250 name = "drivetrain_lib",
251 srcs = [
252 "drivetrain.cc",
253 ],
254 hdrs = [
255 "drivetrain.h",
256 ],
257 deps = [
258 ":down_estimator",
259 ":drivetrain_queue",
260 ":gear",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800261 ":line_follow_drivetrain",
James Kuszmaul3431d622019-02-17 17:07:44 -0800262 ":localizer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700263 ":polydrivetrain",
Alex Perry731b4602019-02-02 22:13:01 -0800264 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800265 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700266 "//aos/controls:control_loop",
267 "//aos/logging:matrix_logging",
268 "//aos/logging:queue_logging",
269 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800270 "//frc971/control_loops:runge_kutta",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700271 "//frc971/queues:gyro",
272 "//frc971/wpilib:imu_queue",
273 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000274)
275
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800276cc_library(
277 name = "drivetrain_test_lib",
278 testonly = True,
279 srcs = ["drivetrain_test_lib.cc"],
280 hdrs = ["drivetrain_test_lib.h"],
281 deps = [
282 ":drivetrain_config",
283 ":drivetrain_queue",
284 ":trajectory",
285 "//aos/testing:googletest",
286 "//frc971/control_loops:state_feedback_loop",
287 "//frc971/queues:gyro",
288 "//y2016:constants",
289 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
290 ],
291)
292
Comran Morshed5323ecb2015-12-26 20:50:55 +0000293cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700294 name = "drivetrain_lib_test",
295 srcs = [
296 "drivetrain_lib_test.cc",
297 ],
Alex Perry04300d62019-02-17 14:37:04 -0800298 defines =
299 cpu_select({
300 "amd64": [
301 "SUPPORT_PLOT=1",
302 ],
303 "arm": [],
304 }),
305 linkstatic = True,
Austin Schuhbcce26a2018-03-26 23:41:24 -0700306 deps = [
307 ":drivetrain_config",
308 ":drivetrain_lib",
309 ":drivetrain_queue",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800310 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700311 "//aos:queues",
312 "//aos/controls:control_loop_test",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700313 "//aos/testing:googletest",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700314 "//frc971/queues:gyro",
Alex Perry04300d62019-02-17 14:37:04 -0800315 ] + cpu_select({
316 "amd64": [
317 "//third_party/matplotlib-cpp",
318 ],
319 "arm": [],
320 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000321)
Brian Silverman6260c092018-01-14 15:21:36 -0800322
323genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700324 name = "genrule_haptic_wheel",
325 outs = [
326 "haptic_wheel.h",
327 "haptic_wheel.cc",
328 "integral_haptic_wheel.h",
329 "integral_haptic_wheel.cc",
330 "haptic_trigger.h",
331 "haptic_trigger.cc",
332 "integral_haptic_trigger.h",
333 "integral_haptic_trigger.cc",
334 ],
335 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
336 compatible_with = mcu_cpus,
337 tools = [
338 "//frc971/control_loops/python:haptic_wheel",
339 ],
340 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800341)
342
343cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700344 name = "haptic_input_uc",
345 srcs = [
346 "haptic_trigger.cc",
347 "haptic_wheel.cc",
348 "integral_haptic_trigger.cc",
349 "integral_haptic_wheel.cc",
350 ],
351 hdrs = [
352 "haptic_trigger.h",
353 "haptic_wheel.h",
354 "integral_haptic_trigger.h",
355 "integral_haptic_wheel.h",
356 ],
357 restricted_to = mcu_cpus,
358 deps = [
359 "//frc971/control_loops:state_feedback_loop_uc",
360 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800361)
362
363cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700364 name = "haptic_wheel",
365 srcs = [
366 "haptic_trigger.cc",
367 "haptic_wheel.cc",
368 "integral_haptic_trigger.cc",
369 "integral_haptic_wheel.cc",
370 ],
371 hdrs = [
372 "haptic_trigger.h",
373 "haptic_wheel.h",
374 "integral_haptic_trigger.h",
375 "integral_haptic_wheel.h",
376 ],
377 deps = [
378 "//frc971/control_loops:state_feedback_loop",
379 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800380)
Austin Schuhc2b08772018-12-19 18:05:06 +1100381
382cc_library(
383 name = "spline",
384 srcs = ["spline.cc"],
385 hdrs = ["spline.h"],
386 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800387 "//frc971/control_loops:binomial",
Austin Schuhc2b08772018-12-19 18:05:06 +1100388 "//third_party/eigen",
389 ],
390)
391
Alex Perrya60da442019-01-21 19:00:27 -0500392cc_binary(
393 name = "spline.so",
394 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800395 linkshared = True,
Alex Perrya60da442019-01-21 19:00:27 -0500396 deps = [
397 ":distance_spline",
398 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800399 ":trajectory",
400 "//aos/logging:implementations",
401 "//aos/network:team_number",
Alex Perrya60da442019-01-21 19:00:27 -0500402 "//third_party/eigen",
Alex Perry0603b542019-01-25 20:29:51 -0800403 "//y2019/control_loops/drivetrain:drivetrain_base",
Alex Perrya60da442019-01-21 19:00:27 -0500404 ],
Alex Perrya60da442019-01-21 19:00:27 -0500405)
406
Austin Schuhc2b08772018-12-19 18:05:06 +1100407cc_test(
408 name = "spline_test",
409 srcs = [
410 "spline_test.cc",
411 ],
412 restricted_to = ["//tools:k8"],
413 deps = [
414 ":spline",
415 "//aos/testing:googletest",
416 "//third_party/matplotlib-cpp",
417 "@com_github_gflags_gflags//:gflags",
418 ],
419)
Austin Schuh941b46d2018-12-19 18:06:05 +1100420
421cc_library(
422 name = "distance_spline",
423 srcs = ["distance_spline.cc"],
424 hdrs = ["distance_spline.h"],
425 deps = [
426 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800427 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100428 "//frc971/control_loops:fixed_quadrature",
429 "//third_party/eigen",
430 ],
431)
432
433cc_test(
434 name = "distance_spline_test",
435 srcs = [
436 "distance_spline_test.cc",
437 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800438 defines =
439 cpu_select({
440 "amd64": [
441 "SUPPORT_PLOT=1",
442 ],
443 "arm": [],
444 }),
445 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100446 deps = [
447 ":distance_spline",
448 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800449 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100450 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800451 ] + cpu_select({
452 "amd64": [
453 "//third_party/matplotlib-cpp",
454 ],
455 "arm": [],
456 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100457)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100458
459cc_library(
460 name = "trajectory",
461 srcs = ["trajectory.cc"],
462 hdrs = ["trajectory.h"],
463 deps = [
464 ":distance_spline",
465 ":drivetrain_config",
466 "//aos/logging:matrix_logging",
467 "//frc971/control_loops:c2d",
468 "//frc971/control_loops:dlqr",
469 "//frc971/control_loops:hybrid_state_feedback_loop",
470 "//frc971/control_loops:runge_kutta",
471 "//frc971/control_loops:state_feedback_loop",
472 "//third_party/eigen",
473 ],
474)
475
476cc_binary(
477 name = "trajectory_plot",
478 srcs = [
479 "trajectory_plot.cc",
480 ],
481 restricted_to = ["//tools:k8"],
482 deps = [
483 ":distance_spline",
484 ":trajectory",
485 "//aos/logging:implementations",
486 "//aos/logging:matrix_logging",
487 "//aos/network:team_number",
488 "//third_party/eigen",
489 "//third_party/matplotlib-cpp",
490 "//y2016/control_loops/drivetrain:drivetrain_base",
491 "@com_github_gflags_gflags//:gflags",
492 ],
493)
494
495cc_test(
496 name = "trajectory_test",
497 srcs = [
498 "trajectory_test.cc",
499 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800500 defines =
501 cpu_select({
502 "amd64": [
503 "SUPPORT_PLOT=1",
504 ],
505 "arm": [],
506 }),
507 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100508 deps = [
509 ":trajectory",
510 "//aos/testing:googletest",
511 "//aos/testing:test_shm",
512 "//y2016:constants",
513 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800514 ] + cpu_select({
515 "amd64": [
516 "//third_party/matplotlib-cpp",
517 ],
518 "arm": [],
519 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100520)