blob: 1aeec18277b8757c6ab996d23e6ab320f9c51bc0 [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")
James Kuszmaulc4ae11c2020-12-26 16:26:58 -08006load("@npm_bazel_typescript//:defs.bzl", "ts_library")
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"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070011 gen_reflections = 1,
12 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
Comran Morshed5323ecb2015-12-26 20:50:55 +000013)
14
Alex Perrycb7da4b2019-08-28 19:35:56 -070015flatbuffer_cc_library(
16 name = "drivetrain_output_fbs",
17 srcs = ["drivetrain_output.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070018 gen_reflections = 1,
19)
20
21flatbuffer_cc_library(
22 name = "drivetrain_position_fbs",
23 srcs = ["drivetrain_position.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070024 gen_reflections = 1,
25)
26
27flatbuffer_cc_library(
28 name = "drivetrain_status_fbs",
29 srcs = ["drivetrain_status.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070030 gen_reflections = 1,
31 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
32)
33
Alex Perry2124ae82020-03-07 14:19:06 -080034flatbuffer_ts_library(
35 name = "drivetrain_status_ts_fbs",
36 srcs = ["drivetrain_status.fbs"],
37 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
Philipp Schraderdada1072020-11-24 11:34:46 -080038 target_compatible_with = ["@platforms//os:linux"],
Alex Perry2124ae82020-03-07 14:19:06 -080039)
40
Alex Perrycb7da4b2019-08-28 19:35:56 -070041genrule(
42 name = "drivetrain_goal_float_fbs_generated",
43 srcs = ["drivetrain_goal.fbs"],
44 outs = ["drivetrain_goal_float.fbs"],
45 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070046)
47
48genrule(
49 name = "drivetrain_position_float_fbs_generated",
50 srcs = ["drivetrain_position.fbs"],
51 outs = ["drivetrain_position_float.fbs"],
52 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070053)
54
55genrule(
56 name = "drivetrain_output_float_fbs_generated",
57 srcs = ["drivetrain_output.fbs"],
58 outs = ["drivetrain_output_float.fbs"],
59 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070060)
61
62genrule(
63 name = "drivetrain_status_float_fbs_generated",
64 srcs = ["drivetrain_status.fbs"],
65 outs = ["drivetrain_status_float.fbs"],
66 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070067)
68
69flatbuffer_cc_library(
70 name = "drivetrain_goal_float_fbs",
71 srcs = ["drivetrain_goal_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070072 gen_reflections = 1,
73 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
74)
75
76flatbuffer_cc_library(
77 name = "drivetrain_output_float_fbs",
78 srcs = ["drivetrain_output_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070079 gen_reflections = 1,
80)
81
82flatbuffer_cc_library(
83 name = "drivetrain_position_float_fbs",
84 srcs = ["drivetrain_position_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070085 gen_reflections = 1,
86)
87
88flatbuffer_cc_library(
89 name = "drivetrain_status_float_fbs",
90 srcs = ["drivetrain_status_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070091 gen_reflections = 1,
92 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
93)
94
95aos_config(
James Kuszmaul74d8f972020-02-11 17:13:17 -080096 name = "simulation_channels",
97 src = "drivetrain_simulation_channels.json",
98 flatbuffers = [
99 ":drivetrain_status_fbs",
100 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800101 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800102 visibility = ["//visibility:public"],
103)
104
105aos_config(
106 name = "simulation_config",
107 src = "drivetrain_simulation_config.json",
Philipp Schraderdada1072020-11-24 11:34:46 -0800108 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800109 visibility = ["//visibility:public"],
110 deps = [
111 ":config",
112 ":simulation_channels",
113 ],
114)
115
116aos_config(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700117 name = "config",
118 src = "drivetrain_config.json",
119 flatbuffers = [
120 ":drivetrain_goal_fbs",
121 ":drivetrain_output_fbs",
122 ":drivetrain_status_fbs",
123 ":drivetrain_position_fbs",
124 ":localizer_fbs",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800125 "//frc971/queues:gyro_fbs",
126 "//frc971/queues:gyro_uid_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700127 "//frc971/wpilib:imu_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700128 "//frc971/wpilib:imu_batch_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700129 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800130 target_compatible_with = ["@platforms//os:linux"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700131 visibility = ["//visibility:public"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700132 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700133 "//aos/robot_state:config",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700134 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000135)
136
137cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700138 name = "drivetrain_config",
139 hdrs = [
140 "drivetrain_config.h",
141 ],
142 deps = [
143 "//frc971:shifter_hall_effect",
144 "//frc971/control_loops:state_feedback_loop",
Philipp Schraderdada1072020-11-24 11:34:46 -0800145 ] + select({
146 "@platforms//os:linux": ["//frc971/control_loops:hybrid_state_feedback_loop"],
147 "//conditions:default": [],
148 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000149)
150
151cc_library(
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800152 name = "hybrid_ekf",
153 hdrs = ["hybrid_ekf.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800154 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800155 deps = [
156 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800157 "//aos:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800158 "//aos/containers:priority_queue",
James Kuszmaulfedc4612019-03-10 11:24:51 -0700159 "//aos/util:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800160 "//frc971/control_loops:c2d",
161 "//frc971/control_loops:runge_kutta",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700162 "@org_tuxfamily_eigen//:eigen",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800163 ],
164)
165
166cc_test(
167 name = "hybrid_ekf_test",
168 srcs = ["hybrid_ekf_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800169 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800170 deps = [
171 ":drivetrain_test_lib",
172 ":hybrid_ekf",
173 ":trajectory",
174 "//aos/testing:googletest",
175 "//aos/testing:random_seed",
176 "//aos/testing:test_shm",
177 ],
178)
179
Alex Perrycb7da4b2019-08-28 19:35:56 -0700180flatbuffer_cc_library(
181 name = "localizer_fbs",
182 srcs = ["localizer.fbs"],
183 gen_reflections = 1,
Philipp Schraderdada1072020-11-24 11:34:46 -0800184 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulef428a02019-03-02 22:19:41 -0800185)
186
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800187cc_library(
James Kuszmaul3431d622019-02-17 17:07:44 -0800188 name = "localizer",
189 hdrs = ["localizer.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800190 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul3431d622019-02-17 17:07:44 -0800191 deps = [
192 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800193 ":drivetrain_status_fbs",
James Kuszmaul3431d622019-02-17 17:07:44 -0800194 ":hybrid_ekf",
James Kuszmaul5398fae2020-02-17 16:44:03 -0800195 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800196 "//frc971/control_loops:pose",
James Kuszmaul3431d622019-02-17 17:07:44 -0800197 ],
198)
199
200cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700201 name = "gear",
202 hdrs = [
203 "gear.h",
204 ],
Austin Schuh093535c2016-03-05 23:21:00 -0800205)
206
207cc_library(
Alex Perry731b4602019-02-02 22:13:01 -0800208 name = "splinedrivetrain",
209 srcs = [
210 "splinedrivetrain.cc",
211 ],
212 hdrs = [
213 "splinedrivetrain.h",
214 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800215 target_compatible_with = ["@platforms//os:linux"],
Alex Perry731b4602019-02-02 22:13:01 -0800216 deps = [
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800217 ":distance_spline",
Alex Perry731b4602019-02-02 22:13:01 -0800218 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700219 ":drivetrain_goal_fbs",
220 ":drivetrain_output_fbs",
221 ":drivetrain_status_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800222 ":spline",
Alex Perry731b4602019-02-02 22:13:01 -0800223 ":trajectory",
Austin Schuh3d9ccd72020-08-01 15:42:40 -0700224 "//aos:condition",
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 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800239 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800240 deps = [
241 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700242 ":drivetrain_goal_fbs",
243 ":drivetrain_output_fbs",
244 ":drivetrain_status_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800245 ":localizer",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800246 "//aos:math",
247 "//aos/util:math",
248 "//frc971/control_loops:c2d",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700249 "//frc971/control_loops:control_loops_fbs",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800250 "//frc971/control_loops:dlqr",
251 "//frc971/control_loops:pose",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700252 "//frc971/control_loops:profiled_subsystem_fbs",
253 "//y2019/control_loops/superstructure:superstructure_goal_fbs",
254 "@org_tuxfamily_eigen//:eigen",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800255 ],
256)
257
258cc_test(
259 name = "line_follow_drivetrain_test",
260 srcs = ["line_follow_drivetrain_test.cc"],
261 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800262 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800263 deps = [
264 ":drivetrain_config",
265 ":drivetrain_test_lib",
266 ":line_follow_drivetrain",
267 ":trajectory",
268 "//aos/testing:googletest",
269 "//aos/testing:test_shm",
270 "//third_party/matplotlib-cpp",
271 "@com_github_gflags_gflags//:gflags",
272 ],
273)
274
275cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700276 name = "ssdrivetrain",
277 srcs = [
278 "ssdrivetrain.cc",
279 ],
280 hdrs = [
281 "ssdrivetrain.h",
282 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800283 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700284 deps = [
285 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700286 ":drivetrain_goal_fbs",
287 ":drivetrain_output_fbs",
288 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700289 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800290 ":localizer",
John Park33858a32018-09-28 23:05:48 -0700291 "//aos:math",
292 "//aos/controls:control_loop",
293 "//aos/controls:polytope",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700294 "//aos/robot_state:robot_state_fbs",
John Park33858a32018-09-28 23:05:48 -0700295 "//aos/util:log_interval",
296 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700297 "//frc971:shifter_hall_effect",
298 "//frc971/control_loops:coerce_goal",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700299 "//frc971/control_loops:control_loops_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700300 "//frc971/control_loops:state_feedback_loop",
301 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000302)
303
304cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700305 name = "polydrivetrain",
306 srcs = [
307 "polydrivetrain.cc",
308 ],
309 hdrs = [
310 "polydrivetrain.h",
311 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800312 copts = select({
313 "@platforms//os:none": ["-Wno-type-limits"],
314 "//conditions:default": [],
315 }),
Austin Schuhbcce26a2018-03-26 23:41:24 -0700316 deps = [
317 ":drivetrain_config",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700318 ":gear",
John Park33858a32018-09-28 23:05:48 -0700319 "//aos:math",
320 "//aos/controls:polytope",
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",
Philipp Schraderdada1072020-11-24 11:34:46 -0800324 ] + select({
325 "@platforms//os:linux": [
326 ":drivetrain_goal_fbs",
327 ":drivetrain_output_fbs",
328 ":drivetrain_position_fbs",
329 ":drivetrain_status_fbs",
330 "//aos/robot_state:robot_state_fbs",
331 "//aos/util:log_interval",
332 ],
333 "@platforms//os:none": [
334 ":drivetrain_goal_float_fbs",
335 ":drivetrain_output_float_fbs",
336 ":drivetrain_position_float_fbs",
337 ":drivetrain_status_float_fbs",
338 ],
339 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000340)
341
Austin Schuh05c5a612016-04-02 15:10:25 -0700342genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700343 name = "genrule_down_estimator",
344 outs = [
345 "down_estimator.h",
346 "down_estimator.cc",
347 ],
348 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
Philipp Schraderdada1072020-11-24 11:34:46 -0800349 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700350 tools = [
351 "//frc971/control_loops/python:down_estimator",
352 ],
353 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700354)
355
356cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700357 name = "down_estimator",
358 srcs = [
359 "down_estimator.cc",
360 ],
361 hdrs = [
362 "down_estimator.h",
363 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800364 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700365 deps = [
366 "//frc971/control_loops:state_feedback_loop",
367 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700368)
369
Comran Morshed5323ecb2015-12-26 20:50:55 +0000370cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700371 name = "drivetrain_lib",
372 srcs = [
373 "drivetrain.cc",
374 ],
375 hdrs = [
376 "drivetrain.h",
377 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800378 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700379 deps = [
380 ":down_estimator",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700381 ":drivetrain_goal_fbs",
382 ":drivetrain_output_fbs",
383 ":drivetrain_position_fbs",
384 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700385 ":gear",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800386 ":improved_down_estimator",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800387 ":line_follow_drivetrain",
James Kuszmaul3431d622019-02-17 17:07:44 -0800388 ":localizer",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700389 ":localizer_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700390 ":polydrivetrain",
Alex Perry731b4602019-02-02 22:13:01 -0800391 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800392 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700393 "//aos/controls:control_loop",
John Park33858a32018-09-28 23:05:48 -0700394 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800395 "//frc971/control_loops:runge_kutta",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800396 "//frc971/queues:gyro_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700397 "//frc971/wpilib:imu_batch_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700398 "//frc971/wpilib:imu_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800399 "//frc971/zeroing:imu_zeroer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700400 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000401)
402
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800403cc_library(
404 name = "drivetrain_test_lib",
405 testonly = True,
406 srcs = ["drivetrain_test_lib.cc"],
407 hdrs = ["drivetrain_test_lib.h"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800408 defines =
409 cpu_select({
410 "amd64": [
411 "SUPPORT_PLOT=1",
412 ],
413 "arm": [],
414 }),
Philipp Schraderdada1072020-11-24 11:34:46 -0800415 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800416 deps = [
417 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700418 ":drivetrain_goal_fbs",
419 ":drivetrain_output_fbs",
420 ":drivetrain_position_fbs",
421 ":drivetrain_status_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800422 ":trajectory",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700423 "//aos/events:event_loop",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800424 "//aos/testing:googletest",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700425 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800426 "//frc971/control_loops:state_feedback_loop",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800427 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800428 "//frc971/wpilib:imu_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700429 "//frc971/wpilib:imu_batch_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800430 "//y2016:constants",
431 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800432 ] + cpu_select({
433 "amd64": [
434 "//third_party/matplotlib-cpp",
435 ],
436 "arm": [],
437 }),
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800438)
439
Comran Morshed5323ecb2015-12-26 20:50:55 +0000440cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700441 name = "drivetrain_lib_test",
442 srcs = [
443 "drivetrain_lib_test.cc",
444 ],
Austin Schuh14d7d3d2020-09-10 18:14:36 -0700445 data = [":simulation_config"],
Alex Perry04300d62019-02-17 14:37:04 -0800446 defines =
447 cpu_select({
448 "amd64": [
449 "SUPPORT_PLOT=1",
450 ],
451 "arm": [],
452 }),
453 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800454 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700455 deps = [
456 ":drivetrain_config",
457 ":drivetrain_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700458 ":localizer_fbs",
459 ":drivetrain_goal_fbs",
460 ":drivetrain_status_fbs",
461 ":drivetrain_position_fbs",
462 ":drivetrain_output_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800463 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700464 "//aos/controls:control_loop_test",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800465 "//aos/events/logging:logger",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700466 "//aos/testing:googletest",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800467 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800468 "//frc971/wpilib:imu_fbs",
Alex Perry04300d62019-02-17 14:37:04 -0800469 ] + cpu_select({
470 "amd64": [
471 "//third_party/matplotlib-cpp",
472 ],
473 "arm": [],
474 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000475)
Brian Silverman6260c092018-01-14 15:21:36 -0800476
477genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700478 name = "genrule_haptic_wheel",
479 outs = [
480 "haptic_wheel.h",
481 "haptic_wheel.cc",
482 "integral_haptic_wheel.h",
483 "integral_haptic_wheel.cc",
484 "haptic_trigger.h",
485 "haptic_trigger.cc",
486 "integral_haptic_trigger.h",
487 "integral_haptic_trigger.cc",
488 ],
489 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700490 tools = [
491 "//frc971/control_loops/python:haptic_wheel",
492 ],
493 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800494)
495
496cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700497 name = "haptic_wheel",
498 srcs = [
499 "haptic_trigger.cc",
500 "haptic_wheel.cc",
501 "integral_haptic_trigger.cc",
502 "integral_haptic_wheel.cc",
503 ],
504 hdrs = [
505 "haptic_trigger.h",
506 "haptic_wheel.h",
507 "integral_haptic_trigger.h",
508 "integral_haptic_wheel.h",
509 ],
510 deps = [
511 "//frc971/control_loops:state_feedback_loop",
512 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800513)
Austin Schuhc2b08772018-12-19 18:05:06 +1100514
515cc_library(
516 name = "spline",
517 srcs = ["spline.cc"],
518 hdrs = ["spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800519 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100520 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800521 "//frc971/control_loops:binomial",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700522 "@org_tuxfamily_eigen//:eigen",
Austin Schuhc2b08772018-12-19 18:05:06 +1100523 ],
524)
525
Alex Perrya60da442019-01-21 19:00:27 -0500526cc_binary(
527 name = "spline.so",
528 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800529 linkshared = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800530 target_compatible_with = ["@platforms//os:linux"],
Alex Perrya60da442019-01-21 19:00:27 -0500531 deps = [
532 ":distance_spline",
533 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800534 ":trajectory",
535 "//aos/logging:implementations",
536 "//aos/network:team_number",
James Kuszmaul8aa37cb2020-03-01 10:27:58 -0800537 "//y2020/control_loops/drivetrain:drivetrain_base",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700538 "@org_tuxfamily_eigen//:eigen",
Alex Perrya60da442019-01-21 19:00:27 -0500539 ],
Alex Perrya60da442019-01-21 19:00:27 -0500540)
541
Austin Schuhc2b08772018-12-19 18:05:06 +1100542cc_test(
543 name = "spline_test",
544 srcs = [
545 "spline_test.cc",
546 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800547 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100548 deps = [
549 ":spline",
550 "//aos/testing:googletest",
551 "//third_party/matplotlib-cpp",
552 "@com_github_gflags_gflags//:gflags",
553 ],
554)
Austin Schuh941b46d2018-12-19 18:06:05 +1100555
556cc_library(
557 name = "distance_spline",
558 srcs = ["distance_spline.cc"],
559 hdrs = ["distance_spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800560 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100561 deps = [
562 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800563 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100564 "//frc971/control_loops:fixed_quadrature",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700565 "@org_tuxfamily_eigen//:eigen",
Austin Schuh941b46d2018-12-19 18:06:05 +1100566 ],
567)
568
569cc_test(
570 name = "distance_spline_test",
571 srcs = [
572 "distance_spline_test.cc",
573 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800574 defines =
575 cpu_select({
576 "amd64": [
577 "SUPPORT_PLOT=1",
578 ],
579 "arm": [],
580 }),
581 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800582 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100583 deps = [
584 ":distance_spline",
585 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800586 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100587 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800588 ] + cpu_select({
589 "amd64": [
590 "//third_party/matplotlib-cpp",
591 ],
592 "arm": [],
593 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100594)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100595
596cc_library(
597 name = "trajectory",
598 srcs = ["trajectory.cc"],
599 hdrs = ["trajectory.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800600 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100601 deps = [
602 ":distance_spline",
603 ":drivetrain_config",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100604 "//frc971/control_loops:c2d",
605 "//frc971/control_loops:dlqr",
606 "//frc971/control_loops:hybrid_state_feedback_loop",
607 "//frc971/control_loops:runge_kutta",
608 "//frc971/control_loops:state_feedback_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700609 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100610 ],
611)
612
613cc_binary(
614 name = "trajectory_plot",
615 srcs = [
616 "trajectory_plot.cc",
617 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800618 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100619 deps = [
620 ":distance_spline",
621 ":trajectory",
622 "//aos/logging:implementations",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100623 "//aos/network:team_number",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100624 "//third_party/matplotlib-cpp",
Austin Schuh11043182019-03-23 22:29:12 -0700625 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100626 "@com_github_gflags_gflags//:gflags",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700627 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100628 ],
629)
630
631cc_test(
632 name = "trajectory_test",
633 srcs = [
634 "trajectory_test.cc",
635 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800636 defines =
637 cpu_select({
638 "amd64": [
639 "SUPPORT_PLOT=1",
640 ],
641 "arm": [],
642 }),
643 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800644 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100645 deps = [
646 ":trajectory",
James Kuszmaulea314d92019-02-18 19:45:06 -0800647 ":drivetrain_test_lib",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100648 "//aos/testing:googletest",
649 "//aos/testing:test_shm",
650 "//y2016:constants",
651 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaulea314d92019-02-18 19:45:06 -0800652 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuh719a33e2019-01-07 15:13:34 -0800653 ] + cpu_select({
654 "amd64": [
655 "//third_party/matplotlib-cpp",
656 ],
657 "arm": [],
658 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100659)
Austin Schuhca080812017-05-10 19:31:55 -0700660
661cc_library(
662 name = "improved_down_estimator",
663 srcs = [
664 "improved_down_estimator.cc",
665 ],
666 hdrs = [
667 "improved_down_estimator.h",
668 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800669 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700670 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800671 ":drivetrain_config",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800672 ":drivetrain_status_fbs",
Brian Silvermandac0a4b2020-06-23 17:03:09 -0700673 "//aos/controls:quaternion_utils",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800674 "//aos/events:event_loop",
675 "//frc971/control_loops:control_loops_fbs",
Austin Schuhca080812017-05-10 19:31:55 -0700676 "//frc971/control_loops:runge_kutta",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800677 "@//aos/time",
Austin Schuhca080812017-05-10 19:31:55 -0700678 "@com_github_google_glog//:glog",
679 "@org_tuxfamily_eigen//:eigen",
680 ],
681)
682
683cc_test(
684 name = "improved_down_estimator_test",
685 srcs = [
686 "improved_down_estimator_test.cc",
687 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800688 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700689 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800690 ":drivetrain_test_lib",
Brian Silvermandac0a4b2020-06-23 17:03:09 -0700691 "//aos/controls:quaternion_utils",
Austin Schuhca080812017-05-10 19:31:55 -0700692 "//aos/testing:googletest",
693 "//aos/testing:random_seed",
694 "//frc971/control_loops/drivetrain:improved_down_estimator",
695 "@org_tuxfamily_eigen//:eigen",
696 ],
697)
James Kuszmaulf4ede202020-02-14 08:47:40 -0800698
699cc_library(
700 name = "camera",
701 srcs = ["camera.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800702 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800703 visibility = ["//visibility:public"],
704 deps = [
705 "//aos/containers:sized_array",
706 "//frc971/control_loops:pose",
707 ],
708)
709
710cc_test(
711 name = "camera_test",
712 srcs = ["camera_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800713 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800714 deps = [
715 ":camera",
716 "//aos/testing:googletest",
717 ],
718)
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800719
720ts_library(
721 name = "drivetrain_plotter",
722 srcs = ["drivetrain_plotter.ts"],
723 target_compatible_with = ["@platforms//os:linux"],
724 deps = [
725 "//aos/network/www:aos_plotter",
726 "//aos/network/www:proxy",
727 "//frc971/wpilib:imu_plot_utils",
728 ],
729)
milind upadhyay9bd381d2021-01-23 13:44:13 -0800730
731ts_library(
732 name = "robot_state_plotter",
733 srcs = ["robot_state_plotter.ts"],
734 target_compatible_with = ["@platforms//os:linux"],
735 deps = [
736 "//aos/network/www:aos_plotter",
737 "//aos/network/www:proxy",
738 ],
739)