blob: c99053fadfe5c269a58aa0e3f801605a92544cac [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",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -080074 "//frc971/control_loops:pose",
James Kuszmaul3431d622019-02-17 17:07:44 -080075 ],
76)
77
78cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070079 name = "gear",
80 hdrs = [
81 "gear.h",
82 ],
83 compatible_with = mcu_cpus,
Austin Schuh093535c2016-03-05 23:21:00 -080084)
85
86cc_library(
Alex Perry731b4602019-02-02 22:13:01 -080087 name = "splinedrivetrain",
88 srcs = [
89 "splinedrivetrain.cc",
90 ],
91 hdrs = [
92 "splinedrivetrain.h",
93 ],
94 deps = [
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -080095 ":distance_spline",
Alex Perry731b4602019-02-02 22:13:01 -080096 ":drivetrain_config",
97 ":drivetrain_queue",
98 ":spline",
Alex Perry731b4602019-02-02 22:13:01 -080099 ":trajectory",
Alex Perry1ec34522019-02-17 22:44:10 -0800100 "//aos:init",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800101 ],
Alex Perry731b4602019-02-02 22:13:01 -0800102)
103
104cc_library(
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800105 name = "line_follow_drivetrain",
106 srcs = [
107 "line_follow_drivetrain.cc",
108 ],
109 hdrs = [
110 "line_follow_drivetrain.h",
111 ],
112 deps = [
113 ":drivetrain_config",
114 ":drivetrain_queue",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800115 ":localizer",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800116 "//aos:math",
117 "//aos/util:math",
118 "//frc971/control_loops:c2d",
119 "//frc971/control_loops:dlqr",
120 "//frc971/control_loops:pose",
121 "//third_party/eigen",
122 ],
123)
124
125cc_test(
126 name = "line_follow_drivetrain_test",
127 srcs = ["line_follow_drivetrain_test.cc"],
128 linkstatic = True,
129 restricted_to = ["//tools:k8"],
130 deps = [
131 ":drivetrain_config",
132 ":drivetrain_test_lib",
133 ":line_follow_drivetrain",
134 ":trajectory",
135 "//aos/testing:googletest",
136 "//aos/testing:test_shm",
137 "//third_party/matplotlib-cpp",
138 "@com_github_gflags_gflags//:gflags",
139 ],
140)
141
142cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700143 name = "ssdrivetrain",
144 srcs = [
145 "ssdrivetrain.cc",
146 ],
147 hdrs = [
148 "ssdrivetrain.h",
149 ],
150 deps = [
151 ":drivetrain_config",
152 ":drivetrain_queue",
153 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800154 ":localizer",
John Park33858a32018-09-28 23:05:48 -0700155 "//aos:math",
156 "//aos/controls:control_loop",
157 "//aos/controls:polytope",
158 "//aos/logging:matrix_logging",
159 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100160 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700161 "//aos/util:log_interval",
162 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700163 "//frc971:shifter_hall_effect",
164 "//frc971/control_loops:coerce_goal",
165 "//frc971/control_loops:state_feedback_loop",
166 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000167)
168
169cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700170 name = "polydrivetrain",
171 srcs = [
172 "polydrivetrain.cc",
173 ],
174 hdrs = [
175 "polydrivetrain.h",
176 ],
177 deps = [
178 ":drivetrain_config",
179 ":drivetrain_queue",
180 ":gear",
John Park33858a32018-09-28 23:05:48 -0700181 "//aos:math",
182 "//aos/controls:polytope",
183 "//aos/logging:matrix_logging",
184 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100185 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700186 "//aos/util:log_interval",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700187 "//frc971/control_loops:coerce_goal",
188 "//frc971/control_loops:state_feedback_loop",
189 ],
190)
191
192cc_library(
193 name = "drivetrain_config_uc",
194 hdrs = [
195 "drivetrain_config.h",
196 ],
197 restricted_to = mcu_cpus,
198 deps = [
199 "//frc971:shifter_hall_effect",
200 "//frc971/control_loops:state_feedback_loop_uc",
201 ],
202)
203
204cc_library(
205 name = "polydrivetrain_uc",
206 srcs = [
207 "drivetrain_uc.q.cc",
208 "polydrivetrain.cc",
209 ],
210 hdrs = [
211 "drivetrain_uc.q.h",
212 "polydrivetrain.h",
213 ],
214 restricted_to = mcu_cpus,
215 deps = [
216 ":drivetrain_config_uc",
217 ":gear",
John Park33858a32018-09-28 23:05:48 -0700218 "//aos:math",
219 "//aos/controls:polytope_uc",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700220 "//frc971/control_loops:coerce_goal_uc",
221 "//frc971/control_loops:state_feedback_loop_uc",
222 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000223)
224
Austin Schuh05c5a612016-04-02 15:10:25 -0700225genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700226 name = "genrule_down_estimator",
227 outs = [
228 "down_estimator.h",
229 "down_estimator.cc",
230 ],
231 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
232 tools = [
233 "//frc971/control_loops/python:down_estimator",
234 ],
235 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700236)
237
238cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700239 name = "down_estimator",
240 srcs = [
241 "down_estimator.cc",
242 ],
243 hdrs = [
244 "down_estimator.h",
245 ],
246 deps = [
247 "//frc971/control_loops:state_feedback_loop",
248 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700249)
250
Comran Morshed5323ecb2015-12-26 20:50:55 +0000251cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700252 name = "drivetrain_lib",
253 srcs = [
254 "drivetrain.cc",
255 ],
256 hdrs = [
257 "drivetrain.h",
258 ],
259 deps = [
260 ":down_estimator",
261 ":drivetrain_queue",
262 ":gear",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800263 ":line_follow_drivetrain",
James Kuszmaul3431d622019-02-17 17:07:44 -0800264 ":localizer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700265 ":polydrivetrain",
Alex Perry731b4602019-02-02 22:13:01 -0800266 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800267 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700268 "//aos/controls:control_loop",
269 "//aos/logging:matrix_logging",
270 "//aos/logging:queue_logging",
271 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800272 "//frc971/control_loops:runge_kutta",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700273 "//frc971/queues:gyro",
274 "//frc971/wpilib:imu_queue",
275 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000276)
277
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800278cc_library(
279 name = "drivetrain_test_lib",
280 testonly = True,
281 srcs = ["drivetrain_test_lib.cc"],
282 hdrs = ["drivetrain_test_lib.h"],
283 deps = [
284 ":drivetrain_config",
285 ":drivetrain_queue",
286 ":trajectory",
287 "//aos/testing:googletest",
288 "//frc971/control_loops:state_feedback_loop",
289 "//frc971/queues:gyro",
290 "//y2016:constants",
291 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
292 ],
293)
294
Comran Morshed5323ecb2015-12-26 20:50:55 +0000295cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700296 name = "drivetrain_lib_test",
297 srcs = [
298 "drivetrain_lib_test.cc",
299 ],
Alex Perry04300d62019-02-17 14:37:04 -0800300 defines =
301 cpu_select({
302 "amd64": [
303 "SUPPORT_PLOT=1",
304 ],
305 "arm": [],
306 }),
307 linkstatic = True,
Austin Schuhbcce26a2018-03-26 23:41:24 -0700308 deps = [
309 ":drivetrain_config",
310 ":drivetrain_lib",
311 ":drivetrain_queue",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800312 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700313 "//aos:queues",
314 "//aos/controls:control_loop_test",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700315 "//aos/testing:googletest",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700316 "//frc971/queues:gyro",
Alex Perry04300d62019-02-17 14:37:04 -0800317 ] + cpu_select({
318 "amd64": [
319 "//third_party/matplotlib-cpp",
320 ],
321 "arm": [],
322 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000323)
Brian Silverman6260c092018-01-14 15:21:36 -0800324
325genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700326 name = "genrule_haptic_wheel",
327 outs = [
328 "haptic_wheel.h",
329 "haptic_wheel.cc",
330 "integral_haptic_wheel.h",
331 "integral_haptic_wheel.cc",
332 "haptic_trigger.h",
333 "haptic_trigger.cc",
334 "integral_haptic_trigger.h",
335 "integral_haptic_trigger.cc",
336 ],
337 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
338 compatible_with = mcu_cpus,
339 tools = [
340 "//frc971/control_loops/python:haptic_wheel",
341 ],
342 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800343)
344
345cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700346 name = "haptic_input_uc",
347 srcs = [
348 "haptic_trigger.cc",
349 "haptic_wheel.cc",
350 "integral_haptic_trigger.cc",
351 "integral_haptic_wheel.cc",
352 ],
353 hdrs = [
354 "haptic_trigger.h",
355 "haptic_wheel.h",
356 "integral_haptic_trigger.h",
357 "integral_haptic_wheel.h",
358 ],
359 restricted_to = mcu_cpus,
360 deps = [
361 "//frc971/control_loops:state_feedback_loop_uc",
362 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800363)
364
365cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700366 name = "haptic_wheel",
367 srcs = [
368 "haptic_trigger.cc",
369 "haptic_wheel.cc",
370 "integral_haptic_trigger.cc",
371 "integral_haptic_wheel.cc",
372 ],
373 hdrs = [
374 "haptic_trigger.h",
375 "haptic_wheel.h",
376 "integral_haptic_trigger.h",
377 "integral_haptic_wheel.h",
378 ],
379 deps = [
380 "//frc971/control_loops:state_feedback_loop",
381 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800382)
Austin Schuhc2b08772018-12-19 18:05:06 +1100383
384cc_library(
385 name = "spline",
386 srcs = ["spline.cc"],
387 hdrs = ["spline.h"],
388 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800389 "//frc971/control_loops:binomial",
Austin Schuhc2b08772018-12-19 18:05:06 +1100390 "//third_party/eigen",
391 ],
392)
393
Alex Perrya60da442019-01-21 19:00:27 -0500394cc_binary(
395 name = "spline.so",
396 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800397 linkshared = True,
Alex Perrya60da442019-01-21 19:00:27 -0500398 deps = [
399 ":distance_spline",
400 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800401 ":trajectory",
402 "//aos/logging:implementations",
403 "//aos/network:team_number",
Alex Perrya60da442019-01-21 19:00:27 -0500404 "//third_party/eigen",
Alex Perry0603b542019-01-25 20:29:51 -0800405 "//y2019/control_loops/drivetrain:drivetrain_base",
Alex Perrya60da442019-01-21 19:00:27 -0500406 ],
Alex Perrya60da442019-01-21 19:00:27 -0500407)
408
Austin Schuhc2b08772018-12-19 18:05:06 +1100409cc_test(
410 name = "spline_test",
411 srcs = [
412 "spline_test.cc",
413 ],
414 restricted_to = ["//tools:k8"],
415 deps = [
416 ":spline",
417 "//aos/testing:googletest",
418 "//third_party/matplotlib-cpp",
419 "@com_github_gflags_gflags//:gflags",
420 ],
421)
Austin Schuh941b46d2018-12-19 18:06:05 +1100422
423cc_library(
424 name = "distance_spline",
425 srcs = ["distance_spline.cc"],
426 hdrs = ["distance_spline.h"],
427 deps = [
428 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800429 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100430 "//frc971/control_loops:fixed_quadrature",
431 "//third_party/eigen",
432 ],
433)
434
435cc_test(
436 name = "distance_spline_test",
437 srcs = [
438 "distance_spline_test.cc",
439 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800440 defines =
441 cpu_select({
442 "amd64": [
443 "SUPPORT_PLOT=1",
444 ],
445 "arm": [],
446 }),
447 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100448 deps = [
449 ":distance_spline",
450 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800451 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100452 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800453 ] + cpu_select({
454 "amd64": [
455 "//third_party/matplotlib-cpp",
456 ],
457 "arm": [],
458 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100459)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100460
461cc_library(
462 name = "trajectory",
463 srcs = ["trajectory.cc"],
464 hdrs = ["trajectory.h"],
465 deps = [
466 ":distance_spline",
467 ":drivetrain_config",
468 "//aos/logging:matrix_logging",
469 "//frc971/control_loops:c2d",
470 "//frc971/control_loops:dlqr",
471 "//frc971/control_loops:hybrid_state_feedback_loop",
472 "//frc971/control_loops:runge_kutta",
473 "//frc971/control_loops:state_feedback_loop",
474 "//third_party/eigen",
475 ],
476)
477
478cc_binary(
479 name = "trajectory_plot",
480 srcs = [
481 "trajectory_plot.cc",
482 ],
483 restricted_to = ["//tools:k8"],
484 deps = [
485 ":distance_spline",
486 ":trajectory",
487 "//aos/logging:implementations",
488 "//aos/logging:matrix_logging",
489 "//aos/network:team_number",
490 "//third_party/eigen",
491 "//third_party/matplotlib-cpp",
492 "//y2016/control_loops/drivetrain:drivetrain_base",
493 "@com_github_gflags_gflags//:gflags",
494 ],
495)
496
497cc_test(
498 name = "trajectory_test",
499 srcs = [
500 "trajectory_test.cc",
501 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800502 defines =
503 cpu_select({
504 "amd64": [
505 "SUPPORT_PLOT=1",
506 ],
507 "arm": [],
508 }),
509 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100510 deps = [
511 ":trajectory",
512 "//aos/testing:googletest",
513 "//aos/testing:test_shm",
514 "//y2016:constants",
515 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800516 ] + cpu_select({
517 "amd64": [
518 "//third_party/matplotlib-cpp",
519 ],
520 "arm": [],
521 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100522)