blob: 4e6f373aa97360c0345b3989751bcebe24bace44 [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(
James Kuszmaul75a18c52021-03-10 22:02:07 -08009 name = "spline_goal_fbs",
10 srcs = ["spline_goal.fbs"],
11 gen_reflections = 1,
12 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
13)
14
15flatbuffer_cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -070016 name = "drivetrain_goal_fbs",
17 srcs = ["drivetrain_goal.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070018 gen_reflections = 1,
James Kuszmaul75a18c52021-03-10 22:02:07 -080019 includes = [
20 ":spline_goal_fbs_includes",
21 "//frc971/control_loops:control_loops_fbs_includes",
22 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +000023)
24
Alex Perrycb7da4b2019-08-28 19:35:56 -070025flatbuffer_cc_library(
26 name = "drivetrain_output_fbs",
27 srcs = ["drivetrain_output.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070028 gen_reflections = 1,
29)
30
31flatbuffer_cc_library(
32 name = "drivetrain_position_fbs",
33 srcs = ["drivetrain_position.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070034 gen_reflections = 1,
35)
36
37flatbuffer_cc_library(
38 name = "drivetrain_status_fbs",
39 srcs = ["drivetrain_status.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070040 gen_reflections = 1,
41 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
42)
43
James Kuszmaul75a18c52021-03-10 22:02:07 -080044flatbuffer_cc_library(
45 name = "trajectory_fbs",
46 srcs = ["trajectory.fbs"],
47 gen_reflections = 1,
48 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
49)
50
Alex Perry2124ae82020-03-07 14:19:06 -080051flatbuffer_ts_library(
52 name = "drivetrain_status_ts_fbs",
53 srcs = ["drivetrain_status.fbs"],
54 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
Philipp Schraderdada1072020-11-24 11:34:46 -080055 target_compatible_with = ["@platforms//os:linux"],
Alex Perry2124ae82020-03-07 14:19:06 -080056)
57
Alex Perrycb7da4b2019-08-28 19:35:56 -070058genrule(
59 name = "drivetrain_goal_float_fbs_generated",
60 srcs = ["drivetrain_goal.fbs"],
61 outs = ["drivetrain_goal_float.fbs"],
62 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070063)
64
65genrule(
66 name = "drivetrain_position_float_fbs_generated",
67 srcs = ["drivetrain_position.fbs"],
68 outs = ["drivetrain_position_float.fbs"],
69 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070070)
71
72genrule(
73 name = "drivetrain_output_float_fbs_generated",
74 srcs = ["drivetrain_output.fbs"],
75 outs = ["drivetrain_output_float.fbs"],
76 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070077)
78
79genrule(
80 name = "drivetrain_status_float_fbs_generated",
81 srcs = ["drivetrain_status.fbs"],
82 outs = ["drivetrain_status_float.fbs"],
83 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070084)
85
86flatbuffer_cc_library(
87 name = "drivetrain_goal_float_fbs",
88 srcs = ["drivetrain_goal_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070089 gen_reflections = 1,
James Kuszmaul75a18c52021-03-10 22:02:07 -080090 includes = [
91 ":spline_goal_fbs_includes",
92 "//frc971/control_loops:control_loops_fbs_includes",
93 ],
Alex Perrycb7da4b2019-08-28 19:35:56 -070094)
95
96flatbuffer_cc_library(
97 name = "drivetrain_output_float_fbs",
98 srcs = ["drivetrain_output_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070099 gen_reflections = 1,
100)
101
102flatbuffer_cc_library(
103 name = "drivetrain_position_float_fbs",
104 srcs = ["drivetrain_position_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700105 gen_reflections = 1,
106)
107
108flatbuffer_cc_library(
109 name = "drivetrain_status_float_fbs",
110 srcs = ["drivetrain_status_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700111 gen_reflections = 1,
112 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
113)
114
115aos_config(
James Kuszmaul74d8f972020-02-11 17:13:17 -0800116 name = "simulation_channels",
117 src = "drivetrain_simulation_channels.json",
118 flatbuffers = [
119 ":drivetrain_status_fbs",
120 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800121 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800122 visibility = ["//visibility:public"],
123)
124
125aos_config(
126 name = "simulation_config",
127 src = "drivetrain_simulation_config.json",
Philipp Schraderdada1072020-11-24 11:34:46 -0800128 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800129 visibility = ["//visibility:public"],
130 deps = [
131 ":config",
132 ":simulation_channels",
133 ],
134)
135
136aos_config(
Alex Perrycb7da4b2019-08-28 19:35:56 -0700137 name = "config",
138 src = "drivetrain_config.json",
139 flatbuffers = [
140 ":drivetrain_goal_fbs",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800141 ":trajectory_fbs",
142 ":spline_goal_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700143 ":drivetrain_output_fbs",
144 ":drivetrain_status_fbs",
145 ":drivetrain_position_fbs",
146 ":localizer_fbs",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800147 "//frc971/queues:gyro_fbs",
148 "//frc971/queues:gyro_uid_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700149 "//frc971/wpilib:imu_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700150 "//frc971/wpilib:imu_batch_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700151 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800152 target_compatible_with = ["@platforms//os:linux"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700153 visibility = ["//visibility:public"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700154 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700155 "//aos/robot_state:config",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700156 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000157)
158
159cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700160 name = "drivetrain_config",
161 hdrs = [
162 "drivetrain_config.h",
163 ],
164 deps = [
165 "//frc971:shifter_hall_effect",
166 "//frc971/control_loops:state_feedback_loop",
Philipp Schraderdada1072020-11-24 11:34:46 -0800167 ] + select({
168 "@platforms//os:linux": ["//frc971/control_loops:hybrid_state_feedback_loop"],
169 "//conditions:default": [],
170 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000171)
172
173cc_library(
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800174 name = "hybrid_ekf",
175 hdrs = ["hybrid_ekf.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800176 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800177 deps = [
178 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800179 "//aos:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800180 "//aos/containers:priority_queue",
James Kuszmaulfedc4612019-03-10 11:24:51 -0700181 "//aos/util:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800182 "//frc971/control_loops:c2d",
183 "//frc971/control_loops:runge_kutta",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700184 "@org_tuxfamily_eigen//:eigen",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800185 ],
186)
187
188cc_test(
189 name = "hybrid_ekf_test",
190 srcs = ["hybrid_ekf_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800191 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800192 deps = [
193 ":drivetrain_test_lib",
194 ":hybrid_ekf",
195 ":trajectory",
196 "//aos/testing:googletest",
197 "//aos/testing:random_seed",
198 "//aos/testing:test_shm",
199 ],
200)
201
Alex Perrycb7da4b2019-08-28 19:35:56 -0700202flatbuffer_cc_library(
203 name = "localizer_fbs",
204 srcs = ["localizer.fbs"],
205 gen_reflections = 1,
Philipp Schraderdada1072020-11-24 11:34:46 -0800206 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulef428a02019-03-02 22:19:41 -0800207)
208
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800209cc_library(
James Kuszmaul3431d622019-02-17 17:07:44 -0800210 name = "localizer",
211 hdrs = ["localizer.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800212 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul3431d622019-02-17 17:07:44 -0800213 deps = [
214 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800215 ":drivetrain_status_fbs",
James Kuszmaul3431d622019-02-17 17:07:44 -0800216 ":hybrid_ekf",
James Kuszmaul5398fae2020-02-17 16:44:03 -0800217 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800218 "//frc971/control_loops:pose",
James Kuszmaul3431d622019-02-17 17:07:44 -0800219 ],
220)
221
222cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700223 name = "gear",
224 hdrs = [
225 "gear.h",
226 ],
Austin Schuh093535c2016-03-05 23:21:00 -0800227)
228
229cc_library(
Alex Perry731b4602019-02-02 22:13:01 -0800230 name = "splinedrivetrain",
231 srcs = [
232 "splinedrivetrain.cc",
233 ],
234 hdrs = [
235 "splinedrivetrain.h",
236 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800237 target_compatible_with = ["@platforms//os:linux"],
Alex Perry731b4602019-02-02 22:13:01 -0800238 deps = [
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800239 ":distance_spline",
Alex Perry731b4602019-02-02 22:13:01 -0800240 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700241 ":drivetrain_goal_fbs",
242 ":drivetrain_output_fbs",
243 ":drivetrain_status_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800244 ":spline",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800245 ":spline_goal_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800246 ":trajectory",
Austin Schuh3d9ccd72020-08-01 15:42:40 -0700247 "//aos:condition",
Alex Perry1ec34522019-02-17 22:44:10 -0800248 "//aos:init",
James Kuszmaulc73bb222019-04-07 12:15:35 -0700249 "//aos/util:math",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700250 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800251 ],
Alex Perry731b4602019-02-02 22:13:01 -0800252)
253
254cc_library(
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800255 name = "line_follow_drivetrain",
256 srcs = [
257 "line_follow_drivetrain.cc",
258 ],
259 hdrs = [
260 "line_follow_drivetrain.h",
261 ],
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",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700265 ":drivetrain_goal_fbs",
266 ":drivetrain_output_fbs",
267 ":drivetrain_status_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800268 ":localizer",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800269 ":spline_goal_fbs",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800270 "//aos:math",
271 "//aos/util:math",
272 "//frc971/control_loops:c2d",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700273 "//frc971/control_loops:control_loops_fbs",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800274 "//frc971/control_loops:dlqr",
275 "//frc971/control_loops:pose",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700276 "//frc971/control_loops:profiled_subsystem_fbs",
277 "//y2019/control_loops/superstructure:superstructure_goal_fbs",
278 "@org_tuxfamily_eigen//:eigen",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800279 ],
280)
281
282cc_test(
283 name = "line_follow_drivetrain_test",
284 srcs = ["line_follow_drivetrain_test.cc"],
285 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800286 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800287 deps = [
288 ":drivetrain_config",
289 ":drivetrain_test_lib",
290 ":line_follow_drivetrain",
291 ":trajectory",
292 "//aos/testing:googletest",
293 "//aos/testing:test_shm",
294 "//third_party/matplotlib-cpp",
295 "@com_github_gflags_gflags//:gflags",
296 ],
297)
298
299cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700300 name = "ssdrivetrain",
301 srcs = [
302 "ssdrivetrain.cc",
303 ],
304 hdrs = [
305 "ssdrivetrain.h",
306 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800307 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700308 deps = [
309 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700310 ":drivetrain_goal_fbs",
311 ":drivetrain_output_fbs",
Austin Schuh95771d92021-01-23 14:42:25 -0800312 ":drivetrain_states",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700313 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700314 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800315 ":localizer",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800316 ":spline_goal_fbs",
John Park33858a32018-09-28 23:05:48 -0700317 "//aos:math",
318 "//aos/controls:control_loop",
319 "//aos/controls:polytope",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700320 "//aos/robot_state:robot_state_fbs",
John Park33858a32018-09-28 23:05:48 -0700321 "//aos/util:log_interval",
322 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700323 "//frc971:shifter_hall_effect",
324 "//frc971/control_loops:coerce_goal",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700325 "//frc971/control_loops:control_loops_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700326 "//frc971/control_loops:state_feedback_loop",
327 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000328)
329
330cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700331 name = "polydrivetrain",
332 srcs = [
333 "polydrivetrain.cc",
334 ],
335 hdrs = [
336 "polydrivetrain.h",
337 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800338 copts = select({
339 "@platforms//os:none": ["-Wno-type-limits"],
340 "//conditions:default": [],
341 }),
Austin Schuhbcce26a2018-03-26 23:41:24 -0700342 deps = [
343 ":drivetrain_config",
Austin Schuh95771d92021-01-23 14:42:25 -0800344 ":drivetrain_states",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700345 ":gear",
John Park33858a32018-09-28 23:05:48 -0700346 "//aos:math",
347 "//aos/controls:polytope",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700348 "//frc971/control_loops:coerce_goal",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700349 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800350 ":spline_goal_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700351 "//frc971/control_loops:state_feedback_loop",
Philipp Schraderdada1072020-11-24 11:34:46 -0800352 ] + select({
353 "@platforms//os:linux": [
354 ":drivetrain_goal_fbs",
355 ":drivetrain_output_fbs",
356 ":drivetrain_position_fbs",
357 ":drivetrain_status_fbs",
358 "//aos/robot_state:robot_state_fbs",
359 "//aos/util:log_interval",
360 ],
361 "@platforms//os:none": [
362 ":drivetrain_goal_float_fbs",
363 ":drivetrain_output_float_fbs",
364 ":drivetrain_position_float_fbs",
365 ":drivetrain_status_float_fbs",
366 ],
367 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000368)
369
Austin Schuh05c5a612016-04-02 15:10:25 -0700370genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700371 name = "genrule_down_estimator",
372 outs = [
373 "down_estimator.h",
374 "down_estimator.cc",
375 ],
376 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
Philipp Schraderdada1072020-11-24 11:34:46 -0800377 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700378 tools = [
379 "//frc971/control_loops/python:down_estimator",
380 ],
381 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700382)
383
384cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700385 name = "down_estimator",
386 srcs = [
387 "down_estimator.cc",
388 ],
389 hdrs = [
390 "down_estimator.h",
391 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800392 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700393 deps = [
394 "//frc971/control_loops:state_feedback_loop",
395 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700396)
397
Comran Morshed5323ecb2015-12-26 20:50:55 +0000398cc_library(
Austin Schuh95771d92021-01-23 14:42:25 -0800399 name = "drivetrain_states",
400 hdrs = ["drivetrain_states.h"],
401)
402
403cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700404 name = "drivetrain_lib",
405 srcs = [
406 "drivetrain.cc",
407 ],
408 hdrs = [
409 "drivetrain.h",
410 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800411 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700412 deps = [
413 ":down_estimator",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700414 ":drivetrain_goal_fbs",
415 ":drivetrain_output_fbs",
416 ":drivetrain_position_fbs",
Austin Schuh95771d92021-01-23 14:42:25 -0800417 ":drivetrain_states",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700418 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700419 ":gear",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800420 ":improved_down_estimator",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800421 ":line_follow_drivetrain",
James Kuszmaul3431d622019-02-17 17:07:44 -0800422 ":localizer",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700423 ":localizer_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700424 ":polydrivetrain",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800425 ":spline_goal_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800426 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800427 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700428 "//aos/controls:control_loop",
John Park33858a32018-09-28 23:05:48 -0700429 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800430 "//frc971/control_loops:runge_kutta",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800431 "//frc971/queues:gyro_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700432 "//frc971/wpilib:imu_batch_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700433 "//frc971/wpilib:imu_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800434 "//frc971/zeroing:imu_zeroer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700435 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000436)
437
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800438cc_library(
439 name = "drivetrain_test_lib",
440 testonly = True,
441 srcs = ["drivetrain_test_lib.cc"],
442 hdrs = ["drivetrain_test_lib.h"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800443 defines =
444 cpu_select({
445 "amd64": [
446 "SUPPORT_PLOT=1",
447 ],
448 "arm": [],
449 }),
Philipp Schraderdada1072020-11-24 11:34:46 -0800450 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800451 deps = [
452 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700453 ":drivetrain_goal_fbs",
454 ":drivetrain_output_fbs",
455 ":drivetrain_position_fbs",
456 ":drivetrain_status_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800457 ":trajectory",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700458 "//aos/events:event_loop",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800459 "//aos/testing:googletest",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700460 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800461 "//frc971/control_loops:state_feedback_loop",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800462 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800463 "//frc971/wpilib:imu_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700464 "//frc971/wpilib:imu_batch_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800465 "//y2016:constants",
466 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800467 ] + cpu_select({
468 "amd64": [
469 "//third_party/matplotlib-cpp",
470 ],
471 "arm": [],
472 }),
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800473)
474
Comran Morshed5323ecb2015-12-26 20:50:55 +0000475cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700476 name = "drivetrain_lib_test",
477 srcs = [
478 "drivetrain_lib_test.cc",
479 ],
Austin Schuh14d7d3d2020-09-10 18:14:36 -0700480 data = [":simulation_config"],
Alex Perry04300d62019-02-17 14:37:04 -0800481 defines =
482 cpu_select({
483 "amd64": [
484 "SUPPORT_PLOT=1",
485 ],
486 "arm": [],
487 }),
488 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800489 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700490 deps = [
491 ":drivetrain_config",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800492 ":trajectory_generator",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700493 ":drivetrain_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700494 ":localizer_fbs",
495 ":drivetrain_goal_fbs",
496 ":drivetrain_status_fbs",
497 ":drivetrain_position_fbs",
498 ":drivetrain_output_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800499 ":drivetrain_test_lib",
John Park33858a32018-09-28 23:05:48 -0700500 "//aos/controls:control_loop_test",
Austin Schuhb06f03b2021-02-17 22:00:37 -0800501 "//aos/events/logging:log_writer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700502 "//aos/testing:googletest",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800503 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800504 "//frc971/wpilib:imu_fbs",
Alex Perry04300d62019-02-17 14:37:04 -0800505 ] + cpu_select({
506 "amd64": [
507 "//third_party/matplotlib-cpp",
508 ],
509 "arm": [],
510 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000511)
Brian Silverman6260c092018-01-14 15:21:36 -0800512
513genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700514 name = "genrule_haptic_wheel",
515 outs = [
516 "haptic_wheel.h",
517 "haptic_wheel.cc",
518 "integral_haptic_wheel.h",
519 "integral_haptic_wheel.cc",
520 "haptic_trigger.h",
521 "haptic_trigger.cc",
522 "integral_haptic_trigger.h",
523 "integral_haptic_trigger.cc",
524 ],
525 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700526 tools = [
527 "//frc971/control_loops/python:haptic_wheel",
528 ],
529 visibility = ["//visibility:private"],
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"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800555 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100556 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800557 "//frc971/control_loops:binomial",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700558 "@org_tuxfamily_eigen//:eigen",
Austin Schuhc2b08772018-12-19 18:05:06 +1100559 ],
560)
561
Alex Perrya60da442019-01-21 19:00:27 -0500562cc_binary(
563 name = "spline.so",
564 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800565 linkshared = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800566 target_compatible_with = ["@platforms//os:linux"],
Alex Perrya60da442019-01-21 19:00:27 -0500567 deps = [
568 ":distance_spline",
569 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800570 ":trajectory",
571 "//aos/logging:implementations",
572 "//aos/network:team_number",
James Kuszmaul8aa37cb2020-03-01 10:27:58 -0800573 "//y2020/control_loops/drivetrain:drivetrain_base",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700574 "@org_tuxfamily_eigen//:eigen",
Alex Perrya60da442019-01-21 19:00:27 -0500575 ],
Alex Perrya60da442019-01-21 19:00:27 -0500576)
577
Austin Schuhc2b08772018-12-19 18:05:06 +1100578cc_test(
579 name = "spline_test",
580 srcs = [
581 "spline_test.cc",
582 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800583 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100584 deps = [
585 ":spline",
586 "//aos/testing:googletest",
587 "//third_party/matplotlib-cpp",
588 "@com_github_gflags_gflags//:gflags",
589 ],
590)
Austin Schuh941b46d2018-12-19 18:06:05 +1100591
592cc_library(
593 name = "distance_spline",
594 srcs = ["distance_spline.cc"],
595 hdrs = ["distance_spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800596 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100597 deps = [
598 ":spline",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800599 ":trajectory_fbs",
Austin Schuha6e7b212019-01-20 13:53:01 -0800600 "//aos/logging",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800601 "//frc971/control_loops:control_loops_fbs",
Austin Schuh941b46d2018-12-19 18:06:05 +1100602 "//frc971/control_loops:fixed_quadrature",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800603 "@com_github_google_glog//:glog",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700604 "@org_tuxfamily_eigen//:eigen",
Austin Schuh941b46d2018-12-19 18:06:05 +1100605 ],
606)
607
608cc_test(
609 name = "distance_spline_test",
610 srcs = [
611 "distance_spline_test.cc",
612 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800613 defines =
614 cpu_select({
615 "amd64": [
616 "SUPPORT_PLOT=1",
617 ],
618 "arm": [],
619 }),
620 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800621 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100622 deps = [
623 ":distance_spline",
624 "//aos/testing:googletest",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800625 "//aos:flatbuffers",
Austin Schuha6e7b212019-01-20 13:53:01 -0800626 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100627 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800628 ] + cpu_select({
629 "amd64": [
630 "//third_party/matplotlib-cpp",
631 ],
632 "arm": [],
633 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100634)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100635
636cc_library(
637 name = "trajectory",
638 srcs = ["trajectory.cc"],
639 hdrs = ["trajectory.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800640 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100641 deps = [
642 ":distance_spline",
643 ":drivetrain_config",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800644 ":spline_goal_fbs",
645 ":trajectory_fbs",
James Kuszmaul5e8ce312021-03-27 14:59:17 -0700646 "//aos/util:math",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100647 "//frc971/control_loops:c2d",
648 "//frc971/control_loops:dlqr",
649 "//frc971/control_loops:hybrid_state_feedback_loop",
650 "//frc971/control_loops:runge_kutta",
651 "//frc971/control_loops:state_feedback_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700652 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100653 ],
654)
655
James Kuszmaul75a18c52021-03-10 22:02:07 -0800656cc_library(
657 name = "trajectory_generator",
658 srcs = ["trajectory_generator.cc"],
659 hdrs = ["trajectory_generator.h"],
660 target_compatible_with = ["@platforms//os:linux"],
661 deps = [
662 ":distance_spline",
663 ":drivetrain_config",
664 ":spline_goal_fbs",
665 ":trajectory",
666 ":trajectory_fbs",
667 ],
668)
669
Austin Schuhec7f06d2019-01-04 07:47:15 +1100670cc_binary(
671 name = "trajectory_plot",
672 srcs = [
673 "trajectory_plot.cc",
674 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800675 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100676 deps = [
677 ":distance_spline",
678 ":trajectory",
679 "//aos/logging:implementations",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100680 "//aos/network:team_number",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100681 "//third_party/matplotlib-cpp",
Austin Schuh11043182019-03-23 22:29:12 -0700682 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100683 "@com_github_gflags_gflags//:gflags",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700684 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100685 ],
686)
687
688cc_test(
689 name = "trajectory_test",
690 srcs = [
691 "trajectory_test.cc",
692 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800693 defines =
694 cpu_select({
695 "amd64": [
696 "SUPPORT_PLOT=1",
697 ],
698 "arm": [],
699 }),
700 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800701 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100702 deps = [
703 ":trajectory",
James Kuszmaulea314d92019-02-18 19:45:06 -0800704 ":drivetrain_test_lib",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100705 "//aos/testing:googletest",
706 "//aos/testing:test_shm",
707 "//y2016:constants",
708 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaulea314d92019-02-18 19:45:06 -0800709 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuh719a33e2019-01-07 15:13:34 -0800710 ] + cpu_select({
711 "amd64": [
712 "//third_party/matplotlib-cpp",
713 ],
714 "arm": [],
715 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100716)
Austin Schuhca080812017-05-10 19:31:55 -0700717
718cc_library(
719 name = "improved_down_estimator",
720 srcs = [
721 "improved_down_estimator.cc",
722 ],
723 hdrs = [
724 "improved_down_estimator.h",
725 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800726 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700727 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800728 ":drivetrain_config",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800729 ":drivetrain_status_fbs",
Brian Silvermandac0a4b2020-06-23 17:03:09 -0700730 "//aos/controls:quaternion_utils",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800731 "//aos/events:event_loop",
732 "//frc971/control_loops:control_loops_fbs",
Austin Schuhca080812017-05-10 19:31:55 -0700733 "//frc971/control_loops:runge_kutta",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800734 "@//aos/time",
Austin Schuhca080812017-05-10 19:31:55 -0700735 "@com_github_google_glog//:glog",
736 "@org_tuxfamily_eigen//:eigen",
737 ],
738)
739
740cc_test(
741 name = "improved_down_estimator_test",
742 srcs = [
743 "improved_down_estimator_test.cc",
744 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800745 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700746 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800747 ":drivetrain_test_lib",
Brian Silvermandac0a4b2020-06-23 17:03:09 -0700748 "//aos/controls:quaternion_utils",
Austin Schuhca080812017-05-10 19:31:55 -0700749 "//aos/testing:googletest",
750 "//aos/testing:random_seed",
751 "//frc971/control_loops/drivetrain:improved_down_estimator",
752 "@org_tuxfamily_eigen//:eigen",
753 ],
754)
James Kuszmaulf4ede202020-02-14 08:47:40 -0800755
756cc_library(
757 name = "camera",
758 srcs = ["camera.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800759 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800760 visibility = ["//visibility:public"],
761 deps = [
762 "//aos/containers:sized_array",
763 "//frc971/control_loops:pose",
764 ],
765)
766
767cc_test(
768 name = "camera_test",
769 srcs = ["camera_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800770 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800771 deps = [
772 ":camera",
773 "//aos/testing:googletest",
774 ],
775)
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800776
777ts_library(
James Kuszmaulac2b6b42021-03-07 22:38:06 -0800778 name = "down_estimator_plotter",
779 srcs = ["down_estimator_plotter.ts"],
780 target_compatible_with = ["@platforms//os:linux"],
781 deps = [
782 "//aos/network/www:aos_plotter",
783 "//aos/network/www:colors",
784 "//aos/network/www:proxy",
785 "//frc971/wpilib:imu_plot_utils",
786 ],
787)
788
789ts_library(
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800790 name = "drivetrain_plotter",
791 srcs = ["drivetrain_plotter.ts"],
792 target_compatible_with = ["@platforms//os:linux"],
793 deps = [
794 "//aos/network/www:aos_plotter",
James Kuszmaul933a9742021-03-07 19:59:06 -0800795 "//aos/network/www:colors",
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800796 "//aos/network/www:proxy",
797 "//frc971/wpilib:imu_plot_utils",
798 ],
799)
milind upadhyay9bd381d2021-01-23 13:44:13 -0800800
801ts_library(
802 name = "robot_state_plotter",
803 srcs = ["robot_state_plotter.ts"],
804 target_compatible_with = ["@platforms//os:linux"],
805 deps = [
806 "//aos/network/www:aos_plotter",
James Kuszmaul933a9742021-03-07 19:59:06 -0800807 "//aos/network/www:colors",
milind upadhyay9bd381d2021-01-23 13:44:13 -0800808 "//aos/network/www:proxy",
809 ],
810)