blob: 02f8e3a72e5c4004b0d23bd074b3f833648a35fb [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 = [
James Kuszmaul7077d342021-06-09 20:23:58 -0700155 "//frc971/input: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",
John Park33858a32018-09-28 23:05:48 -0700318 "//aos/util:log_interval",
319 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700320 "//frc971:shifter_hall_effect",
321 "//frc971/control_loops:coerce_goal",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700322 "//frc971/control_loops:control_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700323 "//frc971/control_loops:control_loops_fbs",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700324 "//frc971/control_loops:polytope",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700325 "//frc971/control_loops:state_feedback_loop",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700326 "//frc971/input:robot_state_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700327 ],
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",
James Kuszmaul61750662021-06-21 21:32:33 -0700347 "//frc971/control_loops: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",
James Kuszmaul7077d342021-06-09 20:23:58 -0700358 "//frc971/input:robot_state_fbs",
Philipp Schraderdada1072020-11-24 11:34:46 -0800359 "//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/util:log_interval",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700429 "//frc971/control_loops:control_loop",
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",
James Kuszmaul61750662021-06-21 21:32:33 -0700500 "//frc971/control_loops: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 ],
James Kuszmaule32fa932021-05-11 21:38:16 -0700583 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800584 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100585 deps = [
586 ":spline",
587 "//aos/testing:googletest",
James Kuszmaule32fa932021-05-11 21:38:16 -0700588 "//frc971/analysis:in_process_plotter",
Austin Schuhc2b08772018-12-19 18:05:06 +1100589 "@com_github_gflags_gflags//:gflags",
590 ],
591)
Austin Schuh941b46d2018-12-19 18:06:05 +1100592
593cc_library(
594 name = "distance_spline",
595 srcs = ["distance_spline.cc"],
596 hdrs = ["distance_spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800597 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100598 deps = [
599 ":spline",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800600 ":trajectory_fbs",
Austin Schuha6e7b212019-01-20 13:53:01 -0800601 "//aos/logging",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800602 "//frc971/control_loops:control_loops_fbs",
Austin Schuh941b46d2018-12-19 18:06:05 +1100603 "//frc971/control_loops:fixed_quadrature",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800604 "@com_github_google_glog//:glog",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700605 "@org_tuxfamily_eigen//:eigen",
Austin Schuh941b46d2018-12-19 18:06:05 +1100606 ],
607)
608
609cc_test(
610 name = "distance_spline_test",
611 srcs = [
612 "distance_spline_test.cc",
613 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800614 defines =
615 cpu_select({
616 "amd64": [
617 "SUPPORT_PLOT=1",
618 ],
619 "arm": [],
620 }),
621 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800622 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100623 deps = [
624 ":distance_spline",
625 "//aos/testing:googletest",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800626 "//aos:flatbuffers",
Austin Schuha6e7b212019-01-20 13:53:01 -0800627 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100628 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800629 ] + cpu_select({
630 "amd64": [
631 "//third_party/matplotlib-cpp",
632 ],
633 "arm": [],
634 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100635)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100636
637cc_library(
638 name = "trajectory",
639 srcs = ["trajectory.cc"],
640 hdrs = ["trajectory.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800641 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100642 deps = [
643 ":distance_spline",
644 ":drivetrain_config",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800645 ":spline_goal_fbs",
646 ":trajectory_fbs",
James Kuszmaul5e8ce312021-03-27 14:59:17 -0700647 "//aos/util:math",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100648 "//frc971/control_loops:c2d",
649 "//frc971/control_loops:dlqr",
650 "//frc971/control_loops:hybrid_state_feedback_loop",
651 "//frc971/control_loops:runge_kutta",
652 "//frc971/control_loops:state_feedback_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700653 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100654 ],
655)
656
James Kuszmaul75a18c52021-03-10 22:02:07 -0800657cc_library(
658 name = "trajectory_generator",
659 srcs = ["trajectory_generator.cc"],
660 hdrs = ["trajectory_generator.h"],
661 target_compatible_with = ["@platforms//os:linux"],
662 deps = [
663 ":distance_spline",
664 ":drivetrain_config",
665 ":spline_goal_fbs",
666 ":trajectory",
667 ":trajectory_fbs",
668 ],
669)
670
Austin Schuhec7f06d2019-01-04 07:47:15 +1100671cc_binary(
672 name = "trajectory_plot",
673 srcs = [
674 "trajectory_plot.cc",
675 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800676 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100677 deps = [
678 ":distance_spline",
679 ":trajectory",
680 "//aos/logging:implementations",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100681 "//aos/network:team_number",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100682 "//third_party/matplotlib-cpp",
Austin Schuh11043182019-03-23 22:29:12 -0700683 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100684 "@com_github_gflags_gflags//:gflags",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700685 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100686 ],
687)
688
689cc_test(
690 name = "trajectory_test",
691 srcs = [
692 "trajectory_test.cc",
693 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800694 defines =
695 cpu_select({
696 "amd64": [
697 "SUPPORT_PLOT=1",
698 ],
699 "arm": [],
700 }),
701 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800702 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100703 deps = [
704 ":trajectory",
James Kuszmaulea314d92019-02-18 19:45:06 -0800705 ":drivetrain_test_lib",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100706 "//aos/testing:googletest",
707 "//aos/testing:test_shm",
708 "//y2016:constants",
709 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaulea314d92019-02-18 19:45:06 -0800710 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuh719a33e2019-01-07 15:13:34 -0800711 ] + cpu_select({
712 "amd64": [
713 "//third_party/matplotlib-cpp",
714 ],
715 "arm": [],
716 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100717)
Austin Schuhca080812017-05-10 19:31:55 -0700718
719cc_library(
720 name = "improved_down_estimator",
721 srcs = [
722 "improved_down_estimator.cc",
723 ],
724 hdrs = [
725 "improved_down_estimator.h",
726 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800727 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700728 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800729 ":drivetrain_config",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800730 ":drivetrain_status_fbs",
731 "//aos/events:event_loop",
732 "//frc971/control_loops:control_loops_fbs",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700733 "//frc971/control_loops:quaternion_utils",
Austin Schuhca080812017-05-10 19:31:55 -0700734 "//frc971/control_loops:runge_kutta",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800735 "@//aos/time",
Austin Schuhca080812017-05-10 19:31:55 -0700736 "@com_github_google_glog//:glog",
737 "@org_tuxfamily_eigen//:eigen",
738 ],
739)
740
741cc_test(
742 name = "improved_down_estimator_test",
743 srcs = [
744 "improved_down_estimator_test.cc",
745 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800746 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700747 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800748 ":drivetrain_test_lib",
Austin Schuhca080812017-05-10 19:31:55 -0700749 "//aos/testing:googletest",
750 "//aos/testing:random_seed",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700751 "//frc971/control_loops:quaternion_utils",
Austin Schuhca080812017-05-10 19:31:55 -0700752 "//frc971/control_loops/drivetrain:improved_down_estimator",
753 "@org_tuxfamily_eigen//:eigen",
754 ],
755)
James Kuszmaulf4ede202020-02-14 08:47:40 -0800756
757cc_library(
758 name = "camera",
759 srcs = ["camera.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800760 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800761 visibility = ["//visibility:public"],
762 deps = [
763 "//aos/containers:sized_array",
764 "//frc971/control_loops:pose",
765 ],
766)
767
768cc_test(
769 name = "camera_test",
770 srcs = ["camera_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800771 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800772 deps = [
773 ":camera",
774 "//aos/testing:googletest",
775 ],
776)
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800777
778ts_library(
James Kuszmaulac2b6b42021-03-07 22:38:06 -0800779 name = "down_estimator_plotter",
780 srcs = ["down_estimator_plotter.ts"],
781 target_compatible_with = ["@platforms//os:linux"],
782 deps = [
783 "//aos/network/www:aos_plotter",
784 "//aos/network/www:colors",
785 "//aos/network/www:proxy",
786 "//frc971/wpilib:imu_plot_utils",
787 ],
788)
789
790ts_library(
James Kuszmaul73fc1352021-04-09 22:31:25 -0700791 name = "spline_plotter",
792 srcs = ["spline_plotter.ts"],
793 target_compatible_with = ["@platforms//os:linux"],
794 deps = [
795 "//aos/network/www:aos_plotter",
796 "//aos/network/www:colors",
797 "//aos/network/www:proxy",
798 ],
799)
800
801ts_library(
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800802 name = "drivetrain_plotter",
803 srcs = ["drivetrain_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",
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800808 "//aos/network/www:proxy",
809 "//frc971/wpilib:imu_plot_utils",
810 ],
811)
milind upadhyay9bd381d2021-01-23 13:44:13 -0800812
813ts_library(
814 name = "robot_state_plotter",
815 srcs = ["robot_state_plotter.ts"],
816 target_compatible_with = ["@platforms//os:linux"],
817 deps = [
818 "//aos/network/www:aos_plotter",
James Kuszmaul933a9742021-03-07 19:59:06 -0800819 "//aos/network/www:colors",
milind upadhyay9bd381d2021-01-23 13:44:13 -0800820 "//aos/network/www:proxy",
821 ],
822)