blob: 9b0400e2551fb2ce040d6e9229c8081fbc5c2516 [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",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -080099 ],
Alex Perry731b4602019-02-02 22:13:01 -0800100)
101
102cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700103 name = "ssdrivetrain",
104 srcs = [
105 "ssdrivetrain.cc",
106 ],
107 hdrs = [
108 "ssdrivetrain.h",
109 ],
110 deps = [
111 ":drivetrain_config",
112 ":drivetrain_queue",
113 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800114 ":localizer",
John Park33858a32018-09-28 23:05:48 -0700115 "//aos:math",
116 "//aos/controls:control_loop",
117 "//aos/controls:polytope",
118 "//aos/logging:matrix_logging",
119 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100120 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700121 "//aos/util:log_interval",
122 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700123 "//frc971:shifter_hall_effect",
124 "//frc971/control_loops:coerce_goal",
125 "//frc971/control_loops:state_feedback_loop",
126 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000127)
128
129cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700130 name = "polydrivetrain",
131 srcs = [
132 "polydrivetrain.cc",
133 ],
134 hdrs = [
135 "polydrivetrain.h",
136 ],
137 deps = [
138 ":drivetrain_config",
139 ":drivetrain_queue",
140 ":gear",
John Park33858a32018-09-28 23:05:48 -0700141 "//aos:math",
142 "//aos/controls:polytope",
143 "//aos/logging:matrix_logging",
144 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100145 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700146 "//aos/util:log_interval",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700147 "//frc971/control_loops:coerce_goal",
148 "//frc971/control_loops:state_feedback_loop",
149 ],
150)
151
152cc_library(
153 name = "drivetrain_config_uc",
154 hdrs = [
155 "drivetrain_config.h",
156 ],
157 restricted_to = mcu_cpus,
158 deps = [
159 "//frc971:shifter_hall_effect",
160 "//frc971/control_loops:state_feedback_loop_uc",
161 ],
162)
163
164cc_library(
165 name = "polydrivetrain_uc",
166 srcs = [
167 "drivetrain_uc.q.cc",
168 "polydrivetrain.cc",
169 ],
170 hdrs = [
171 "drivetrain_uc.q.h",
172 "polydrivetrain.h",
173 ],
174 restricted_to = mcu_cpus,
175 deps = [
176 ":drivetrain_config_uc",
177 ":gear",
John Park33858a32018-09-28 23:05:48 -0700178 "//aos:math",
179 "//aos/controls:polytope_uc",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700180 "//frc971/control_loops:coerce_goal_uc",
181 "//frc971/control_loops:state_feedback_loop_uc",
182 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000183)
184
Austin Schuh05c5a612016-04-02 15:10:25 -0700185genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700186 name = "genrule_down_estimator",
187 outs = [
188 "down_estimator.h",
189 "down_estimator.cc",
190 ],
191 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
192 tools = [
193 "//frc971/control_loops/python:down_estimator",
194 ],
195 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700196)
197
198cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700199 name = "down_estimator",
200 srcs = [
201 "down_estimator.cc",
202 ],
203 hdrs = [
204 "down_estimator.h",
205 ],
206 deps = [
207 "//frc971/control_loops:state_feedback_loop",
208 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700209)
210
Comran Morshed5323ecb2015-12-26 20:50:55 +0000211cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700212 name = "drivetrain_lib",
213 srcs = [
214 "drivetrain.cc",
215 ],
216 hdrs = [
217 "drivetrain.h",
218 ],
219 deps = [
220 ":down_estimator",
221 ":drivetrain_queue",
222 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800223 ":localizer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700224 ":polydrivetrain",
Alex Perry731b4602019-02-02 22:13:01 -0800225 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800226 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700227 "//aos/controls:control_loop",
228 "//aos/logging:matrix_logging",
229 "//aos/logging:queue_logging",
230 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800231 "//frc971/control_loops:runge_kutta",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700232 "//frc971/queues:gyro",
233 "//frc971/wpilib:imu_queue",
234 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000235)
236
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800237cc_library(
238 name = "drivetrain_test_lib",
239 testonly = True,
240 srcs = ["drivetrain_test_lib.cc"],
241 hdrs = ["drivetrain_test_lib.h"],
242 deps = [
243 ":drivetrain_config",
244 ":drivetrain_queue",
245 ":trajectory",
246 "//aos/testing:googletest",
247 "//frc971/control_loops:state_feedback_loop",
248 "//frc971/queues:gyro",
249 "//y2016:constants",
250 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
251 ],
252)
253
Comran Morshed5323ecb2015-12-26 20:50:55 +0000254cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700255 name = "drivetrain_lib_test",
256 srcs = [
257 "drivetrain_lib_test.cc",
258 ],
Alex Perry04300d62019-02-17 14:37:04 -0800259 defines =
260 cpu_select({
261 "amd64": [
262 "SUPPORT_PLOT=1",
263 ],
264 "arm": [],
265 }),
266 linkstatic = True,
Austin Schuhbcce26a2018-03-26 23:41:24 -0700267 deps = [
268 ":drivetrain_config",
269 ":drivetrain_lib",
270 ":drivetrain_queue",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800271 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700272 "//aos:queues",
273 "//aos/controls:control_loop_test",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700274 "//aos/testing:googletest",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700275 "//frc971/queues:gyro",
Alex Perry04300d62019-02-17 14:37:04 -0800276 ] + cpu_select({
277 "amd64": [
278 "//third_party/matplotlib-cpp",
279 ],
280 "arm": [],
281 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000282)
Brian Silverman6260c092018-01-14 15:21:36 -0800283
284genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700285 name = "genrule_haptic_wheel",
286 outs = [
287 "haptic_wheel.h",
288 "haptic_wheel.cc",
289 "integral_haptic_wheel.h",
290 "integral_haptic_wheel.cc",
291 "haptic_trigger.h",
292 "haptic_trigger.cc",
293 "integral_haptic_trigger.h",
294 "integral_haptic_trigger.cc",
295 ],
296 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
297 compatible_with = mcu_cpus,
298 tools = [
299 "//frc971/control_loops/python:haptic_wheel",
300 ],
301 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800302)
303
304cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700305 name = "haptic_input_uc",
306 srcs = [
307 "haptic_trigger.cc",
308 "haptic_wheel.cc",
309 "integral_haptic_trigger.cc",
310 "integral_haptic_wheel.cc",
311 ],
312 hdrs = [
313 "haptic_trigger.h",
314 "haptic_wheel.h",
315 "integral_haptic_trigger.h",
316 "integral_haptic_wheel.h",
317 ],
318 restricted_to = mcu_cpus,
319 deps = [
320 "//frc971/control_loops:state_feedback_loop_uc",
321 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800322)
323
324cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700325 name = "haptic_wheel",
326 srcs = [
327 "haptic_trigger.cc",
328 "haptic_wheel.cc",
329 "integral_haptic_trigger.cc",
330 "integral_haptic_wheel.cc",
331 ],
332 hdrs = [
333 "haptic_trigger.h",
334 "haptic_wheel.h",
335 "integral_haptic_trigger.h",
336 "integral_haptic_wheel.h",
337 ],
338 deps = [
339 "//frc971/control_loops:state_feedback_loop",
340 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800341)
Austin Schuhc2b08772018-12-19 18:05:06 +1100342
343cc_library(
344 name = "spline",
345 srcs = ["spline.cc"],
346 hdrs = ["spline.h"],
347 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800348 "//frc971/control_loops:binomial",
Austin Schuhc2b08772018-12-19 18:05:06 +1100349 "//third_party/eigen",
350 ],
351)
352
Alex Perrya60da442019-01-21 19:00:27 -0500353cc_binary(
354 name = "spline.so",
355 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800356 linkshared = True,
Alex Perrya60da442019-01-21 19:00:27 -0500357 deps = [
358 ":distance_spline",
359 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800360 ":trajectory",
361 "//aos/logging:implementations",
362 "//aos/network:team_number",
Alex Perrya60da442019-01-21 19:00:27 -0500363 "//third_party/eigen",
Alex Perry0603b542019-01-25 20:29:51 -0800364 "//y2019/control_loops/drivetrain:drivetrain_base",
Alex Perrya60da442019-01-21 19:00:27 -0500365 ],
Alex Perrya60da442019-01-21 19:00:27 -0500366)
367
Austin Schuhc2b08772018-12-19 18:05:06 +1100368cc_test(
369 name = "spline_test",
370 srcs = [
371 "spline_test.cc",
372 ],
373 restricted_to = ["//tools:k8"],
374 deps = [
375 ":spline",
376 "//aos/testing:googletest",
377 "//third_party/matplotlib-cpp",
378 "@com_github_gflags_gflags//:gflags",
379 ],
380)
Austin Schuh941b46d2018-12-19 18:06:05 +1100381
382cc_library(
383 name = "distance_spline",
384 srcs = ["distance_spline.cc"],
385 hdrs = ["distance_spline.h"],
386 deps = [
387 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800388 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100389 "//frc971/control_loops:fixed_quadrature",
390 "//third_party/eigen",
391 ],
392)
393
394cc_test(
395 name = "distance_spline_test",
396 srcs = [
397 "distance_spline_test.cc",
398 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800399 defines =
400 cpu_select({
401 "amd64": [
402 "SUPPORT_PLOT=1",
403 ],
404 "arm": [],
405 }),
406 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100407 deps = [
408 ":distance_spline",
409 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800410 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100411 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800412 ] + cpu_select({
413 "amd64": [
414 "//third_party/matplotlib-cpp",
415 ],
416 "arm": [],
417 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100418)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100419
420cc_library(
421 name = "trajectory",
422 srcs = ["trajectory.cc"],
423 hdrs = ["trajectory.h"],
424 deps = [
425 ":distance_spline",
426 ":drivetrain_config",
427 "//aos/logging:matrix_logging",
428 "//frc971/control_loops:c2d",
429 "//frc971/control_loops:dlqr",
430 "//frc971/control_loops:hybrid_state_feedback_loop",
431 "//frc971/control_loops:runge_kutta",
432 "//frc971/control_loops:state_feedback_loop",
433 "//third_party/eigen",
434 ],
435)
436
437cc_binary(
438 name = "trajectory_plot",
439 srcs = [
440 "trajectory_plot.cc",
441 ],
442 restricted_to = ["//tools:k8"],
443 deps = [
444 ":distance_spline",
445 ":trajectory",
446 "//aos/logging:implementations",
447 "//aos/logging:matrix_logging",
448 "//aos/network:team_number",
449 "//third_party/eigen",
450 "//third_party/matplotlib-cpp",
451 "//y2016/control_loops/drivetrain:drivetrain_base",
452 "@com_github_gflags_gflags//:gflags",
453 ],
454)
455
456cc_test(
457 name = "trajectory_test",
458 srcs = [
459 "trajectory_test.cc",
460 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800461 defines =
462 cpu_select({
463 "amd64": [
464 "SUPPORT_PLOT=1",
465 ],
466 "arm": [],
467 }),
468 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100469 deps = [
470 ":trajectory",
471 "//aos/testing:googletest",
472 "//aos/testing:test_shm",
473 "//y2016:constants",
474 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800475 ] + cpu_select({
476 "amd64": [
477 "//third_party/matplotlib-cpp",
478 ],
479 "arm": [],
480 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100481)