blob: 6725987c47fcc69bd12702f33ef420cf6194867c [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(
Austin Schuhbcce26a2018-03-26 23:41:24 -070069 name = "gear",
70 hdrs = [
71 "gear.h",
72 ],
73 compatible_with = mcu_cpus,
Austin Schuh093535c2016-03-05 23:21:00 -080074)
75
76cc_library(
Alex Perry731b4602019-02-02 22:13:01 -080077 name = "splinedrivetrain",
78 srcs = [
79 "splinedrivetrain.cc",
80 ],
81 hdrs = [
82 "splinedrivetrain.h",
83 ],
84 deps = [
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -080085 ":distance_spline",
Alex Perry731b4602019-02-02 22:13:01 -080086 ":drivetrain_config",
87 ":drivetrain_queue",
88 ":spline",
Alex Perry731b4602019-02-02 22:13:01 -080089 ":trajectory",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -080090 ],
Alex Perry731b4602019-02-02 22:13:01 -080091)
92
93cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070094 name = "ssdrivetrain",
95 srcs = [
96 "ssdrivetrain.cc",
97 ],
98 hdrs = [
99 "ssdrivetrain.h",
100 ],
101 deps = [
102 ":drivetrain_config",
103 ":drivetrain_queue",
104 ":gear",
John Park33858a32018-09-28 23:05:48 -0700105 "//aos:math",
106 "//aos/controls:control_loop",
107 "//aos/controls:polytope",
108 "//aos/logging:matrix_logging",
109 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100110 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700111 "//aos/util:log_interval",
112 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700113 "//frc971:shifter_hall_effect",
114 "//frc971/control_loops:coerce_goal",
115 "//frc971/control_loops:state_feedback_loop",
116 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000117)
118
119cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700120 name = "polydrivetrain",
121 srcs = [
122 "polydrivetrain.cc",
123 ],
124 hdrs = [
125 "polydrivetrain.h",
126 ],
127 deps = [
128 ":drivetrain_config",
129 ":drivetrain_queue",
130 ":gear",
John Park33858a32018-09-28 23:05:48 -0700131 "//aos:math",
132 "//aos/controls:polytope",
133 "//aos/logging:matrix_logging",
134 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +1100135 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -0700136 "//aos/util:log_interval",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700137 "//frc971/control_loops:coerce_goal",
138 "//frc971/control_loops:state_feedback_loop",
139 ],
140)
141
142cc_library(
143 name = "drivetrain_config_uc",
144 hdrs = [
145 "drivetrain_config.h",
146 ],
147 restricted_to = mcu_cpus,
148 deps = [
149 "//frc971:shifter_hall_effect",
150 "//frc971/control_loops:state_feedback_loop_uc",
151 ],
152)
153
154cc_library(
155 name = "polydrivetrain_uc",
156 srcs = [
157 "drivetrain_uc.q.cc",
158 "polydrivetrain.cc",
159 ],
160 hdrs = [
161 "drivetrain_uc.q.h",
162 "polydrivetrain.h",
163 ],
164 restricted_to = mcu_cpus,
165 deps = [
166 ":drivetrain_config_uc",
167 ":gear",
John Park33858a32018-09-28 23:05:48 -0700168 "//aos:math",
169 "//aos/controls:polytope_uc",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700170 "//frc971/control_loops:coerce_goal_uc",
171 "//frc971/control_loops:state_feedback_loop_uc",
172 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000173)
174
Austin Schuh05c5a612016-04-02 15:10:25 -0700175genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700176 name = "genrule_down_estimator",
177 outs = [
178 "down_estimator.h",
179 "down_estimator.cc",
180 ],
181 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
182 tools = [
183 "//frc971/control_loops/python:down_estimator",
184 ],
185 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700186)
187
188cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700189 name = "down_estimator",
190 srcs = [
191 "down_estimator.cc",
192 ],
193 hdrs = [
194 "down_estimator.h",
195 ],
196 deps = [
197 "//frc971/control_loops:state_feedback_loop",
198 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700199)
200
Comran Morshed5323ecb2015-12-26 20:50:55 +0000201cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700202 name = "drivetrain_lib",
203 srcs = [
204 "drivetrain.cc",
205 ],
206 hdrs = [
207 "drivetrain.h",
208 ],
209 deps = [
210 ":down_estimator",
211 ":drivetrain_queue",
212 ":gear",
213 ":polydrivetrain",
Alex Perry731b4602019-02-02 22:13:01 -0800214 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800215 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700216 "//aos/controls:control_loop",
217 "//aos/logging:matrix_logging",
218 "//aos/logging:queue_logging",
219 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800220 "//frc971/control_loops:runge_kutta",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700221 "//frc971/queues:gyro",
222 "//frc971/wpilib:imu_queue",
223 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000224)
225
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800226cc_library(
227 name = "drivetrain_test_lib",
228 testonly = True,
229 srcs = ["drivetrain_test_lib.cc"],
230 hdrs = ["drivetrain_test_lib.h"],
231 deps = [
232 ":drivetrain_config",
233 ":drivetrain_queue",
234 ":trajectory",
235 "//aos/testing:googletest",
236 "//frc971/control_loops:state_feedback_loop",
237 "//frc971/queues:gyro",
238 "//y2016:constants",
239 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
240 ],
241)
242
Comran Morshed5323ecb2015-12-26 20:50:55 +0000243cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700244 name = "drivetrain_lib_test",
245 srcs = [
246 "drivetrain_lib_test.cc",
247 ],
248 deps = [
249 ":drivetrain_config",
250 ":drivetrain_lib",
251 ":drivetrain_queue",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800252 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700253 "//aos:queues",
254 "//aos/controls:control_loop_test",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700255 "//aos/testing:googletest",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700256 "//frc971/queues:gyro",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700257 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000258)
Brian Silverman6260c092018-01-14 15:21:36 -0800259
260genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700261 name = "genrule_haptic_wheel",
262 outs = [
263 "haptic_wheel.h",
264 "haptic_wheel.cc",
265 "integral_haptic_wheel.h",
266 "integral_haptic_wheel.cc",
267 "haptic_trigger.h",
268 "haptic_trigger.cc",
269 "integral_haptic_trigger.h",
270 "integral_haptic_trigger.cc",
271 ],
272 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
273 compatible_with = mcu_cpus,
274 tools = [
275 "//frc971/control_loops/python:haptic_wheel",
276 ],
277 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800278)
279
280cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700281 name = "haptic_input_uc",
282 srcs = [
283 "haptic_trigger.cc",
284 "haptic_wheel.cc",
285 "integral_haptic_trigger.cc",
286 "integral_haptic_wheel.cc",
287 ],
288 hdrs = [
289 "haptic_trigger.h",
290 "haptic_wheel.h",
291 "integral_haptic_trigger.h",
292 "integral_haptic_wheel.h",
293 ],
294 restricted_to = mcu_cpus,
295 deps = [
296 "//frc971/control_loops:state_feedback_loop_uc",
297 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800298)
299
300cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700301 name = "haptic_wheel",
302 srcs = [
303 "haptic_trigger.cc",
304 "haptic_wheel.cc",
305 "integral_haptic_trigger.cc",
306 "integral_haptic_wheel.cc",
307 ],
308 hdrs = [
309 "haptic_trigger.h",
310 "haptic_wheel.h",
311 "integral_haptic_trigger.h",
312 "integral_haptic_wheel.h",
313 ],
314 deps = [
315 "//frc971/control_loops:state_feedback_loop",
316 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800317)
Austin Schuhc2b08772018-12-19 18:05:06 +1100318
319cc_library(
320 name = "spline",
321 srcs = ["spline.cc"],
322 hdrs = ["spline.h"],
323 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800324 "//frc971/control_loops:binomial",
Austin Schuhc2b08772018-12-19 18:05:06 +1100325 "//third_party/eigen",
326 ],
327)
328
Alex Perrya60da442019-01-21 19:00:27 -0500329cc_binary(
330 name = "spline.so",
331 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800332 linkshared = True,
Alex Perrya60da442019-01-21 19:00:27 -0500333 deps = [
334 ":distance_spline",
335 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800336 ":trajectory",
337 "//aos/logging:implementations",
338 "//aos/network:team_number",
Alex Perrya60da442019-01-21 19:00:27 -0500339 "//third_party/eigen",
Alex Perry0603b542019-01-25 20:29:51 -0800340 "//y2019/control_loops/drivetrain:drivetrain_base",
Alex Perrya60da442019-01-21 19:00:27 -0500341 ],
Alex Perrya60da442019-01-21 19:00:27 -0500342)
343
Austin Schuhc2b08772018-12-19 18:05:06 +1100344cc_test(
345 name = "spline_test",
346 srcs = [
347 "spline_test.cc",
348 ],
349 restricted_to = ["//tools:k8"],
350 deps = [
351 ":spline",
352 "//aos/testing:googletest",
353 "//third_party/matplotlib-cpp",
354 "@com_github_gflags_gflags//:gflags",
355 ],
356)
Austin Schuh941b46d2018-12-19 18:06:05 +1100357
358cc_library(
359 name = "distance_spline",
360 srcs = ["distance_spline.cc"],
361 hdrs = ["distance_spline.h"],
362 deps = [
363 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800364 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100365 "//frc971/control_loops:fixed_quadrature",
366 "//third_party/eigen",
367 ],
368)
369
370cc_test(
371 name = "distance_spline_test",
372 srcs = [
373 "distance_spline_test.cc",
374 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800375 defines =
376 cpu_select({
377 "amd64": [
378 "SUPPORT_PLOT=1",
379 ],
380 "arm": [],
381 }),
382 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100383 deps = [
384 ":distance_spline",
385 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800386 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100387 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800388 ] + cpu_select({
389 "amd64": [
390 "//third_party/matplotlib-cpp",
391 ],
392 "arm": [],
393 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100394)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100395
396cc_library(
397 name = "trajectory",
398 srcs = ["trajectory.cc"],
399 hdrs = ["trajectory.h"],
400 deps = [
401 ":distance_spline",
402 ":drivetrain_config",
403 "//aos/logging:matrix_logging",
404 "//frc971/control_loops:c2d",
405 "//frc971/control_loops:dlqr",
406 "//frc971/control_loops:hybrid_state_feedback_loop",
407 "//frc971/control_loops:runge_kutta",
408 "//frc971/control_loops:state_feedback_loop",
409 "//third_party/eigen",
410 ],
411)
412
413cc_binary(
414 name = "trajectory_plot",
415 srcs = [
416 "trajectory_plot.cc",
417 ],
418 restricted_to = ["//tools:k8"],
419 deps = [
420 ":distance_spline",
421 ":trajectory",
422 "//aos/logging:implementations",
423 "//aos/logging:matrix_logging",
424 "//aos/network:team_number",
425 "//third_party/eigen",
426 "//third_party/matplotlib-cpp",
427 "//y2016/control_loops/drivetrain:drivetrain_base",
428 "@com_github_gflags_gflags//:gflags",
429 ],
430)
431
432cc_test(
433 name = "trajectory_test",
434 srcs = [
435 "trajectory_test.cc",
436 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800437 defines =
438 cpu_select({
439 "amd64": [
440 "SUPPORT_PLOT=1",
441 ],
442 "arm": [],
443 }),
444 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100445 deps = [
446 ":trajectory",
447 "//aos/testing:googletest",
448 "//aos/testing:test_shm",
449 "//y2016:constants",
450 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800451 ] + cpu_select({
452 "amd64": [
453 "//third_party/matplotlib-cpp",
454 ],
455 "arm": [],
456 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100457)