blob: 663d36b3a20c47b2eb2de8982c5dc6b64960b66a [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 ],
259 deps = [
260 ":drivetrain_config",
261 ":drivetrain_lib",
262 ":drivetrain_queue",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800263 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700264 "//aos:queues",
265 "//aos/controls:control_loop_test",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700266 "//aos/testing:googletest",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700267 "//frc971/queues:gyro",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700268 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000269)
Brian Silverman6260c092018-01-14 15:21:36 -0800270
271genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700272 name = "genrule_haptic_wheel",
273 outs = [
274 "haptic_wheel.h",
275 "haptic_wheel.cc",
276 "integral_haptic_wheel.h",
277 "integral_haptic_wheel.cc",
278 "haptic_trigger.h",
279 "haptic_trigger.cc",
280 "integral_haptic_trigger.h",
281 "integral_haptic_trigger.cc",
282 ],
283 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
284 compatible_with = mcu_cpus,
285 tools = [
286 "//frc971/control_loops/python:haptic_wheel",
287 ],
288 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800289)
290
291cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700292 name = "haptic_input_uc",
293 srcs = [
294 "haptic_trigger.cc",
295 "haptic_wheel.cc",
296 "integral_haptic_trigger.cc",
297 "integral_haptic_wheel.cc",
298 ],
299 hdrs = [
300 "haptic_trigger.h",
301 "haptic_wheel.h",
302 "integral_haptic_trigger.h",
303 "integral_haptic_wheel.h",
304 ],
305 restricted_to = mcu_cpus,
306 deps = [
307 "//frc971/control_loops:state_feedback_loop_uc",
308 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800309)
310
311cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700312 name = "haptic_wheel",
313 srcs = [
314 "haptic_trigger.cc",
315 "haptic_wheel.cc",
316 "integral_haptic_trigger.cc",
317 "integral_haptic_wheel.cc",
318 ],
319 hdrs = [
320 "haptic_trigger.h",
321 "haptic_wheel.h",
322 "integral_haptic_trigger.h",
323 "integral_haptic_wheel.h",
324 ],
325 deps = [
326 "//frc971/control_loops:state_feedback_loop",
327 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800328)
Austin Schuhc2b08772018-12-19 18:05:06 +1100329
330cc_library(
331 name = "spline",
332 srcs = ["spline.cc"],
333 hdrs = ["spline.h"],
334 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800335 "//frc971/control_loops:binomial",
Austin Schuhc2b08772018-12-19 18:05:06 +1100336 "//third_party/eigen",
337 ],
338)
339
Alex Perrya60da442019-01-21 19:00:27 -0500340cc_binary(
341 name = "spline.so",
342 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800343 linkshared = True,
Alex Perrya60da442019-01-21 19:00:27 -0500344 deps = [
345 ":distance_spline",
346 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800347 ":trajectory",
348 "//aos/logging:implementations",
349 "//aos/network:team_number",
Alex Perrya60da442019-01-21 19:00:27 -0500350 "//third_party/eigen",
Alex Perry0603b542019-01-25 20:29:51 -0800351 "//y2019/control_loops/drivetrain:drivetrain_base",
Alex Perrya60da442019-01-21 19:00:27 -0500352 ],
Alex Perrya60da442019-01-21 19:00:27 -0500353)
354
Austin Schuhc2b08772018-12-19 18:05:06 +1100355cc_test(
356 name = "spline_test",
357 srcs = [
358 "spline_test.cc",
359 ],
360 restricted_to = ["//tools:k8"],
361 deps = [
362 ":spline",
363 "//aos/testing:googletest",
364 "//third_party/matplotlib-cpp",
365 "@com_github_gflags_gflags//:gflags",
366 ],
367)
Austin Schuh941b46d2018-12-19 18:06:05 +1100368
369cc_library(
370 name = "distance_spline",
371 srcs = ["distance_spline.cc"],
372 hdrs = ["distance_spline.h"],
373 deps = [
374 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800375 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100376 "//frc971/control_loops:fixed_quadrature",
377 "//third_party/eigen",
378 ],
379)
380
381cc_test(
382 name = "distance_spline_test",
383 srcs = [
384 "distance_spline_test.cc",
385 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800386 defines =
387 cpu_select({
388 "amd64": [
389 "SUPPORT_PLOT=1",
390 ],
391 "arm": [],
392 }),
393 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100394 deps = [
395 ":distance_spline",
396 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800397 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100398 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800399 ] + cpu_select({
400 "amd64": [
401 "//third_party/matplotlib-cpp",
402 ],
403 "arm": [],
404 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100405)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100406
407cc_library(
408 name = "trajectory",
409 srcs = ["trajectory.cc"],
410 hdrs = ["trajectory.h"],
411 deps = [
412 ":distance_spline",
413 ":drivetrain_config",
414 "//aos/logging:matrix_logging",
415 "//frc971/control_loops:c2d",
416 "//frc971/control_loops:dlqr",
417 "//frc971/control_loops:hybrid_state_feedback_loop",
418 "//frc971/control_loops:runge_kutta",
419 "//frc971/control_loops:state_feedback_loop",
420 "//third_party/eigen",
421 ],
422)
423
424cc_binary(
425 name = "trajectory_plot",
426 srcs = [
427 "trajectory_plot.cc",
428 ],
429 restricted_to = ["//tools:k8"],
430 deps = [
431 ":distance_spline",
432 ":trajectory",
433 "//aos/logging:implementations",
434 "//aos/logging:matrix_logging",
435 "//aos/network:team_number",
436 "//third_party/eigen",
437 "//third_party/matplotlib-cpp",
438 "//y2016/control_loops/drivetrain:drivetrain_base",
439 "@com_github_gflags_gflags//:gflags",
440 ],
441)
442
443cc_test(
444 name = "trajectory_test",
445 srcs = [
446 "trajectory_test.cc",
447 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800448 defines =
449 cpu_select({
450 "amd64": [
451 "SUPPORT_PLOT=1",
452 ],
453 "arm": [],
454 }),
455 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100456 deps = [
457 ":trajectory",
458 "//aos/testing:googletest",
459 "//aos/testing:test_shm",
460 "//y2016:constants",
461 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800462 ] + cpu_select({
463 "amd64": [
464 "//third_party/matplotlib-cpp",
465 ],
466 "arm": [],
467 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100468)