blob: 042c8d8a3bb5a2d9d775c010f740ec2f3391d62e [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")
Philipp Schraderdada1072020-11-24 11:34:46 -08005load("//tools/build_rules:select.bzl", "cpu_select")
Comran Morshed5323ecb2015-12-26 20:50:55 +00006
Alex Perrycb7da4b2019-08-28 19:35:56 -07007flatbuffer_cc_library(
8 name = "drivetrain_goal_fbs",
9 srcs = ["drivetrain_goal.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070010 gen_reflections = 1,
11 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
Comran Morshed5323ecb2015-12-26 20:50:55 +000012)
13
Alex Perrycb7da4b2019-08-28 19:35:56 -070014flatbuffer_cc_library(
15 name = "drivetrain_output_fbs",
16 srcs = ["drivetrain_output.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070017 gen_reflections = 1,
18)
19
20flatbuffer_cc_library(
21 name = "drivetrain_position_fbs",
22 srcs = ["drivetrain_position.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070023 gen_reflections = 1,
24)
25
26flatbuffer_cc_library(
27 name = "drivetrain_status_fbs",
28 srcs = ["drivetrain_status.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070029 gen_reflections = 1,
30 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
31)
32
Alex Perry2124ae82020-03-07 14:19:06 -080033flatbuffer_ts_library(
34 name = "drivetrain_status_ts_fbs",
35 srcs = ["drivetrain_status.fbs"],
36 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
Philipp Schraderdada1072020-11-24 11:34:46 -080037 target_compatible_with = ["@platforms//os:linux"],
Alex Perry2124ae82020-03-07 14:19:06 -080038)
39
Alex Perrycb7da4b2019-08-28 19:35:56 -070040genrule(
41 name = "drivetrain_goal_float_fbs_generated",
42 srcs = ["drivetrain_goal.fbs"],
43 outs = ["drivetrain_goal_float.fbs"],
44 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070045)
46
47genrule(
48 name = "drivetrain_position_float_fbs_generated",
49 srcs = ["drivetrain_position.fbs"],
50 outs = ["drivetrain_position_float.fbs"],
51 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070052)
53
54genrule(
55 name = "drivetrain_output_float_fbs_generated",
56 srcs = ["drivetrain_output.fbs"],
57 outs = ["drivetrain_output_float.fbs"],
58 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070059)
60
61genrule(
62 name = "drivetrain_status_float_fbs_generated",
63 srcs = ["drivetrain_status.fbs"],
64 outs = ["drivetrain_status_float.fbs"],
65 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070066)
67
68flatbuffer_cc_library(
69 name = "drivetrain_goal_float_fbs",
70 srcs = ["drivetrain_goal_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070071 gen_reflections = 1,
72 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
73)
74
75flatbuffer_cc_library(
76 name = "drivetrain_output_float_fbs",
77 srcs = ["drivetrain_output_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070078 gen_reflections = 1,
79)
80
81flatbuffer_cc_library(
82 name = "drivetrain_position_float_fbs",
83 srcs = ["drivetrain_position_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070084 gen_reflections = 1,
85)
86
87flatbuffer_cc_library(
88 name = "drivetrain_status_float_fbs",
89 srcs = ["drivetrain_status_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070090 gen_reflections = 1,
91 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
92)
93
94aos_config(
James Kuszmaul74d8f972020-02-11 17:13:17 -080095 name = "simulation_channels",
96 src = "drivetrain_simulation_channels.json",
97 flatbuffers = [
98 ":drivetrain_status_fbs",
99 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800100 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800101 visibility = ["//visibility:public"],
102)
103
104aos_config(
105 name = "simulation_config",
106 src = "drivetrain_simulation_config.json",
Philipp Schraderdada1072020-11-24 11:34:46 -0800107 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800108 visibility = ["//visibility:public"],
109 deps = [
110 ":config",
111 ":simulation_channels",
112 ],
113)
114
115aos_config(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700116 name = "config",
117 src = "drivetrain_config.json",
118 flatbuffers = [
119 ":drivetrain_goal_fbs",
120 ":drivetrain_output_fbs",
121 ":drivetrain_status_fbs",
122 ":drivetrain_position_fbs",
123 ":localizer_fbs",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800124 "//frc971/queues:gyro_fbs",
125 "//frc971/queues:gyro_uid_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700126 "//frc971/wpilib:imu_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700127 "//frc971/wpilib:imu_batch_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700128 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800129 target_compatible_with = ["@platforms//os:linux"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700130 visibility = ["//visibility:public"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700131 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700132 "//aos/robot_state:config",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700133 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000134)
135
136cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700137 name = "drivetrain_config",
138 hdrs = [
139 "drivetrain_config.h",
140 ],
141 deps = [
142 "//frc971:shifter_hall_effect",
143 "//frc971/control_loops:state_feedback_loop",
Philipp Schraderdada1072020-11-24 11:34:46 -0800144 ] + select({
145 "@platforms//os:linux": ["//frc971/control_loops:hybrid_state_feedback_loop"],
146 "//conditions:default": [],
147 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000148)
149
150cc_library(
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800151 name = "hybrid_ekf",
152 hdrs = ["hybrid_ekf.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800153 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800154 deps = [
155 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800156 "//aos:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800157 "//aos/containers:priority_queue",
James Kuszmaulfedc4612019-03-10 11:24:51 -0700158 "//aos/util:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800159 "//frc971/control_loops:c2d",
160 "//frc971/control_loops:runge_kutta",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700161 "@org_tuxfamily_eigen//:eigen",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800162 ],
163)
164
165cc_test(
166 name = "hybrid_ekf_test",
167 srcs = ["hybrid_ekf_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800168 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800169 deps = [
170 ":drivetrain_test_lib",
171 ":hybrid_ekf",
172 ":trajectory",
173 "//aos/testing:googletest",
174 "//aos/testing:random_seed",
175 "//aos/testing:test_shm",
176 ],
177)
178
Alex Perrycb7da4b2019-08-28 19:35:56 -0700179flatbuffer_cc_library(
180 name = "localizer_fbs",
181 srcs = ["localizer.fbs"],
182 gen_reflections = 1,
Philipp Schraderdada1072020-11-24 11:34:46 -0800183 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulef428a02019-03-02 22:19:41 -0800184)
185
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800186cc_library(
James Kuszmaul3431d622019-02-17 17:07:44 -0800187 name = "localizer",
188 hdrs = ["localizer.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800189 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul3431d622019-02-17 17:07:44 -0800190 deps = [
191 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800192 ":drivetrain_status_fbs",
James Kuszmaul3431d622019-02-17 17:07:44 -0800193 ":hybrid_ekf",
James Kuszmaul5398fae2020-02-17 16:44:03 -0800194 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800195 "//frc971/control_loops:pose",
James Kuszmaul3431d622019-02-17 17:07:44 -0800196 ],
197)
198
199cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700200 name = "gear",
201 hdrs = [
202 "gear.h",
203 ],
Austin Schuh093535c2016-03-05 23:21:00 -0800204)
205
206cc_library(
Alex Perry731b4602019-02-02 22:13:01 -0800207 name = "splinedrivetrain",
208 srcs = [
209 "splinedrivetrain.cc",
210 ],
211 hdrs = [
212 "splinedrivetrain.h",
213 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800214 target_compatible_with = ["@platforms//os:linux"],
Alex Perry731b4602019-02-02 22:13:01 -0800215 deps = [
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800216 ":distance_spline",
Alex Perry731b4602019-02-02 22:13:01 -0800217 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700218 ":drivetrain_goal_fbs",
219 ":drivetrain_output_fbs",
220 ":drivetrain_status_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800221 ":spline",
Alex Perry731b4602019-02-02 22:13:01 -0800222 ":trajectory",
Austin Schuh3d9ccd72020-08-01 15:42:40 -0700223 "//aos:condition",
Alex Perry1ec34522019-02-17 22:44:10 -0800224 "//aos:init",
James Kuszmaulc73bb222019-04-07 12:15:35 -0700225 "//aos/util:math",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700226 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800227 ],
Alex Perry731b4602019-02-02 22:13:01 -0800228)
229
230cc_library(
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800231 name = "line_follow_drivetrain",
232 srcs = [
233 "line_follow_drivetrain.cc",
234 ],
235 hdrs = [
236 "line_follow_drivetrain.h",
237 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800238 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800239 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,
Philipp Schraderdada1072020-11-24 11:34:46 -0800261 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800262 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 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800282 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700283 deps = [
284 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700285 ":drivetrain_goal_fbs",
286 ":drivetrain_output_fbs",
287 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700288 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800289 ":localizer",
John Park33858a32018-09-28 23:05:48 -0700290 "//aos:math",
291 "//aos/controls:control_loop",
292 "//aos/controls:polytope",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700293 "//aos/robot_state:robot_state_fbs",
John Park33858a32018-09-28 23:05:48 -0700294 "//aos/util:log_interval",
295 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700296 "//frc971:shifter_hall_effect",
297 "//frc971/control_loops:coerce_goal",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700298 "//frc971/control_loops:control_loops_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700299 "//frc971/control_loops:state_feedback_loop",
300 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000301)
302
303cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700304 name = "polydrivetrain",
305 srcs = [
306 "polydrivetrain.cc",
307 ],
308 hdrs = [
309 "polydrivetrain.h",
310 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800311 copts = select({
312 "@platforms//os:none": ["-Wno-type-limits"],
313 "//conditions:default": [],
314 }),
Austin Schuhbcce26a2018-03-26 23:41:24 -0700315 deps = [
316 ":drivetrain_config",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700317 ":gear",
John Park33858a32018-09-28 23:05:48 -0700318 "//aos:math",
319 "//aos/controls:polytope",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700320 "//frc971/control_loops:coerce_goal",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700321 "//frc971/control_loops:control_loops_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700322 "//frc971/control_loops:state_feedback_loop",
Philipp Schraderdada1072020-11-24 11:34:46 -0800323 ] + select({
324 "@platforms//os:linux": [
325 ":drivetrain_goal_fbs",
326 ":drivetrain_output_fbs",
327 ":drivetrain_position_fbs",
328 ":drivetrain_status_fbs",
329 "//aos/robot_state:robot_state_fbs",
330 "//aos/util:log_interval",
331 ],
332 "@platforms//os:none": [
333 ":drivetrain_goal_float_fbs",
334 ":drivetrain_output_float_fbs",
335 ":drivetrain_position_float_fbs",
336 ":drivetrain_status_float_fbs",
337 ],
338 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000339)
340
Austin Schuh05c5a612016-04-02 15:10:25 -0700341genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700342 name = "genrule_down_estimator",
343 outs = [
344 "down_estimator.h",
345 "down_estimator.cc",
346 ],
347 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
Philipp Schraderdada1072020-11-24 11:34:46 -0800348 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700349 tools = [
350 "//frc971/control_loops/python:down_estimator",
351 ],
352 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700353)
354
355cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700356 name = "down_estimator",
357 srcs = [
358 "down_estimator.cc",
359 ],
360 hdrs = [
361 "down_estimator.h",
362 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800363 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700364 deps = [
365 "//frc971/control_loops:state_feedback_loop",
366 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700367)
368
Comran Morshed5323ecb2015-12-26 20:50:55 +0000369cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700370 name = "drivetrain_lib",
371 srcs = [
372 "drivetrain.cc",
373 ],
374 hdrs = [
375 "drivetrain.h",
376 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800377 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700378 deps = [
379 ":down_estimator",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700380 ":drivetrain_goal_fbs",
381 ":drivetrain_output_fbs",
382 ":drivetrain_position_fbs",
383 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700384 ":gear",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800385 ":improved_down_estimator",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800386 ":line_follow_drivetrain",
James Kuszmaul3431d622019-02-17 17:07:44 -0800387 ":localizer",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700388 ":localizer_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700389 ":polydrivetrain",
Alex Perry731b4602019-02-02 22:13:01 -0800390 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800391 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700392 "//aos/controls:control_loop",
John Park33858a32018-09-28 23:05:48 -0700393 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800394 "//frc971/control_loops:runge_kutta",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800395 "//frc971/queues:gyro_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700396 "//frc971/wpilib:imu_batch_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700397 "//frc971/wpilib:imu_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800398 "//frc971/zeroing:imu_zeroer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700399 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000400)
401
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800402cc_library(
403 name = "drivetrain_test_lib",
404 testonly = True,
405 srcs = ["drivetrain_test_lib.cc"],
406 hdrs = ["drivetrain_test_lib.h"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800407 defines =
408 cpu_select({
409 "amd64": [
410 "SUPPORT_PLOT=1",
411 ],
412 "arm": [],
413 }),
Philipp Schraderdada1072020-11-24 11:34:46 -0800414 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800415 deps = [
416 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700417 ":drivetrain_goal_fbs",
418 ":drivetrain_output_fbs",
419 ":drivetrain_position_fbs",
420 ":drivetrain_status_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800421 ":trajectory",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700422 "//aos/events:event_loop",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800423 "//aos/testing:googletest",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700424 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800425 "//frc971/control_loops:state_feedback_loop",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800426 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800427 "//frc971/wpilib:imu_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700428 "//frc971/wpilib:imu_batch_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800429 "//y2016:constants",
430 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800431 ] + cpu_select({
432 "amd64": [
433 "//third_party/matplotlib-cpp",
434 ],
435 "arm": [],
436 }),
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800437)
438
Comran Morshed5323ecb2015-12-26 20:50:55 +0000439cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700440 name = "drivetrain_lib_test",
441 srcs = [
442 "drivetrain_lib_test.cc",
443 ],
Austin Schuh14d7d3d2020-09-10 18:14:36 -0700444 data = [":simulation_config"],
Alex Perry04300d62019-02-17 14:37:04 -0800445 defines =
446 cpu_select({
447 "amd64": [
448 "SUPPORT_PLOT=1",
449 ],
450 "arm": [],
451 }),
452 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800453 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700454 deps = [
455 ":drivetrain_config",
456 ":drivetrain_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700457 ":localizer_fbs",
458 ":drivetrain_goal_fbs",
459 ":drivetrain_status_fbs",
460 ":drivetrain_position_fbs",
461 ":drivetrain_output_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800462 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700463 "//aos/controls:control_loop_test",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800464 "//aos/events/logging:logger",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700465 "//aos/testing:googletest",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800466 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800467 "//frc971/wpilib:imu_fbs",
Alex Perry04300d62019-02-17 14:37:04 -0800468 ] + cpu_select({
469 "amd64": [
470 "//third_party/matplotlib-cpp",
471 ],
472 "arm": [],
473 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000474)
Brian Silverman6260c092018-01-14 15:21:36 -0800475
476genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700477 name = "genrule_haptic_wheel",
478 outs = [
479 "haptic_wheel.h",
480 "haptic_wheel.cc",
481 "integral_haptic_wheel.h",
482 "integral_haptic_wheel.cc",
483 "haptic_trigger.h",
484 "haptic_trigger.cc",
485 "integral_haptic_trigger.h",
486 "integral_haptic_trigger.cc",
487 ],
488 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700489 tools = [
490 "//frc971/control_loops/python:haptic_wheel",
491 ],
492 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800493)
494
495cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700496 name = "haptic_wheel",
497 srcs = [
498 "haptic_trigger.cc",
499 "haptic_wheel.cc",
500 "integral_haptic_trigger.cc",
501 "integral_haptic_wheel.cc",
502 ],
503 hdrs = [
504 "haptic_trigger.h",
505 "haptic_wheel.h",
506 "integral_haptic_trigger.h",
507 "integral_haptic_wheel.h",
508 ],
509 deps = [
510 "//frc971/control_loops:state_feedback_loop",
511 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800512)
Austin Schuhc2b08772018-12-19 18:05:06 +1100513
514cc_library(
515 name = "spline",
516 srcs = ["spline.cc"],
517 hdrs = ["spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800518 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100519 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800520 "//frc971/control_loops:binomial",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700521 "@org_tuxfamily_eigen//:eigen",
Austin Schuhc2b08772018-12-19 18:05:06 +1100522 ],
523)
524
Alex Perrya60da442019-01-21 19:00:27 -0500525cc_binary(
526 name = "spline.so",
527 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800528 linkshared = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800529 target_compatible_with = ["@platforms//os:linux"],
Alex Perrya60da442019-01-21 19:00:27 -0500530 deps = [
531 ":distance_spline",
532 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800533 ":trajectory",
534 "//aos/logging:implementations",
535 "//aos/network:team_number",
James Kuszmaul8aa37cb2020-03-01 10:27:58 -0800536 "//y2020/control_loops/drivetrain:drivetrain_base",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700537 "@org_tuxfamily_eigen//:eigen",
Alex Perrya60da442019-01-21 19:00:27 -0500538 ],
Alex Perrya60da442019-01-21 19:00:27 -0500539)
540
Austin Schuhc2b08772018-12-19 18:05:06 +1100541cc_test(
542 name = "spline_test",
543 srcs = [
544 "spline_test.cc",
545 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800546 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100547 deps = [
548 ":spline",
549 "//aos/testing:googletest",
550 "//third_party/matplotlib-cpp",
551 "@com_github_gflags_gflags//:gflags",
552 ],
553)
Austin Schuh941b46d2018-12-19 18:06:05 +1100554
555cc_library(
556 name = "distance_spline",
557 srcs = ["distance_spline.cc"],
558 hdrs = ["distance_spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800559 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100560 deps = [
561 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800562 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100563 "//frc971/control_loops:fixed_quadrature",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700564 "@org_tuxfamily_eigen//:eigen",
Austin Schuh941b46d2018-12-19 18:06:05 +1100565 ],
566)
567
568cc_test(
569 name = "distance_spline_test",
570 srcs = [
571 "distance_spline_test.cc",
572 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800573 defines =
574 cpu_select({
575 "amd64": [
576 "SUPPORT_PLOT=1",
577 ],
578 "arm": [],
579 }),
580 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800581 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100582 deps = [
583 ":distance_spline",
584 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800585 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100586 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800587 ] + cpu_select({
588 "amd64": [
589 "//third_party/matplotlib-cpp",
590 ],
591 "arm": [],
592 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100593)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100594
595cc_library(
596 name = "trajectory",
597 srcs = ["trajectory.cc"],
598 hdrs = ["trajectory.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800599 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100600 deps = [
601 ":distance_spline",
602 ":drivetrain_config",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100603 "//frc971/control_loops:c2d",
604 "//frc971/control_loops:dlqr",
605 "//frc971/control_loops:hybrid_state_feedback_loop",
606 "//frc971/control_loops:runge_kutta",
607 "//frc971/control_loops:state_feedback_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700608 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100609 ],
610)
611
612cc_binary(
613 name = "trajectory_plot",
614 srcs = [
615 "trajectory_plot.cc",
616 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800617 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100618 deps = [
619 ":distance_spline",
620 ":trajectory",
621 "//aos/logging:implementations",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100622 "//aos/network:team_number",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100623 "//third_party/matplotlib-cpp",
Austin Schuh11043182019-03-23 22:29:12 -0700624 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100625 "@com_github_gflags_gflags//:gflags",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700626 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100627 ],
628)
629
630cc_test(
631 name = "trajectory_test",
632 srcs = [
633 "trajectory_test.cc",
634 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800635 defines =
636 cpu_select({
637 "amd64": [
638 "SUPPORT_PLOT=1",
639 ],
640 "arm": [],
641 }),
642 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800643 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100644 deps = [
645 ":trajectory",
James Kuszmaulea314d92019-02-18 19:45:06 -0800646 ":drivetrain_test_lib",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100647 "//aos/testing:googletest",
648 "//aos/testing:test_shm",
649 "//y2016:constants",
650 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaulea314d92019-02-18 19:45:06 -0800651 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuh719a33e2019-01-07 15:13:34 -0800652 ] + cpu_select({
653 "amd64": [
654 "//third_party/matplotlib-cpp",
655 ],
656 "arm": [],
657 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100658)
Austin Schuhca080812017-05-10 19:31:55 -0700659
660cc_library(
661 name = "improved_down_estimator",
662 srcs = [
663 "improved_down_estimator.cc",
664 ],
665 hdrs = [
666 "improved_down_estimator.h",
667 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800668 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700669 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800670 ":drivetrain_config",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800671 ":drivetrain_status_fbs",
Brian Silvermandac0a4b2020-06-23 17:03:09 -0700672 "//aos/controls:quaternion_utils",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800673 "//aos/events:event_loop",
674 "//frc971/control_loops:control_loops_fbs",
Austin Schuhca080812017-05-10 19:31:55 -0700675 "//frc971/control_loops:runge_kutta",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800676 "@//aos/time",
Austin Schuhca080812017-05-10 19:31:55 -0700677 "@com_github_google_glog//:glog",
678 "@org_tuxfamily_eigen//:eigen",
679 ],
680)
681
682cc_test(
683 name = "improved_down_estimator_test",
684 srcs = [
685 "improved_down_estimator_test.cc",
686 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800687 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700688 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800689 ":drivetrain_test_lib",
Brian Silvermandac0a4b2020-06-23 17:03:09 -0700690 "//aos/controls:quaternion_utils",
Austin Schuhca080812017-05-10 19:31:55 -0700691 "//aos/testing:googletest",
692 "//aos/testing:random_seed",
693 "//frc971/control_loops/drivetrain:improved_down_estimator",
694 "@org_tuxfamily_eigen//:eigen",
695 ],
696)
James Kuszmaulf4ede202020-02-14 08:47:40 -0800697
698cc_library(
699 name = "camera",
700 srcs = ["camera.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800701 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800702 visibility = ["//visibility:public"],
703 deps = [
704 "//aos/containers:sized_array",
705 "//frc971/control_loops:pose",
706 ],
707)
708
709cc_test(
710 name = "camera_test",
711 srcs = ["camera_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800712 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800713 deps = [
714 ":camera",
715 "//aos/testing:googletest",
716 ],
717)