blob: 8c3274dcc39aecc48e2452d60a78029a08f704fd [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",
Austin Schuh95771d92021-01-23 14:42:25 -0800288 ":drivetrain_states",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700289 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700290 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800291 ":localizer",
John Park33858a32018-09-28 23:05:48 -0700292 "//aos:math",
293 "//aos/controls:control_loop",
294 "//aos/controls:polytope",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700295 "//aos/robot_state:robot_state_fbs",
John Park33858a32018-09-28 23:05:48 -0700296 "//aos/util:log_interval",
297 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700298 "//frc971:shifter_hall_effect",
299 "//frc971/control_loops:coerce_goal",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700300 "//frc971/control_loops:control_loops_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700301 "//frc971/control_loops:state_feedback_loop",
302 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000303)
304
305cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700306 name = "polydrivetrain",
307 srcs = [
308 "polydrivetrain.cc",
309 ],
310 hdrs = [
311 "polydrivetrain.h",
312 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800313 copts = select({
314 "@platforms//os:none": ["-Wno-type-limits"],
315 "//conditions:default": [],
316 }),
Austin Schuhbcce26a2018-03-26 23:41:24 -0700317 deps = [
318 ":drivetrain_config",
Austin Schuh95771d92021-01-23 14:42:25 -0800319 ":drivetrain_states",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700320 ":gear",
John Park33858a32018-09-28 23:05:48 -0700321 "//aos:math",
322 "//aos/controls:polytope",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700323 "//frc971/control_loops:coerce_goal",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700324 "//frc971/control_loops:control_loops_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700325 "//frc971/control_loops:state_feedback_loop",
Philipp Schraderdada1072020-11-24 11:34:46 -0800326 ] + select({
327 "@platforms//os:linux": [
328 ":drivetrain_goal_fbs",
329 ":drivetrain_output_fbs",
330 ":drivetrain_position_fbs",
331 ":drivetrain_status_fbs",
332 "//aos/robot_state:robot_state_fbs",
333 "//aos/util:log_interval",
334 ],
335 "@platforms//os:none": [
336 ":drivetrain_goal_float_fbs",
337 ":drivetrain_output_float_fbs",
338 ":drivetrain_position_float_fbs",
339 ":drivetrain_status_float_fbs",
340 ],
341 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000342)
343
Austin Schuh05c5a612016-04-02 15:10:25 -0700344genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700345 name = "genrule_down_estimator",
346 outs = [
347 "down_estimator.h",
348 "down_estimator.cc",
349 ],
350 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
Philipp Schraderdada1072020-11-24 11:34:46 -0800351 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700352 tools = [
353 "//frc971/control_loops/python:down_estimator",
354 ],
355 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700356)
357
358cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700359 name = "down_estimator",
360 srcs = [
361 "down_estimator.cc",
362 ],
363 hdrs = [
364 "down_estimator.h",
365 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800366 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700367 deps = [
368 "//frc971/control_loops:state_feedback_loop",
369 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700370)
371
Comran Morshed5323ecb2015-12-26 20:50:55 +0000372cc_library(
Austin Schuh95771d92021-01-23 14:42:25 -0800373 name = "drivetrain_states",
374 hdrs = ["drivetrain_states.h"],
375)
376
377cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700378 name = "drivetrain_lib",
379 srcs = [
380 "drivetrain.cc",
381 ],
382 hdrs = [
383 "drivetrain.h",
384 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800385 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700386 deps = [
387 ":down_estimator",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700388 ":drivetrain_goal_fbs",
389 ":drivetrain_output_fbs",
390 ":drivetrain_position_fbs",
Austin Schuh95771d92021-01-23 14:42:25 -0800391 ":drivetrain_states",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700392 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700393 ":gear",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800394 ":improved_down_estimator",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800395 ":line_follow_drivetrain",
James Kuszmaul3431d622019-02-17 17:07:44 -0800396 ":localizer",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700397 ":localizer_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700398 ":polydrivetrain",
Alex Perry731b4602019-02-02 22:13:01 -0800399 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800400 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700401 "//aos/controls:control_loop",
John Park33858a32018-09-28 23:05:48 -0700402 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800403 "//frc971/control_loops:runge_kutta",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800404 "//frc971/queues:gyro_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700405 "//frc971/wpilib:imu_batch_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700406 "//frc971/wpilib:imu_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800407 "//frc971/zeroing:imu_zeroer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700408 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000409)
410
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800411cc_library(
412 name = "drivetrain_test_lib",
413 testonly = True,
414 srcs = ["drivetrain_test_lib.cc"],
415 hdrs = ["drivetrain_test_lib.h"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800416 defines =
417 cpu_select({
418 "amd64": [
419 "SUPPORT_PLOT=1",
420 ],
421 "arm": [],
422 }),
Philipp Schraderdada1072020-11-24 11:34:46 -0800423 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800424 deps = [
425 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700426 ":drivetrain_goal_fbs",
427 ":drivetrain_output_fbs",
428 ":drivetrain_position_fbs",
429 ":drivetrain_status_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800430 ":trajectory",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700431 "//aos/events:event_loop",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800432 "//aos/testing:googletest",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700433 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800434 "//frc971/control_loops:state_feedback_loop",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800435 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800436 "//frc971/wpilib:imu_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700437 "//frc971/wpilib:imu_batch_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800438 "//y2016:constants",
439 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800440 ] + cpu_select({
441 "amd64": [
442 "//third_party/matplotlib-cpp",
443 ],
444 "arm": [],
445 }),
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800446)
447
Comran Morshed5323ecb2015-12-26 20:50:55 +0000448cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700449 name = "drivetrain_lib_test",
450 srcs = [
451 "drivetrain_lib_test.cc",
452 ],
Austin Schuh14d7d3d2020-09-10 18:14:36 -0700453 data = [":simulation_config"],
Alex Perry04300d62019-02-17 14:37:04 -0800454 defines =
455 cpu_select({
456 "amd64": [
457 "SUPPORT_PLOT=1",
458 ],
459 "arm": [],
460 }),
461 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800462 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700463 deps = [
464 ":drivetrain_config",
465 ":drivetrain_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700466 ":localizer_fbs",
467 ":drivetrain_goal_fbs",
468 ":drivetrain_status_fbs",
469 ":drivetrain_position_fbs",
470 ":drivetrain_output_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800471 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700472 "//aos/controls:control_loop_test",
Austin Schuhb06f03b2021-02-17 22:00:37 -0800473 "//aos/events/logging:log_writer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700474 "//aos/testing:googletest",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800475 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800476 "//frc971/wpilib:imu_fbs",
Alex Perry04300d62019-02-17 14:37:04 -0800477 ] + cpu_select({
478 "amd64": [
479 "//third_party/matplotlib-cpp",
480 ],
481 "arm": [],
482 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000483)
Brian Silverman6260c092018-01-14 15:21:36 -0800484
485genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700486 name = "genrule_haptic_wheel",
487 outs = [
488 "haptic_wheel.h",
489 "haptic_wheel.cc",
490 "integral_haptic_wheel.h",
491 "integral_haptic_wheel.cc",
492 "haptic_trigger.h",
493 "haptic_trigger.cc",
494 "integral_haptic_trigger.h",
495 "integral_haptic_trigger.cc",
496 ],
497 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700498 tools = [
499 "//frc971/control_loops/python:haptic_wheel",
500 ],
501 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800502)
503
504cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700505 name = "haptic_wheel",
506 srcs = [
507 "haptic_trigger.cc",
508 "haptic_wheel.cc",
509 "integral_haptic_trigger.cc",
510 "integral_haptic_wheel.cc",
511 ],
512 hdrs = [
513 "haptic_trigger.h",
514 "haptic_wheel.h",
515 "integral_haptic_trigger.h",
516 "integral_haptic_wheel.h",
517 ],
518 deps = [
519 "//frc971/control_loops:state_feedback_loop",
520 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800521)
Austin Schuhc2b08772018-12-19 18:05:06 +1100522
523cc_library(
524 name = "spline",
525 srcs = ["spline.cc"],
526 hdrs = ["spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800527 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100528 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800529 "//frc971/control_loops:binomial",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700530 "@org_tuxfamily_eigen//:eigen",
Austin Schuhc2b08772018-12-19 18:05:06 +1100531 ],
532)
533
Alex Perrya60da442019-01-21 19:00:27 -0500534cc_binary(
535 name = "spline.so",
536 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800537 linkshared = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800538 target_compatible_with = ["@platforms//os:linux"],
Alex Perrya60da442019-01-21 19:00:27 -0500539 deps = [
540 ":distance_spline",
541 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800542 ":trajectory",
543 "//aos/logging:implementations",
544 "//aos/network:team_number",
James Kuszmaul8aa37cb2020-03-01 10:27:58 -0800545 "//y2020/control_loops/drivetrain:drivetrain_base",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700546 "@org_tuxfamily_eigen//:eigen",
Alex Perrya60da442019-01-21 19:00:27 -0500547 ],
Alex Perrya60da442019-01-21 19:00:27 -0500548)
549
Austin Schuhc2b08772018-12-19 18:05:06 +1100550cc_test(
551 name = "spline_test",
552 srcs = [
553 "spline_test.cc",
554 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800555 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100556 deps = [
557 ":spline",
558 "//aos/testing:googletest",
559 "//third_party/matplotlib-cpp",
560 "@com_github_gflags_gflags//:gflags",
561 ],
562)
Austin Schuh941b46d2018-12-19 18:06:05 +1100563
564cc_library(
565 name = "distance_spline",
566 srcs = ["distance_spline.cc"],
567 hdrs = ["distance_spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800568 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100569 deps = [
570 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800571 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100572 "//frc971/control_loops:fixed_quadrature",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700573 "@org_tuxfamily_eigen//:eigen",
Austin Schuh941b46d2018-12-19 18:06:05 +1100574 ],
575)
576
577cc_test(
578 name = "distance_spline_test",
579 srcs = [
580 "distance_spline_test.cc",
581 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800582 defines =
583 cpu_select({
584 "amd64": [
585 "SUPPORT_PLOT=1",
586 ],
587 "arm": [],
588 }),
589 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800590 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100591 deps = [
592 ":distance_spline",
593 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800594 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100595 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800596 ] + cpu_select({
597 "amd64": [
598 "//third_party/matplotlib-cpp",
599 ],
600 "arm": [],
601 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100602)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100603
604cc_library(
605 name = "trajectory",
606 srcs = ["trajectory.cc"],
607 hdrs = ["trajectory.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800608 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100609 deps = [
610 ":distance_spline",
611 ":drivetrain_config",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100612 "//frc971/control_loops:c2d",
613 "//frc971/control_loops:dlqr",
614 "//frc971/control_loops:hybrid_state_feedback_loop",
615 "//frc971/control_loops:runge_kutta",
616 "//frc971/control_loops:state_feedback_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700617 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100618 ],
619)
620
621cc_binary(
622 name = "trajectory_plot",
623 srcs = [
624 "trajectory_plot.cc",
625 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800626 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100627 deps = [
628 ":distance_spline",
629 ":trajectory",
630 "//aos/logging:implementations",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100631 "//aos/network:team_number",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100632 "//third_party/matplotlib-cpp",
Austin Schuh11043182019-03-23 22:29:12 -0700633 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100634 "@com_github_gflags_gflags//:gflags",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700635 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100636 ],
637)
638
639cc_test(
640 name = "trajectory_test",
641 srcs = [
642 "trajectory_test.cc",
643 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800644 defines =
645 cpu_select({
646 "amd64": [
647 "SUPPORT_PLOT=1",
648 ],
649 "arm": [],
650 }),
651 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800652 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100653 deps = [
654 ":trajectory",
James Kuszmaulea314d92019-02-18 19:45:06 -0800655 ":drivetrain_test_lib",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100656 "//aos/testing:googletest",
657 "//aos/testing:test_shm",
658 "//y2016:constants",
659 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaulea314d92019-02-18 19:45:06 -0800660 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuh719a33e2019-01-07 15:13:34 -0800661 ] + cpu_select({
662 "amd64": [
663 "//third_party/matplotlib-cpp",
664 ],
665 "arm": [],
666 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100667)
Austin Schuhca080812017-05-10 19:31:55 -0700668
669cc_library(
670 name = "improved_down_estimator",
671 srcs = [
672 "improved_down_estimator.cc",
673 ],
674 hdrs = [
675 "improved_down_estimator.h",
676 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800677 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700678 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800679 ":drivetrain_config",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800680 ":drivetrain_status_fbs",
Brian Silvermandac0a4b2020-06-23 17:03:09 -0700681 "//aos/controls:quaternion_utils",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800682 "//aos/events:event_loop",
683 "//frc971/control_loops:control_loops_fbs",
Austin Schuhca080812017-05-10 19:31:55 -0700684 "//frc971/control_loops:runge_kutta",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800685 "@//aos/time",
Austin Schuhca080812017-05-10 19:31:55 -0700686 "@com_github_google_glog//:glog",
687 "@org_tuxfamily_eigen//:eigen",
688 ],
689)
690
691cc_test(
692 name = "improved_down_estimator_test",
693 srcs = [
694 "improved_down_estimator_test.cc",
695 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800696 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700697 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800698 ":drivetrain_test_lib",
Brian Silvermandac0a4b2020-06-23 17:03:09 -0700699 "//aos/controls:quaternion_utils",
Austin Schuhca080812017-05-10 19:31:55 -0700700 "//aos/testing:googletest",
701 "//aos/testing:random_seed",
702 "//frc971/control_loops/drivetrain:improved_down_estimator",
703 "@org_tuxfamily_eigen//:eigen",
704 ],
705)
James Kuszmaulf4ede202020-02-14 08:47:40 -0800706
707cc_library(
708 name = "camera",
709 srcs = ["camera.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800710 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800711 visibility = ["//visibility:public"],
712 deps = [
713 "//aos/containers:sized_array",
714 "//frc971/control_loops:pose",
715 ],
716)
717
718cc_test(
719 name = "camera_test",
720 srcs = ["camera_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800721 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800722 deps = [
723 ":camera",
724 "//aos/testing:googletest",
725 ],
726)
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800727
728ts_library(
729 name = "drivetrain_plotter",
730 srcs = ["drivetrain_plotter.ts"],
731 target_compatible_with = ["@platforms//os:linux"],
732 deps = [
733 "//aos/network/www:aos_plotter",
734 "//aos/network/www:proxy",
735 "//frc971/wpilib:imu_plot_utils",
736 ],
737)
milind upadhyay9bd381d2021-01-23 13:44:13 -0800738
739ts_library(
740 name = "robot_state_plotter",
741 srcs = ["robot_state_plotter.ts"],
742 target_compatible_with = ["@platforms//os:linux"],
743 deps = [
744 "//aos/network/www:aos_plotter",
745 "//aos/network/www:proxy",
746 ],
747)