blob: ee05fc5571a73e0d98bced10f7ee553b7d31643f [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(
Austin Schuhbcce26a2018-03-26 23:41:24 -070044 name = "gear",
45 hdrs = [
46 "gear.h",
47 ],
48 compatible_with = mcu_cpus,
Austin Schuh093535c2016-03-05 23:21:00 -080049)
50
51cc_library(
Alex Perry731b4602019-02-02 22:13:01 -080052 name = "splinedrivetrain",
53 srcs = [
54 "splinedrivetrain.cc",
55 ],
56 hdrs = [
57 "splinedrivetrain.h",
58 ],
59 deps = [
60 ":drivetrain_config",
61 ":drivetrain_queue",
62 ":spline",
63 ":distance_spline",
64 ":trajectory",
65 ]
66)
67
68cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070069 name = "ssdrivetrain",
70 srcs = [
71 "ssdrivetrain.cc",
72 ],
73 hdrs = [
74 "ssdrivetrain.h",
75 ],
76 deps = [
77 ":drivetrain_config",
78 ":drivetrain_queue",
79 ":gear",
John Park33858a32018-09-28 23:05:48 -070080 "//aos:math",
81 "//aos/controls:control_loop",
82 "//aos/controls:polytope",
83 "//aos/logging:matrix_logging",
84 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +110085 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -070086 "//aos/util:log_interval",
87 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -070088 "//frc971:shifter_hall_effect",
89 "//frc971/control_loops:coerce_goal",
90 "//frc971/control_loops:state_feedback_loop",
91 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +000092)
93
94cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070095 name = "polydrivetrain",
96 srcs = [
97 "polydrivetrain.cc",
98 ],
99 hdrs = [
100 "polydrivetrain.h",
101 ],
102 deps = [
103 ":drivetrain_config",
104 ":drivetrain_queue",
105 ":gear",
John Park33858a32018-09-28 23:05:48 -0700106 "//aos:math",
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",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700112 "//frc971/control_loops:coerce_goal",
113 "//frc971/control_loops:state_feedback_loop",
114 ],
115)
116
117cc_library(
118 name = "drivetrain_config_uc",
119 hdrs = [
120 "drivetrain_config.h",
121 ],
122 restricted_to = mcu_cpus,
123 deps = [
124 "//frc971:shifter_hall_effect",
125 "//frc971/control_loops:state_feedback_loop_uc",
126 ],
127)
128
129cc_library(
130 name = "polydrivetrain_uc",
131 srcs = [
132 "drivetrain_uc.q.cc",
133 "polydrivetrain.cc",
134 ],
135 hdrs = [
136 "drivetrain_uc.q.h",
137 "polydrivetrain.h",
138 ],
139 restricted_to = mcu_cpus,
140 deps = [
141 ":drivetrain_config_uc",
142 ":gear",
John Park33858a32018-09-28 23:05:48 -0700143 "//aos:math",
144 "//aos/controls:polytope_uc",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700145 "//frc971/control_loops:coerce_goal_uc",
146 "//frc971/control_loops:state_feedback_loop_uc",
147 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000148)
149
Austin Schuh05c5a612016-04-02 15:10:25 -0700150genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700151 name = "genrule_down_estimator",
152 outs = [
153 "down_estimator.h",
154 "down_estimator.cc",
155 ],
156 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
157 tools = [
158 "//frc971/control_loops/python:down_estimator",
159 ],
160 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700161)
162
163cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700164 name = "down_estimator",
165 srcs = [
166 "down_estimator.cc",
167 ],
168 hdrs = [
169 "down_estimator.h",
170 ],
171 deps = [
172 "//frc971/control_loops:state_feedback_loop",
173 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700174)
175
Comran Morshed5323ecb2015-12-26 20:50:55 +0000176cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700177 name = "drivetrain_lib",
178 srcs = [
179 "drivetrain.cc",
180 ],
181 hdrs = [
182 "drivetrain.h",
183 ],
184 deps = [
185 ":down_estimator",
186 ":drivetrain_queue",
187 ":gear",
188 ":polydrivetrain",
189 ":ssdrivetrain",
Alex Perry731b4602019-02-02 22:13:01 -0800190 ":splinedrivetrain",
John Park33858a32018-09-28 23:05:48 -0700191 "//aos/controls:control_loop",
192 "//aos/logging:matrix_logging",
193 "//aos/logging:queue_logging",
194 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800195 "//frc971/control_loops:runge_kutta",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700196 "//frc971/queues:gyro",
197 "//frc971/wpilib:imu_queue",
198 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000199)
200
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800201cc_library(
202 name = "drivetrain_test_lib",
203 testonly = True,
204 srcs = ["drivetrain_test_lib.cc"],
205 hdrs = ["drivetrain_test_lib.h"],
206 deps = [
207 ":drivetrain_config",
208 ":drivetrain_queue",
209 ":trajectory",
210 "//aos/testing:googletest",
211 "//frc971/control_loops:state_feedback_loop",
212 "//frc971/queues:gyro",
213 "//y2016:constants",
214 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
215 ],
216)
217
Comran Morshed5323ecb2015-12-26 20:50:55 +0000218cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700219 name = "drivetrain_lib_test",
220 srcs = [
221 "drivetrain_lib_test.cc",
222 ],
223 deps = [
224 ":drivetrain_config",
225 ":drivetrain_lib",
226 ":drivetrain_queue",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800227 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700228 "//aos:queues",
229 "//aos/controls:control_loop_test",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700230 "//aos/testing:googletest",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700231 "//frc971/queues:gyro",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700232 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000233)
Brian Silverman6260c092018-01-14 15:21:36 -0800234
235genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700236 name = "genrule_haptic_wheel",
237 outs = [
238 "haptic_wheel.h",
239 "haptic_wheel.cc",
240 "integral_haptic_wheel.h",
241 "integral_haptic_wheel.cc",
242 "haptic_trigger.h",
243 "haptic_trigger.cc",
244 "integral_haptic_trigger.h",
245 "integral_haptic_trigger.cc",
246 ],
247 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
248 compatible_with = mcu_cpus,
249 tools = [
250 "//frc971/control_loops/python:haptic_wheel",
251 ],
252 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800253)
254
255cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700256 name = "haptic_input_uc",
257 srcs = [
258 "haptic_trigger.cc",
259 "haptic_wheel.cc",
260 "integral_haptic_trigger.cc",
261 "integral_haptic_wheel.cc",
262 ],
263 hdrs = [
264 "haptic_trigger.h",
265 "haptic_wheel.h",
266 "integral_haptic_trigger.h",
267 "integral_haptic_wheel.h",
268 ],
269 restricted_to = mcu_cpus,
270 deps = [
271 "//frc971/control_loops:state_feedback_loop_uc",
272 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800273)
274
275cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700276 name = "haptic_wheel",
277 srcs = [
278 "haptic_trigger.cc",
279 "haptic_wheel.cc",
280 "integral_haptic_trigger.cc",
281 "integral_haptic_wheel.cc",
282 ],
283 hdrs = [
284 "haptic_trigger.h",
285 "haptic_wheel.h",
286 "integral_haptic_trigger.h",
287 "integral_haptic_wheel.h",
288 ],
289 deps = [
290 "//frc971/control_loops:state_feedback_loop",
291 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800292)
Austin Schuhc2b08772018-12-19 18:05:06 +1100293
294cc_library(
295 name = "spline",
296 srcs = ["spline.cc"],
297 hdrs = ["spline.h"],
298 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800299 "//frc971/control_loops:binomial",
Austin Schuhc2b08772018-12-19 18:05:06 +1100300 "//third_party/eigen",
301 ],
302)
303
Alex Perrya60da442019-01-21 19:00:27 -0500304cc_binary(
305 name = "spline.so",
306 srcs = ["libspline.cc"],
307 deps = [
308 ":distance_spline",
309 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800310 ":trajectory",
311 "//aos/logging:implementations",
312 "//aos/network:team_number",
Alex Perrya60da442019-01-21 19:00:27 -0500313 "//third_party/eigen",
Alex Perry0603b542019-01-25 20:29:51 -0800314 "//y2019/control_loops/drivetrain:drivetrain_base",
Alex Perrya60da442019-01-21 19:00:27 -0500315 ],
316 linkshared=True,
317)
318
Austin Schuhc2b08772018-12-19 18:05:06 +1100319cc_test(
320 name = "spline_test",
321 srcs = [
322 "spline_test.cc",
323 ],
324 restricted_to = ["//tools:k8"],
325 deps = [
326 ":spline",
327 "//aos/testing:googletest",
328 "//third_party/matplotlib-cpp",
329 "@com_github_gflags_gflags//:gflags",
330 ],
331)
Austin Schuh941b46d2018-12-19 18:06:05 +1100332
333cc_library(
334 name = "distance_spline",
335 srcs = ["distance_spline.cc"],
336 hdrs = ["distance_spline.h"],
337 deps = [
338 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800339 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100340 "//frc971/control_loops:fixed_quadrature",
341 "//third_party/eigen",
342 ],
343)
344
345cc_test(
346 name = "distance_spline_test",
347 srcs = [
348 "distance_spline_test.cc",
349 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800350 defines =
351 cpu_select({
352 "amd64": [
353 "SUPPORT_PLOT=1",
354 ],
355 "arm": [],
356 }),
357 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100358 deps = [
359 ":distance_spline",
360 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800361 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100362 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800363 ] + cpu_select({
364 "amd64": [
365 "//third_party/matplotlib-cpp",
366 ],
367 "arm": [],
368 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100369)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100370
371cc_library(
372 name = "trajectory",
373 srcs = ["trajectory.cc"],
374 hdrs = ["trajectory.h"],
375 deps = [
376 ":distance_spline",
377 ":drivetrain_config",
378 "//aos/logging:matrix_logging",
379 "//frc971/control_loops:c2d",
380 "//frc971/control_loops:dlqr",
381 "//frc971/control_loops:hybrid_state_feedback_loop",
382 "//frc971/control_loops:runge_kutta",
383 "//frc971/control_loops:state_feedback_loop",
384 "//third_party/eigen",
385 ],
386)
387
388cc_binary(
389 name = "trajectory_plot",
390 srcs = [
391 "trajectory_plot.cc",
392 ],
393 restricted_to = ["//tools:k8"],
394 deps = [
395 ":distance_spline",
396 ":trajectory",
397 "//aos/logging:implementations",
398 "//aos/logging:matrix_logging",
399 "//aos/network:team_number",
400 "//third_party/eigen",
401 "//third_party/matplotlib-cpp",
402 "//y2016/control_loops/drivetrain:drivetrain_base",
403 "@com_github_gflags_gflags//:gflags",
404 ],
405)
406
407cc_test(
408 name = "trajectory_test",
409 srcs = [
410 "trajectory_test.cc",
411 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800412 defines =
413 cpu_select({
414 "amd64": [
415 "SUPPORT_PLOT=1",
416 ],
417 "arm": [],
418 }),
419 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100420 deps = [
421 ":trajectory",
422 "//aos/testing:googletest",
423 "//aos/testing:test_shm",
424 "//y2016:constants",
425 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800426 ] + cpu_select({
427 "amd64": [
428 "//third_party/matplotlib-cpp",
429 ],
430 "arm": [],
431 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100432)