blob: e332cfea6c1aaf0eed371248d3c74d2346773f36 [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(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700104 name = "ssdrivetrain",
105 srcs = [
106 "ssdrivetrain.cc",
107 ],
108 hdrs = [
109 "ssdrivetrain.h",
110 ],
111 deps = [
112 ":drivetrain_config",
113 ":drivetrain_queue",
114 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800115 ":localizer",
John Park33858a32018-09-28 23:05:48 -0700116 "//aos:math",
117 "//aos/controls:control_loop",
118 "//aos/controls:polytope",
119 "//aos/logging:matrix_logging",
120 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100121 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700122 "//aos/util:log_interval",
123 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700124 "//frc971:shifter_hall_effect",
125 "//frc971/control_loops:coerce_goal",
126 "//frc971/control_loops:state_feedback_loop",
127 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000128)
129
130cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700131 name = "polydrivetrain",
132 srcs = [
133 "polydrivetrain.cc",
134 ],
135 hdrs = [
136 "polydrivetrain.h",
137 ],
138 deps = [
139 ":drivetrain_config",
140 ":drivetrain_queue",
141 ":gear",
John Park33858a32018-09-28 23:05:48 -0700142 "//aos:math",
143 "//aos/controls:polytope",
144 "//aos/logging:matrix_logging",
145 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100146 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700147 "//aos/util:log_interval",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700148 "//frc971/control_loops:coerce_goal",
149 "//frc971/control_loops:state_feedback_loop",
150 ],
151)
152
153cc_library(
154 name = "drivetrain_config_uc",
155 hdrs = [
156 "drivetrain_config.h",
157 ],
158 restricted_to = mcu_cpus,
159 deps = [
160 "//frc971:shifter_hall_effect",
161 "//frc971/control_loops:state_feedback_loop_uc",
162 ],
163)
164
165cc_library(
166 name = "polydrivetrain_uc",
167 srcs = [
168 "drivetrain_uc.q.cc",
169 "polydrivetrain.cc",
170 ],
171 hdrs = [
172 "drivetrain_uc.q.h",
173 "polydrivetrain.h",
174 ],
175 restricted_to = mcu_cpus,
176 deps = [
177 ":drivetrain_config_uc",
178 ":gear",
John Park33858a32018-09-28 23:05:48 -0700179 "//aos:math",
180 "//aos/controls:polytope_uc",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700181 "//frc971/control_loops:coerce_goal_uc",
182 "//frc971/control_loops:state_feedback_loop_uc",
183 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000184)
185
Austin Schuh05c5a612016-04-02 15:10:25 -0700186genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700187 name = "genrule_down_estimator",
188 outs = [
189 "down_estimator.h",
190 "down_estimator.cc",
191 ],
192 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
193 tools = [
194 "//frc971/control_loops/python:down_estimator",
195 ],
196 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700197)
198
199cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700200 name = "down_estimator",
201 srcs = [
202 "down_estimator.cc",
203 ],
204 hdrs = [
205 "down_estimator.h",
206 ],
207 deps = [
208 "//frc971/control_loops:state_feedback_loop",
209 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700210)
211
Comran Morshed5323ecb2015-12-26 20:50:55 +0000212cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700213 name = "drivetrain_lib",
214 srcs = [
215 "drivetrain.cc",
216 ],
217 hdrs = [
218 "drivetrain.h",
219 ],
220 deps = [
221 ":down_estimator",
222 ":drivetrain_queue",
223 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800224 ":localizer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700225 ":polydrivetrain",
Alex Perry731b4602019-02-02 22:13:01 -0800226 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800227 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700228 "//aos/controls:control_loop",
229 "//aos/logging:matrix_logging",
230 "//aos/logging:queue_logging",
231 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800232 "//frc971/control_loops:runge_kutta",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700233 "//frc971/queues:gyro",
234 "//frc971/wpilib:imu_queue",
235 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000236)
237
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800238cc_library(
239 name = "drivetrain_test_lib",
240 testonly = True,
241 srcs = ["drivetrain_test_lib.cc"],
242 hdrs = ["drivetrain_test_lib.h"],
243 deps = [
244 ":drivetrain_config",
245 ":drivetrain_queue",
246 ":trajectory",
247 "//aos/testing:googletest",
248 "//frc971/control_loops:state_feedback_loop",
249 "//frc971/queues:gyro",
250 "//y2016:constants",
251 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
252 ],
253)
254
Comran Morshed5323ecb2015-12-26 20:50:55 +0000255cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700256 name = "drivetrain_lib_test",
257 srcs = [
258 "drivetrain_lib_test.cc",
259 ],
Alex Perry04300d62019-02-17 14:37:04 -0800260 defines =
261 cpu_select({
262 "amd64": [
263 "SUPPORT_PLOT=1",
264 ],
265 "arm": [],
266 }),
267 linkstatic = True,
Austin Schuhbcce26a2018-03-26 23:41:24 -0700268 deps = [
269 ":drivetrain_config",
270 ":drivetrain_lib",
271 ":drivetrain_queue",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800272 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700273 "//aos:queues",
274 "//aos/controls:control_loop_test",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700275 "//aos/testing:googletest",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700276 "//frc971/queues:gyro",
Alex Perry04300d62019-02-17 14:37:04 -0800277 ] + cpu_select({
278 "amd64": [
279 "//third_party/matplotlib-cpp",
280 ],
281 "arm": [],
282 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000283)
Brian Silverman6260c092018-01-14 15:21:36 -0800284
285genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700286 name = "genrule_haptic_wheel",
287 outs = [
288 "haptic_wheel.h",
289 "haptic_wheel.cc",
290 "integral_haptic_wheel.h",
291 "integral_haptic_wheel.cc",
292 "haptic_trigger.h",
293 "haptic_trigger.cc",
294 "integral_haptic_trigger.h",
295 "integral_haptic_trigger.cc",
296 ],
297 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
298 compatible_with = mcu_cpus,
299 tools = [
300 "//frc971/control_loops/python:haptic_wheel",
301 ],
302 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800303)
304
305cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700306 name = "haptic_input_uc",
307 srcs = [
308 "haptic_trigger.cc",
309 "haptic_wheel.cc",
310 "integral_haptic_trigger.cc",
311 "integral_haptic_wheel.cc",
312 ],
313 hdrs = [
314 "haptic_trigger.h",
315 "haptic_wheel.h",
316 "integral_haptic_trigger.h",
317 "integral_haptic_wheel.h",
318 ],
319 restricted_to = mcu_cpus,
320 deps = [
321 "//frc971/control_loops:state_feedback_loop_uc",
322 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800323)
324
325cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700326 name = "haptic_wheel",
327 srcs = [
328 "haptic_trigger.cc",
329 "haptic_wheel.cc",
330 "integral_haptic_trigger.cc",
331 "integral_haptic_wheel.cc",
332 ],
333 hdrs = [
334 "haptic_trigger.h",
335 "haptic_wheel.h",
336 "integral_haptic_trigger.h",
337 "integral_haptic_wheel.h",
338 ],
339 deps = [
340 "//frc971/control_loops:state_feedback_loop",
341 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800342)
Austin Schuhc2b08772018-12-19 18:05:06 +1100343
344cc_library(
345 name = "spline",
346 srcs = ["spline.cc"],
347 hdrs = ["spline.h"],
348 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800349 "//frc971/control_loops:binomial",
Austin Schuhc2b08772018-12-19 18:05:06 +1100350 "//third_party/eigen",
351 ],
352)
353
Alex Perrya60da442019-01-21 19:00:27 -0500354cc_binary(
355 name = "spline.so",
356 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800357 linkshared = True,
Alex Perrya60da442019-01-21 19:00:27 -0500358 deps = [
359 ":distance_spline",
360 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800361 ":trajectory",
362 "//aos/logging:implementations",
363 "//aos/network:team_number",
Alex Perrya60da442019-01-21 19:00:27 -0500364 "//third_party/eigen",
Alex Perry0603b542019-01-25 20:29:51 -0800365 "//y2019/control_loops/drivetrain:drivetrain_base",
Alex Perrya60da442019-01-21 19:00:27 -0500366 ],
Alex Perrya60da442019-01-21 19:00:27 -0500367)
368
Austin Schuhc2b08772018-12-19 18:05:06 +1100369cc_test(
370 name = "spline_test",
371 srcs = [
372 "spline_test.cc",
373 ],
374 restricted_to = ["//tools:k8"],
375 deps = [
376 ":spline",
377 "//aos/testing:googletest",
378 "//third_party/matplotlib-cpp",
379 "@com_github_gflags_gflags//:gflags",
380 ],
381)
Austin Schuh941b46d2018-12-19 18:06:05 +1100382
383cc_library(
384 name = "distance_spline",
385 srcs = ["distance_spline.cc"],
386 hdrs = ["distance_spline.h"],
387 deps = [
388 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800389 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100390 "//frc971/control_loops:fixed_quadrature",
391 "//third_party/eigen",
392 ],
393)
394
395cc_test(
396 name = "distance_spline_test",
397 srcs = [
398 "distance_spline_test.cc",
399 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800400 defines =
401 cpu_select({
402 "amd64": [
403 "SUPPORT_PLOT=1",
404 ],
405 "arm": [],
406 }),
407 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100408 deps = [
409 ":distance_spline",
410 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800411 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100412 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800413 ] + cpu_select({
414 "amd64": [
415 "//third_party/matplotlib-cpp",
416 ],
417 "arm": [],
418 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100419)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100420
421cc_library(
422 name = "trajectory",
423 srcs = ["trajectory.cc"],
424 hdrs = ["trajectory.h"],
425 deps = [
426 ":distance_spline",
427 ":drivetrain_config",
428 "//aos/logging:matrix_logging",
429 "//frc971/control_loops:c2d",
430 "//frc971/control_loops:dlqr",
431 "//frc971/control_loops:hybrid_state_feedback_loop",
432 "//frc971/control_loops:runge_kutta",
433 "//frc971/control_loops:state_feedback_loop",
434 "//third_party/eigen",
435 ],
436)
437
438cc_binary(
439 name = "trajectory_plot",
440 srcs = [
441 "trajectory_plot.cc",
442 ],
443 restricted_to = ["//tools:k8"],
444 deps = [
445 ":distance_spline",
446 ":trajectory",
447 "//aos/logging:implementations",
448 "//aos/logging:matrix_logging",
449 "//aos/network:team_number",
450 "//third_party/eigen",
451 "//third_party/matplotlib-cpp",
452 "//y2016/control_loops/drivetrain:drivetrain_base",
453 "@com_github_gflags_gflags//:gflags",
454 ],
455)
456
457cc_test(
458 name = "trajectory_test",
459 srcs = [
460 "trajectory_test.cc",
461 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800462 defines =
463 cpu_select({
464 "amd64": [
465 "SUPPORT_PLOT=1",
466 ],
467 "arm": [],
468 }),
469 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100470 deps = [
471 ":trajectory",
472 "//aos/testing:googletest",
473 "//aos/testing:test_shm",
474 "//y2016:constants",
475 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800476 ] + cpu_select({
477 "amd64": [
478 "//third_party/matplotlib-cpp",
479 ],
480 "arm": [],
481 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100482)