blob: 8c81440b168a0ebcb32a8dd164caa389d1b1c68c [file] [log] [blame]
Austin Schuhbcce26a2018-03-26 23:41:24 -07001package(default_visibility = ["//visibility:public"])
Comran Morshed5323ecb2015-12-26 20:50:55 +00002
Alex Perry2124ae82020-03-07 14:19:06 -08003load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_ts_library")
Alex Perrycb7da4b2019-08-28 19:35:56 -07004load("//aos:config.bzl", "aos_config")
Austin Schuhbcce26a2018-03-26 23:41:24 -07005load("//tools:environments.bzl", "mcu_cpus")
Alex Perrycb7da4b2019-08-28 19:35:56 -07006load("//tools/build_rules:select.bzl", "compiler_select", "cpu_select")
Comran Morshed5323ecb2015-12-26 20:50:55 +00007
Alex Perrycb7da4b2019-08-28 19:35:56 -07008flatbuffer_cc_library(
9 name = "drivetrain_goal_fbs",
10 srcs = ["drivetrain_goal.fbs"],
11 compatible_with = mcu_cpus,
12 gen_reflections = 1,
13 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
Comran Morshed5323ecb2015-12-26 20:50:55 +000014)
15
Alex Perrycb7da4b2019-08-28 19:35:56 -070016flatbuffer_cc_library(
17 name = "drivetrain_output_fbs",
18 srcs = ["drivetrain_output.fbs"],
19 compatible_with = mcu_cpus,
20 gen_reflections = 1,
21)
22
23flatbuffer_cc_library(
24 name = "drivetrain_position_fbs",
25 srcs = ["drivetrain_position.fbs"],
26 compatible_with = mcu_cpus,
27 gen_reflections = 1,
28)
29
30flatbuffer_cc_library(
31 name = "drivetrain_status_fbs",
32 srcs = ["drivetrain_status.fbs"],
33 compatible_with = mcu_cpus,
34 gen_reflections = 1,
35 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
36)
37
Alex Perry2124ae82020-03-07 14:19:06 -080038flatbuffer_ts_library(
39 name = "drivetrain_status_ts_fbs",
40 srcs = ["drivetrain_status.fbs"],
41 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
42)
43
Alex Perrycb7da4b2019-08-28 19:35:56 -070044genrule(
45 name = "drivetrain_goal_float_fbs_generated",
46 srcs = ["drivetrain_goal.fbs"],
47 outs = ["drivetrain_goal_float.fbs"],
48 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
49 compatible_with = mcu_cpus,
50)
51
52genrule(
53 name = "drivetrain_position_float_fbs_generated",
54 srcs = ["drivetrain_position.fbs"],
55 outs = ["drivetrain_position_float.fbs"],
56 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
57 compatible_with = mcu_cpus,
58)
59
60genrule(
61 name = "drivetrain_output_float_fbs_generated",
62 srcs = ["drivetrain_output.fbs"],
63 outs = ["drivetrain_output_float.fbs"],
64 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
65 compatible_with = mcu_cpus,
66)
67
68genrule(
69 name = "drivetrain_status_float_fbs_generated",
70 srcs = ["drivetrain_status.fbs"],
71 outs = ["drivetrain_status_float.fbs"],
72 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
73 compatible_with = mcu_cpus,
74)
75
76flatbuffer_cc_library(
77 name = "drivetrain_goal_float_fbs",
78 srcs = ["drivetrain_goal_float.fbs"],
79 compatible_with = mcu_cpus,
80 gen_reflections = 1,
81 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
82)
83
84flatbuffer_cc_library(
85 name = "drivetrain_output_float_fbs",
86 srcs = ["drivetrain_output_float.fbs"],
87 compatible_with = mcu_cpus,
88 gen_reflections = 1,
89)
90
91flatbuffer_cc_library(
92 name = "drivetrain_position_float_fbs",
93 srcs = ["drivetrain_position_float.fbs"],
94 compatible_with = mcu_cpus,
95 gen_reflections = 1,
96)
97
98flatbuffer_cc_library(
99 name = "drivetrain_status_float_fbs",
100 srcs = ["drivetrain_status_float.fbs"],
101 compatible_with = mcu_cpus,
102 gen_reflections = 1,
103 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
104)
105
106aos_config(
James Kuszmaul74d8f972020-02-11 17:13:17 -0800107 name = "simulation_channels",
108 src = "drivetrain_simulation_channels.json",
109 flatbuffers = [
110 ":drivetrain_status_fbs",
111 ],
112 visibility = ["//visibility:public"],
113)
114
115aos_config(
116 name = "simulation_config",
117 src = "drivetrain_simulation_config.json",
118 visibility = ["//visibility:public"],
119 deps = [
120 ":config",
121 ":simulation_channels",
122 ],
123)
124
125aos_config(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700126 name = "config",
127 src = "drivetrain_config.json",
128 flatbuffers = [
129 ":drivetrain_goal_fbs",
130 ":drivetrain_output_fbs",
131 ":drivetrain_status_fbs",
132 ":drivetrain_position_fbs",
133 ":localizer_fbs",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800134 "//frc971/queues:gyro_fbs",
135 "//frc971/queues:gyro_uid_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700136 "//frc971/wpilib:imu_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700137 ],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700138 visibility = ["//visibility:public"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700139 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700140 "//aos/robot_state:config",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700141 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000142)
143
144cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700145 name = "drivetrain_config",
146 hdrs = [
147 "drivetrain_config.h",
148 ],
149 deps = [
150 "//frc971:shifter_hall_effect",
Austin Schuha062edb2019-01-03 13:17:13 -0800151 "//frc971/control_loops:hybrid_state_feedback_loop",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700152 "//frc971/control_loops:state_feedback_loop",
153 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000154)
155
156cc_library(
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800157 name = "hybrid_ekf",
158 hdrs = ["hybrid_ekf.h"],
159 deps = [
160 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800161 "//aos:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800162 "//aos/containers:priority_queue",
James Kuszmaulfedc4612019-03-10 11:24:51 -0700163 "//aos/util:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800164 "//frc971/control_loops:c2d",
165 "//frc971/control_loops:runge_kutta",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700166 "@org_tuxfamily_eigen//:eigen",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800167 ],
168)
169
170cc_test(
171 name = "hybrid_ekf_test",
172 srcs = ["hybrid_ekf_test.cc"],
173 deps = [
174 ":drivetrain_test_lib",
175 ":hybrid_ekf",
176 ":trajectory",
177 "//aos/testing:googletest",
178 "//aos/testing:random_seed",
179 "//aos/testing:test_shm",
180 ],
181)
182
Alex Perrycb7da4b2019-08-28 19:35:56 -0700183flatbuffer_cc_library(
184 name = "localizer_fbs",
185 srcs = ["localizer.fbs"],
186 gen_reflections = 1,
James Kuszmaulef428a02019-03-02 22:19:41 -0800187)
188
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800189cc_library(
James Kuszmaul3431d622019-02-17 17:07:44 -0800190 name = "localizer",
191 hdrs = ["localizer.h"],
192 deps = [
193 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800194 ":drivetrain_status_fbs",
James Kuszmaul3431d622019-02-17 17:07:44 -0800195 ":hybrid_ekf",
James Kuszmaul5398fae2020-02-17 16:44:03 -0800196 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800197 "//frc971/control_loops:pose",
James Kuszmaul3431d622019-02-17 17:07:44 -0800198 ],
199)
200
201cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700202 name = "gear",
203 hdrs = [
204 "gear.h",
205 ],
206 compatible_with = mcu_cpus,
Austin Schuh093535c2016-03-05 23:21:00 -0800207)
208
209cc_library(
Alex Perry731b4602019-02-02 22:13:01 -0800210 name = "splinedrivetrain",
211 srcs = [
212 "splinedrivetrain.cc",
213 ],
214 hdrs = [
215 "splinedrivetrain.h",
216 ],
217 deps = [
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800218 ":distance_spline",
Alex Perry731b4602019-02-02 22:13:01 -0800219 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700220 ":drivetrain_goal_fbs",
221 ":drivetrain_output_fbs",
222 ":drivetrain_status_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800223 ":spline",
Alex Perry731b4602019-02-02 22:13:01 -0800224 ":trajectory",
Alex Perry1ec34522019-02-17 22:44:10 -0800225 "//aos:init",
James Kuszmaulc73bb222019-04-07 12:15:35 -0700226 "//aos/util:math",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700227 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800228 ],
Alex Perry731b4602019-02-02 22:13:01 -0800229)
230
231cc_library(
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800232 name = "line_follow_drivetrain",
233 srcs = [
234 "line_follow_drivetrain.cc",
235 ],
236 hdrs = [
237 "line_follow_drivetrain.h",
238 ],
239 deps = [
240 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700241 ":drivetrain_goal_fbs",
242 ":drivetrain_output_fbs",
243 ":drivetrain_status_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800244 ":localizer",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800245 "//aos:math",
246 "//aos/util:math",
247 "//frc971/control_loops:c2d",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700248 "//frc971/control_loops:control_loops_fbs",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800249 "//frc971/control_loops:dlqr",
250 "//frc971/control_loops:pose",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700251 "//frc971/control_loops:profiled_subsystem_fbs",
252 "//y2019/control_loops/superstructure:superstructure_goal_fbs",
253 "@org_tuxfamily_eigen//:eigen",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800254 ],
255)
256
257cc_test(
258 name = "line_follow_drivetrain_test",
259 srcs = ["line_follow_drivetrain_test.cc"],
260 linkstatic = True,
261 restricted_to = ["//tools:k8"],
262 deps = [
263 ":drivetrain_config",
264 ":drivetrain_test_lib",
265 ":line_follow_drivetrain",
266 ":trajectory",
267 "//aos/testing:googletest",
268 "//aos/testing:test_shm",
269 "//third_party/matplotlib-cpp",
270 "@com_github_gflags_gflags//:gflags",
271 ],
272)
273
274cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700275 name = "ssdrivetrain",
276 srcs = [
277 "ssdrivetrain.cc",
278 ],
279 hdrs = [
280 "ssdrivetrain.h",
281 ],
282 deps = [
283 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700284 ":drivetrain_goal_fbs",
285 ":drivetrain_output_fbs",
286 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700287 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800288 ":localizer",
John Park33858a32018-09-28 23:05:48 -0700289 "//aos:math",
290 "//aos/controls:control_loop",
291 "//aos/controls:polytope",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700292 "//aos/robot_state:robot_state_fbs",
John Park33858a32018-09-28 23:05:48 -0700293 "//aos/util:log_interval",
294 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700295 "//frc971:shifter_hall_effect",
296 "//frc971/control_loops:coerce_goal",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700297 "//frc971/control_loops:control_loops_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700298 "//frc971/control_loops:state_feedback_loop",
299 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000300)
301
302cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700303 name = "polydrivetrain",
304 srcs = [
305 "polydrivetrain.cc",
306 ],
307 hdrs = [
308 "polydrivetrain.h",
309 ],
310 deps = [
311 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700312 ":drivetrain_goal_fbs",
313 ":drivetrain_output_fbs",
314 ":drivetrain_position_fbs",
315 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700316 ":gear",
John Park33858a32018-09-28 23:05:48 -0700317 "//aos:math",
318 "//aos/controls:polytope",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700319 "//aos/robot_state:robot_state_fbs",
John Park33858a32018-09-28 23:05:48 -0700320 "//aos/util:log_interval",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700321 "//frc971/control_loops:coerce_goal",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700322 "//frc971/control_loops:control_loops_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700323 "//frc971/control_loops:state_feedback_loop",
324 ],
325)
326
327cc_library(
328 name = "drivetrain_config_uc",
329 hdrs = [
330 "drivetrain_config.h",
331 ],
332 restricted_to = mcu_cpus,
333 deps = [
334 "//frc971:shifter_hall_effect",
335 "//frc971/control_loops:state_feedback_loop_uc",
336 ],
337)
338
339cc_library(
340 name = "polydrivetrain_uc",
341 srcs = [
Austin Schuhbcce26a2018-03-26 23:41:24 -0700342 "polydrivetrain.cc",
343 ],
344 hdrs = [
Austin Schuhbcce26a2018-03-26 23:41:24 -0700345 "polydrivetrain.h",
346 ],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700347 copts = ["-Wno-type-limits"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700348 restricted_to = mcu_cpus,
349 deps = [
350 ":drivetrain_config_uc",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700351 ":drivetrain_goal_float_fbs",
352 ":drivetrain_output_float_fbs",
353 ":drivetrain_position_float_fbs",
354 ":drivetrain_status_float_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700355 ":gear",
John Park33858a32018-09-28 23:05:48 -0700356 "//aos:math",
357 "//aos/controls:polytope_uc",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700358 "//frc971/control_loops:coerce_goal_uc",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700359 "//frc971/control_loops:control_loops_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700360 "//frc971/control_loops:state_feedback_loop_uc",
361 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000362)
363
Austin Schuh05c5a612016-04-02 15:10:25 -0700364genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700365 name = "genrule_down_estimator",
366 outs = [
367 "down_estimator.h",
368 "down_estimator.cc",
369 ],
370 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
371 tools = [
372 "//frc971/control_loops/python:down_estimator",
373 ],
374 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700375)
376
377cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700378 name = "down_estimator",
379 srcs = [
380 "down_estimator.cc",
381 ],
382 hdrs = [
383 "down_estimator.h",
384 ],
385 deps = [
386 "//frc971/control_loops:state_feedback_loop",
387 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700388)
389
Comran Morshed5323ecb2015-12-26 20:50:55 +0000390cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700391 name = "drivetrain_lib",
392 srcs = [
393 "drivetrain.cc",
394 ],
395 hdrs = [
396 "drivetrain.h",
397 ],
398 deps = [
399 ":down_estimator",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700400 ":drivetrain_goal_fbs",
401 ":drivetrain_output_fbs",
402 ":drivetrain_position_fbs",
403 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700404 ":gear",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800405 ":improved_down_estimator",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800406 ":line_follow_drivetrain",
James Kuszmaul3431d622019-02-17 17:07:44 -0800407 ":localizer",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700408 ":localizer_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700409 ":polydrivetrain",
Alex Perry731b4602019-02-02 22:13:01 -0800410 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800411 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700412 "//aos/controls:control_loop",
John Park33858a32018-09-28 23:05:48 -0700413 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800414 "//frc971/control_loops:runge_kutta",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800415 "//frc971/queues:gyro_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700416 "//frc971/wpilib:imu_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800417 "//frc971/zeroing:imu_zeroer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700418 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000419)
420
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800421cc_library(
422 name = "drivetrain_test_lib",
423 testonly = True,
424 srcs = ["drivetrain_test_lib.cc"],
425 hdrs = ["drivetrain_test_lib.h"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800426 defines =
427 cpu_select({
428 "amd64": [
429 "SUPPORT_PLOT=1",
430 ],
431 "arm": [],
432 }),
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800433 deps = [
434 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700435 ":drivetrain_goal_fbs",
436 ":drivetrain_output_fbs",
437 ":drivetrain_position_fbs",
438 ":drivetrain_status_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800439 ":trajectory",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700440 "//aos/events:event_loop",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800441 "//aos/testing:googletest",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700442 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800443 "//frc971/control_loops:state_feedback_loop",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800444 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800445 "//frc971/wpilib:imu_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800446 "//y2016:constants",
447 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800448 ] + cpu_select({
449 "amd64": [
450 "//third_party/matplotlib-cpp",
451 ],
452 "arm": [],
453 }),
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800454)
455
Comran Morshed5323ecb2015-12-26 20:50:55 +0000456cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700457 name = "drivetrain_lib_test",
458 srcs = [
459 "drivetrain_lib_test.cc",
460 ],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800461 data = ["simulation_config.json"],
Alex Perry04300d62019-02-17 14:37:04 -0800462 defines =
463 cpu_select({
464 "amd64": [
465 "SUPPORT_PLOT=1",
466 ],
467 "arm": [],
468 }),
469 linkstatic = True,
Austin Schuhbcce26a2018-03-26 23:41:24 -0700470 deps = [
471 ":drivetrain_config",
472 ":drivetrain_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700473 ":localizer_fbs",
474 ":drivetrain_goal_fbs",
475 ":drivetrain_status_fbs",
476 ":drivetrain_position_fbs",
477 ":drivetrain_output_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800478 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700479 "//aos/controls:control_loop_test",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800480 "//aos/events/logging:logger",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700481 "//aos/testing:googletest",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800482 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800483 "//frc971/wpilib:imu_fbs",
Alex Perry04300d62019-02-17 14:37:04 -0800484 ] + cpu_select({
485 "amd64": [
486 "//third_party/matplotlib-cpp",
487 ],
488 "arm": [],
489 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000490)
Brian Silverman6260c092018-01-14 15:21:36 -0800491
492genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700493 name = "genrule_haptic_wheel",
494 outs = [
495 "haptic_wheel.h",
496 "haptic_wheel.cc",
497 "integral_haptic_wheel.h",
498 "integral_haptic_wheel.cc",
499 "haptic_trigger.h",
500 "haptic_trigger.cc",
501 "integral_haptic_trigger.h",
502 "integral_haptic_trigger.cc",
503 ],
504 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
505 compatible_with = mcu_cpus,
506 tools = [
507 "//frc971/control_loops/python:haptic_wheel",
508 ],
509 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800510)
511
512cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700513 name = "haptic_input_uc",
514 srcs = [
515 "haptic_trigger.cc",
516 "haptic_wheel.cc",
517 "integral_haptic_trigger.cc",
518 "integral_haptic_wheel.cc",
519 ],
520 hdrs = [
521 "haptic_trigger.h",
522 "haptic_wheel.h",
523 "integral_haptic_trigger.h",
524 "integral_haptic_wheel.h",
525 ],
526 restricted_to = mcu_cpus,
527 deps = [
528 "//frc971/control_loops:state_feedback_loop_uc",
529 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800530)
531
532cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700533 name = "haptic_wheel",
534 srcs = [
535 "haptic_trigger.cc",
536 "haptic_wheel.cc",
537 "integral_haptic_trigger.cc",
538 "integral_haptic_wheel.cc",
539 ],
540 hdrs = [
541 "haptic_trigger.h",
542 "haptic_wheel.h",
543 "integral_haptic_trigger.h",
544 "integral_haptic_wheel.h",
545 ],
546 deps = [
547 "//frc971/control_loops:state_feedback_loop",
548 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800549)
Austin Schuhc2b08772018-12-19 18:05:06 +1100550
551cc_library(
552 name = "spline",
553 srcs = ["spline.cc"],
554 hdrs = ["spline.h"],
555 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800556 "//frc971/control_loops:binomial",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700557 "@org_tuxfamily_eigen//:eigen",
Austin Schuhc2b08772018-12-19 18:05:06 +1100558 ],
559)
560
Alex Perrya60da442019-01-21 19:00:27 -0500561cc_binary(
562 name = "spline.so",
563 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800564 linkshared = True,
Alex Perrya60da442019-01-21 19:00:27 -0500565 deps = [
566 ":distance_spline",
567 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800568 ":trajectory",
569 "//aos/logging:implementations",
570 "//aos/network:team_number",
James Kuszmaul8aa37cb2020-03-01 10:27:58 -0800571 "//y2020/control_loops/drivetrain:drivetrain_base",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700572 "@org_tuxfamily_eigen//:eigen",
Alex Perrya60da442019-01-21 19:00:27 -0500573 ],
Alex Perrya60da442019-01-21 19:00:27 -0500574)
575
Austin Schuhc2b08772018-12-19 18:05:06 +1100576cc_test(
577 name = "spline_test",
578 srcs = [
579 "spline_test.cc",
580 ],
581 restricted_to = ["//tools:k8"],
582 deps = [
583 ":spline",
584 "//aos/testing:googletest",
585 "//third_party/matplotlib-cpp",
586 "@com_github_gflags_gflags//:gflags",
587 ],
588)
Austin Schuh941b46d2018-12-19 18:06:05 +1100589
590cc_library(
591 name = "distance_spline",
592 srcs = ["distance_spline.cc"],
593 hdrs = ["distance_spline.h"],
594 deps = [
595 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800596 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100597 "//frc971/control_loops:fixed_quadrature",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700598 "@org_tuxfamily_eigen//:eigen",
Austin Schuh941b46d2018-12-19 18:06:05 +1100599 ],
600)
601
602cc_test(
603 name = "distance_spline_test",
604 srcs = [
605 "distance_spline_test.cc",
606 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800607 defines =
608 cpu_select({
609 "amd64": [
610 "SUPPORT_PLOT=1",
611 ],
612 "arm": [],
613 }),
614 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100615 deps = [
616 ":distance_spline",
617 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800618 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100619 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800620 ] + cpu_select({
621 "amd64": [
622 "//third_party/matplotlib-cpp",
623 ],
624 "arm": [],
625 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100626)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100627
628cc_library(
629 name = "trajectory",
630 srcs = ["trajectory.cc"],
631 hdrs = ["trajectory.h"],
632 deps = [
633 ":distance_spline",
634 ":drivetrain_config",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100635 "//frc971/control_loops:c2d",
636 "//frc971/control_loops:dlqr",
637 "//frc971/control_loops:hybrid_state_feedback_loop",
638 "//frc971/control_loops:runge_kutta",
639 "//frc971/control_loops:state_feedback_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700640 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100641 ],
642)
643
644cc_binary(
645 name = "trajectory_plot",
646 srcs = [
647 "trajectory_plot.cc",
648 ],
649 restricted_to = ["//tools:k8"],
650 deps = [
651 ":distance_spline",
652 ":trajectory",
653 "//aos/logging:implementations",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100654 "//aos/network:team_number",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100655 "//third_party/matplotlib-cpp",
Austin Schuh11043182019-03-23 22:29:12 -0700656 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100657 "@com_github_gflags_gflags//:gflags",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700658 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100659 ],
660)
661
662cc_test(
663 name = "trajectory_test",
664 srcs = [
665 "trajectory_test.cc",
666 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800667 defines =
668 cpu_select({
669 "amd64": [
670 "SUPPORT_PLOT=1",
671 ],
672 "arm": [],
673 }),
674 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100675 deps = [
676 ":trajectory",
James Kuszmaulea314d92019-02-18 19:45:06 -0800677 ":drivetrain_test_lib",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100678 "//aos/testing:googletest",
679 "//aos/testing:test_shm",
680 "//y2016:constants",
681 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaulea314d92019-02-18 19:45:06 -0800682 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuh719a33e2019-01-07 15:13:34 -0800683 ] + cpu_select({
684 "amd64": [
685 "//third_party/matplotlib-cpp",
686 ],
687 "arm": [],
688 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100689)
Austin Schuhca080812017-05-10 19:31:55 -0700690
691cc_library(
692 name = "improved_down_estimator",
693 srcs = [
694 "improved_down_estimator.cc",
695 ],
696 hdrs = [
697 "improved_down_estimator.h",
698 ],
699 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800700 ":drivetrain_config",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800701 ":drivetrain_status_fbs",
702 "//aos/events:event_loop",
703 "//frc971/control_loops:control_loops_fbs",
Austin Schuhca080812017-05-10 19:31:55 -0700704 "//frc971/control_loops:runge_kutta",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800705 "@//aos/time",
Austin Schuhca080812017-05-10 19:31:55 -0700706 "@com_github_google_glog//:glog",
707 "@org_tuxfamily_eigen//:eigen",
708 ],
709)
710
711cc_test(
712 name = "improved_down_estimator_test",
713 srcs = [
714 "improved_down_estimator_test.cc",
715 ],
716 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800717 ":drivetrain_test_lib",
Austin Schuhca080812017-05-10 19:31:55 -0700718 "//aos/testing:googletest",
719 "//aos/testing:random_seed",
720 "//frc971/control_loops/drivetrain:improved_down_estimator",
721 "@org_tuxfamily_eigen//:eigen",
722 ],
723)
James Kuszmaulf4ede202020-02-14 08:47:40 -0800724
725cc_library(
726 name = "camera",
727 srcs = ["camera.h"],
728 visibility = ["//visibility:public"],
729 deps = [
730 "//aos/containers:sized_array",
731 "//frc971/control_loops:pose",
732 ],
733)
734
735cc_test(
736 name = "camera_test",
737 srcs = ["camera_test.cc"],
738 deps = [
739 ":camera",
740 "//aos/testing:googletest",
741 ],
742)