blob: 085e53f969b49237f7a01ee55a777b7d38b5fbd6 [file] [log] [blame]
Alex Perry2124ae82020-03-07 14:19:06 -08001load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_ts_library")
Alex Perrycb7da4b2019-08-28 19:35:56 -07002load("//aos:config.bzl", "aos_config")
Philipp Schraderdada1072020-11-24 11:34:46 -08003load("//tools/build_rules:select.bzl", "cpu_select")
Austin Schuh41fad8c2021-10-23 21:25:12 -07004load("//aos:flatbuffers.bzl", "cc_static_flatbuffer")
Philipp Schrader87277f42022-01-01 07:45:12 -08005load("@npm//@bazel/typescript:index.bzl", "ts_library")
Comran Morshed5323ecb2015-12-26 20:50:55 +00006
Philipp Schradercc016b32021-12-30 08:59:58 -08007package(default_visibility = ["//visibility:public"])
8
Alex Perrycb7da4b2019-08-28 19:35:56 -07009flatbuffer_cc_library(
James Kuszmaul75a18c52021-03-10 22:02:07 -080010 name = "spline_goal_fbs",
11 srcs = ["spline_goal.fbs"],
12 gen_reflections = 1,
13 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
14)
15
16flatbuffer_cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -070017 name = "drivetrain_goal_fbs",
18 srcs = ["drivetrain_goal.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070019 gen_reflections = 1,
James Kuszmaul75a18c52021-03-10 22:02:07 -080020 includes = [
21 ":spline_goal_fbs_includes",
22 "//frc971/control_loops:control_loops_fbs_includes",
23 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +000024)
25
Alex Perrycb7da4b2019-08-28 19:35:56 -070026flatbuffer_cc_library(
27 name = "drivetrain_output_fbs",
28 srcs = ["drivetrain_output.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070029 gen_reflections = 1,
30)
31
32flatbuffer_cc_library(
33 name = "drivetrain_position_fbs",
34 srcs = ["drivetrain_position.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070035 gen_reflections = 1,
36)
37
38flatbuffer_cc_library(
39 name = "drivetrain_status_fbs",
40 srcs = ["drivetrain_status.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070041 gen_reflections = 1,
42 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
43)
44
James Kuszmaul75a18c52021-03-10 22:02:07 -080045flatbuffer_cc_library(
46 name = "trajectory_fbs",
47 srcs = ["trajectory.fbs"],
48 gen_reflections = 1,
49 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
50)
51
Austin Schuh41fad8c2021-10-23 21:25:12 -070052cc_static_flatbuffer(
53 name = "trajectory_schema",
54 function = "frc971::control_loops::drivetrain::fb::TrajectorySchema",
55 target = ":trajectory_fbs_reflection_out",
56 visibility = ["//visibility:public"],
57)
58
Alex Perry2124ae82020-03-07 14:19:06 -080059flatbuffer_ts_library(
60 name = "drivetrain_status_ts_fbs",
61 srcs = ["drivetrain_status.fbs"],
Philipp Schraderdada1072020-11-24 11:34:46 -080062 target_compatible_with = ["@platforms//os:linux"],
James Kuszmauldac091f2022-03-22 09:35:06 -070063 deps = ["//frc971/control_loops:control_loops_ts_fbs"],
Alex Perry2124ae82020-03-07 14:19:06 -080064)
65
Alex Perrycb7da4b2019-08-28 19:35:56 -070066genrule(
67 name = "drivetrain_goal_float_fbs_generated",
68 srcs = ["drivetrain_goal.fbs"],
69 outs = ["drivetrain_goal_float.fbs"],
70 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070071)
72
73genrule(
74 name = "drivetrain_position_float_fbs_generated",
75 srcs = ["drivetrain_position.fbs"],
76 outs = ["drivetrain_position_float.fbs"],
77 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070078)
79
80genrule(
81 name = "drivetrain_output_float_fbs_generated",
82 srcs = ["drivetrain_output.fbs"],
83 outs = ["drivetrain_output_float.fbs"],
84 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070085)
86
87genrule(
88 name = "drivetrain_status_float_fbs_generated",
89 srcs = ["drivetrain_status.fbs"],
90 outs = ["drivetrain_status_float.fbs"],
91 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070092)
93
94flatbuffer_cc_library(
95 name = "drivetrain_goal_float_fbs",
96 srcs = ["drivetrain_goal_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070097 gen_reflections = 1,
James Kuszmaul75a18c52021-03-10 22:02:07 -080098 includes = [
99 ":spline_goal_fbs_includes",
100 "//frc971/control_loops:control_loops_fbs_includes",
101 ],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700102)
103
104flatbuffer_cc_library(
105 name = "drivetrain_output_float_fbs",
106 srcs = ["drivetrain_output_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700107 gen_reflections = 1,
108)
109
110flatbuffer_cc_library(
111 name = "drivetrain_position_float_fbs",
112 srcs = ["drivetrain_position_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700113 gen_reflections = 1,
114)
115
116flatbuffer_cc_library(
117 name = "drivetrain_status_float_fbs",
118 srcs = ["drivetrain_status_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700119 gen_reflections = 1,
120 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
121)
122
123aos_config(
James Kuszmaul74d8f972020-02-11 17:13:17 -0800124 name = "simulation_channels",
125 src = "drivetrain_simulation_channels.json",
126 flatbuffers = [
127 ":drivetrain_status_fbs",
128 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800129 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800130 visibility = ["//visibility:public"],
131)
132
133aos_config(
134 name = "simulation_config",
135 src = "drivetrain_simulation_config.json",
Philipp Schraderdada1072020-11-24 11:34:46 -0800136 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800137 visibility = ["//visibility:public"],
138 deps = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800139 ":aos_config",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800140 ":simulation_channels",
141 ],
142)
143
144aos_config(
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800145 name = "aos_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700146 src = "drivetrain_config.json",
147 flatbuffers = [
148 ":drivetrain_goal_fbs",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800149 ":trajectory_fbs",
150 ":spline_goal_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700151 ":drivetrain_output_fbs",
152 ":drivetrain_status_fbs",
153 ":drivetrain_position_fbs",
154 ":localizer_fbs",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800155 "//frc971/queues:gyro_fbs",
156 "//frc971/queues:gyro_uid_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700157 "//frc971/wpilib:imu_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700158 "//frc971/wpilib:imu_batch_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700159 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800160 target_compatible_with = ["@platforms//os:linux"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700161 visibility = ["//visibility:public"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700162 deps = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800163 "//frc971/input:aos_config",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700164 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000165)
166
167cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700168 name = "drivetrain_config",
169 hdrs = [
170 "drivetrain_config.h",
171 ],
172 deps = [
173 "//frc971:shifter_hall_effect",
174 "//frc971/control_loops:state_feedback_loop",
Philipp Schraderdada1072020-11-24 11:34:46 -0800175 ] + select({
176 "@platforms//os:linux": ["//frc971/control_loops:hybrid_state_feedback_loop"],
177 "//conditions:default": [],
178 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000179)
180
181cc_library(
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800182 name = "hybrid_ekf",
183 hdrs = ["hybrid_ekf.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800184 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800185 deps = [
186 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800187 "//aos:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800188 "//aos/containers:priority_queue",
James Kuszmaulfedc4612019-03-10 11:24:51 -0700189 "//aos/util:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800190 "//frc971/control_loops:c2d",
191 "//frc971/control_loops:runge_kutta",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700192 "@org_tuxfamily_eigen//:eigen",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800193 ],
194)
195
196cc_test(
197 name = "hybrid_ekf_test",
198 srcs = ["hybrid_ekf_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800199 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800200 deps = [
201 ":drivetrain_test_lib",
202 ":hybrid_ekf",
203 ":trajectory",
204 "//aos/testing:googletest",
205 "//aos/testing:random_seed",
206 "//aos/testing:test_shm",
207 ],
208)
209
Alex Perrycb7da4b2019-08-28 19:35:56 -0700210flatbuffer_cc_library(
211 name = "localizer_fbs",
212 srcs = ["localizer.fbs"],
213 gen_reflections = 1,
Philipp Schraderdada1072020-11-24 11:34:46 -0800214 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulef428a02019-03-02 22:19:41 -0800215)
216
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800217cc_library(
James Kuszmaul3431d622019-02-17 17:07:44 -0800218 name = "localizer",
219 hdrs = ["localizer.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800220 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul3431d622019-02-17 17:07:44 -0800221 deps = [
222 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800223 ":drivetrain_status_fbs",
James Kuszmaul3431d622019-02-17 17:07:44 -0800224 ":hybrid_ekf",
James Kuszmaul5398fae2020-02-17 16:44:03 -0800225 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800226 "//frc971/control_loops:pose",
James Kuszmaul3431d622019-02-17 17:07:44 -0800227 ],
228)
229
230cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700231 name = "gear",
232 hdrs = [
233 "gear.h",
234 ],
Austin Schuh093535c2016-03-05 23:21:00 -0800235)
236
237cc_library(
Alex Perry731b4602019-02-02 22:13:01 -0800238 name = "splinedrivetrain",
239 srcs = [
240 "splinedrivetrain.cc",
241 ],
242 hdrs = [
243 "splinedrivetrain.h",
244 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800245 target_compatible_with = ["@platforms//os:linux"],
Alex Perry731b4602019-02-02 22:13:01 -0800246 deps = [
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800247 ":distance_spline",
Alex Perry731b4602019-02-02 22:13:01 -0800248 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700249 ":drivetrain_goal_fbs",
250 ":drivetrain_output_fbs",
251 ":drivetrain_status_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800252 ":spline",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800253 ":spline_goal_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800254 ":trajectory",
Austin Schuh3d9ccd72020-08-01 15:42:40 -0700255 "//aos:condition",
Alex Perry1ec34522019-02-17 22:44:10 -0800256 "//aos:init",
James Kuszmaulc73bb222019-04-07 12:15:35 -0700257 "//aos/util:math",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700258 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800259 ],
Alex Perry731b4602019-02-02 22:13:01 -0800260)
261
262cc_library(
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800263 name = "line_follow_drivetrain",
264 srcs = [
265 "line_follow_drivetrain.cc",
266 ],
267 hdrs = [
268 "line_follow_drivetrain.h",
269 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800270 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800271 deps = [
272 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700273 ":drivetrain_goal_fbs",
274 ":drivetrain_output_fbs",
275 ":drivetrain_status_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800276 ":localizer",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800277 ":spline_goal_fbs",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800278 "//aos:math",
279 "//aos/util:math",
280 "//frc971/control_loops:c2d",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700281 "//frc971/control_loops:control_loops_fbs",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800282 "//frc971/control_loops:dlqr",
283 "//frc971/control_loops:pose",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700284 "//frc971/control_loops:profiled_subsystem_fbs",
285 "//y2019/control_loops/superstructure:superstructure_goal_fbs",
286 "@org_tuxfamily_eigen//:eigen",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800287 ],
288)
289
290cc_test(
291 name = "line_follow_drivetrain_test",
292 srcs = ["line_follow_drivetrain_test.cc"],
293 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800294 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800295 deps = [
296 ":drivetrain_config",
297 ":drivetrain_test_lib",
298 ":line_follow_drivetrain",
299 ":trajectory",
300 "//aos/testing:googletest",
301 "//aos/testing:test_shm",
302 "//third_party/matplotlib-cpp",
303 "@com_github_gflags_gflags//:gflags",
304 ],
305)
306
307cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700308 name = "ssdrivetrain",
309 srcs = [
310 "ssdrivetrain.cc",
311 ],
312 hdrs = [
313 "ssdrivetrain.h",
314 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800315 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700316 deps = [
317 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700318 ":drivetrain_goal_fbs",
319 ":drivetrain_output_fbs",
Austin Schuh95771d92021-01-23 14:42:25 -0800320 ":drivetrain_states",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700321 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700322 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800323 ":localizer",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800324 ":spline_goal_fbs",
John Park33858a32018-09-28 23:05:48 -0700325 "//aos:math",
John Park33858a32018-09-28 23:05:48 -0700326 "//aos/util:log_interval",
327 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700328 "//frc971:shifter_hall_effect",
329 "//frc971/control_loops:coerce_goal",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700330 "//frc971/control_loops:control_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700331 "//frc971/control_loops:control_loops_fbs",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700332 "//frc971/control_loops:polytope",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700333 "//frc971/control_loops:state_feedback_loop",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700334 "//frc971/input:robot_state_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700335 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000336)
337
338cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700339 name = "polydrivetrain",
340 srcs = [
341 "polydrivetrain.cc",
342 ],
343 hdrs = [
344 "polydrivetrain.h",
345 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800346 copts = select({
347 "@platforms//os:none": ["-Wno-type-limits"],
348 "//conditions:default": [],
349 }),
Austin Schuhbcce26a2018-03-26 23:41:24 -0700350 deps = [
351 ":drivetrain_config",
Austin Schuh95771d92021-01-23 14:42:25 -0800352 ":drivetrain_states",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700353 ":gear",
John Park33858a32018-09-28 23:05:48 -0700354 "//aos:math",
James Kuszmaul61750662021-06-21 21:32:33 -0700355 "//frc971/control_loops:polytope",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700356 "//frc971/control_loops:coerce_goal",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700357 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800358 ":spline_goal_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700359 "//frc971/control_loops:state_feedback_loop",
Philipp Schraderdada1072020-11-24 11:34:46 -0800360 ] + select({
361 "@platforms//os:linux": [
362 ":drivetrain_goal_fbs",
363 ":drivetrain_output_fbs",
364 ":drivetrain_position_fbs",
365 ":drivetrain_status_fbs",
James Kuszmaul7077d342021-06-09 20:23:58 -0700366 "//frc971/input:robot_state_fbs",
Philipp Schraderdada1072020-11-24 11:34:46 -0800367 "//aos/util:log_interval",
368 ],
369 "@platforms//os:none": [
370 ":drivetrain_goal_float_fbs",
371 ":drivetrain_output_float_fbs",
372 ":drivetrain_position_float_fbs",
373 ":drivetrain_status_float_fbs",
374 ],
375 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000376)
377
Austin Schuh05c5a612016-04-02 15:10:25 -0700378genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700379 name = "genrule_down_estimator",
380 outs = [
381 "down_estimator.h",
382 "down_estimator.cc",
383 ],
384 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
Philipp Schraderdada1072020-11-24 11:34:46 -0800385 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700386 tools = [
387 "//frc971/control_loops/python:down_estimator",
388 ],
389 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700390)
391
392cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700393 name = "down_estimator",
394 srcs = [
395 "down_estimator.cc",
396 ],
397 hdrs = [
398 "down_estimator.h",
399 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800400 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700401 deps = [
402 "//frc971/control_loops:state_feedback_loop",
403 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700404)
405
Comran Morshed5323ecb2015-12-26 20:50:55 +0000406cc_library(
Austin Schuh95771d92021-01-23 14:42:25 -0800407 name = "drivetrain_states",
408 hdrs = ["drivetrain_states.h"],
409)
410
411cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700412 name = "drivetrain_lib",
413 srcs = [
414 "drivetrain.cc",
415 ],
416 hdrs = [
417 "drivetrain.h",
418 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800419 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700420 deps = [
421 ":down_estimator",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700422 ":drivetrain_goal_fbs",
423 ":drivetrain_output_fbs",
424 ":drivetrain_position_fbs",
Austin Schuh95771d92021-01-23 14:42:25 -0800425 ":drivetrain_states",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700426 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700427 ":gear",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800428 ":improved_down_estimator",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800429 ":line_follow_drivetrain",
James Kuszmaul3431d622019-02-17 17:07:44 -0800430 ":localizer",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700431 ":localizer_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700432 ":polydrivetrain",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800433 ":spline_goal_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800434 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800435 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700436 "//aos/util:log_interval",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700437 "//frc971/control_loops:control_loop",
Austin Schuh3a378462019-01-04 21:48:04 -0800438 "//frc971/control_loops:runge_kutta",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800439 "//frc971/queues:gyro_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700440 "//frc971/wpilib:imu_batch_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700441 "//frc971/wpilib:imu_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800442 "//frc971/zeroing:imu_zeroer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700443 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000444)
445
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800446cc_library(
447 name = "drivetrain_test_lib",
448 testonly = True,
449 srcs = ["drivetrain_test_lib.cc"],
450 hdrs = ["drivetrain_test_lib.h"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800451 defines =
452 cpu_select({
453 "amd64": [
454 "SUPPORT_PLOT=1",
455 ],
456 "arm": [],
457 }),
Philipp Schraderdada1072020-11-24 11:34:46 -0800458 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800459 deps = [
460 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700461 ":drivetrain_goal_fbs",
462 ":drivetrain_output_fbs",
463 ":drivetrain_position_fbs",
464 ":drivetrain_status_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800465 ":trajectory",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700466 "//aos/events:event_loop",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800467 "//aos/testing:googletest",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700468 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800469 "//frc971/control_loops:state_feedback_loop",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800470 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800471 "//frc971/wpilib:imu_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700472 "//frc971/wpilib:imu_batch_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800473 "//y2016:constants",
474 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800475 ] + cpu_select({
476 "amd64": [
477 "//third_party/matplotlib-cpp",
478 ],
479 "arm": [],
480 }),
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800481)
482
Comran Morshed5323ecb2015-12-26 20:50:55 +0000483cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700484 name = "drivetrain_lib_test",
485 srcs = [
486 "drivetrain_lib_test.cc",
487 ],
Austin Schuh14d7d3d2020-09-10 18:14:36 -0700488 data = [":simulation_config"],
Alex Perry04300d62019-02-17 14:37:04 -0800489 defines =
490 cpu_select({
491 "amd64": [
492 "SUPPORT_PLOT=1",
493 ],
494 "arm": [],
495 }),
496 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800497 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700498 deps = [
499 ":drivetrain_config",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800500 ":trajectory_generator",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700501 ":drivetrain_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700502 ":localizer_fbs",
503 ":drivetrain_goal_fbs",
504 ":drivetrain_status_fbs",
505 ":drivetrain_position_fbs",
506 ":drivetrain_output_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800507 ":drivetrain_test_lib",
James Kuszmaul61750662021-06-21 21:32:33 -0700508 "//frc971/control_loops:control_loop_test",
Austin Schuhb06f03b2021-02-17 22:00:37 -0800509 "//aos/events/logging:log_writer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700510 "//aos/testing:googletest",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800511 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800512 "//frc971/wpilib:imu_fbs",
Alex Perry04300d62019-02-17 14:37:04 -0800513 ] + cpu_select({
514 "amd64": [
515 "//third_party/matplotlib-cpp",
516 ],
517 "arm": [],
518 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000519)
Brian Silverman6260c092018-01-14 15:21:36 -0800520
521genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700522 name = "genrule_haptic_wheel",
523 outs = [
524 "haptic_wheel.h",
525 "haptic_wheel.cc",
526 "integral_haptic_wheel.h",
527 "integral_haptic_wheel.cc",
528 "haptic_trigger.h",
529 "haptic_trigger.cc",
530 "integral_haptic_trigger.h",
531 "integral_haptic_trigger.cc",
532 ],
533 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700534 tools = [
535 "//frc971/control_loops/python:haptic_wheel",
536 ],
537 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800538)
539
540cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700541 name = "haptic_wheel",
542 srcs = [
543 "haptic_trigger.cc",
544 "haptic_wheel.cc",
545 "integral_haptic_trigger.cc",
546 "integral_haptic_wheel.cc",
547 ],
548 hdrs = [
549 "haptic_trigger.h",
550 "haptic_wheel.h",
551 "integral_haptic_trigger.h",
552 "integral_haptic_wheel.h",
553 ],
554 deps = [
555 "//frc971/control_loops:state_feedback_loop",
556 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800557)
Austin Schuhc2b08772018-12-19 18:05:06 +1100558
559cc_library(
560 name = "spline",
561 srcs = ["spline.cc"],
562 hdrs = ["spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800563 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100564 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800565 "//frc971/control_loops:binomial",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700566 "@org_tuxfamily_eigen//:eigen",
Austin Schuhc2b08772018-12-19 18:05:06 +1100567 ],
568)
569
Alex Perrya60da442019-01-21 19:00:27 -0500570cc_binary(
571 name = "spline.so",
572 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800573 linkshared = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800574 target_compatible_with = ["@platforms//os:linux"],
Alex Perrya60da442019-01-21 19:00:27 -0500575 deps = [
576 ":distance_spline",
577 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800578 ":trajectory",
579 "//aos/logging:implementations",
580 "//aos/network:team_number",
James Kuszmaul8aa37cb2020-03-01 10:27:58 -0800581 "//y2020/control_loops/drivetrain:drivetrain_base",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700582 "@org_tuxfamily_eigen//:eigen",
Alex Perrya60da442019-01-21 19:00:27 -0500583 ],
Alex Perrya60da442019-01-21 19:00:27 -0500584)
585
Austin Schuhc2b08772018-12-19 18:05:06 +1100586cc_test(
587 name = "spline_test",
588 srcs = [
589 "spline_test.cc",
590 ],
James Kuszmaule32fa932021-05-11 21:38:16 -0700591 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800592 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100593 deps = [
594 ":spline",
595 "//aos/testing:googletest",
James Kuszmaule32fa932021-05-11 21:38:16 -0700596 "//frc971/analysis:in_process_plotter",
Austin Schuhc2b08772018-12-19 18:05:06 +1100597 "@com_github_gflags_gflags//:gflags",
598 ],
599)
Austin Schuh941b46d2018-12-19 18:06:05 +1100600
601cc_library(
602 name = "distance_spline",
603 srcs = ["distance_spline.cc"],
604 hdrs = ["distance_spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800605 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100606 deps = [
607 ":spline",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800608 ":trajectory_fbs",
Austin Schuha6e7b212019-01-20 13:53:01 -0800609 "//aos/logging",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800610 "//frc971/control_loops:control_loops_fbs",
Austin Schuh941b46d2018-12-19 18:06:05 +1100611 "//frc971/control_loops:fixed_quadrature",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800612 "@com_github_google_glog//:glog",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700613 "@org_tuxfamily_eigen//:eigen",
Austin Schuh941b46d2018-12-19 18:06:05 +1100614 ],
615)
616
617cc_test(
618 name = "distance_spline_test",
619 srcs = [
620 "distance_spline_test.cc",
621 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800622 defines =
623 cpu_select({
624 "amd64": [
625 "SUPPORT_PLOT=1",
626 ],
627 "arm": [],
628 }),
629 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800630 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100631 deps = [
632 ":distance_spline",
633 "//aos/testing:googletest",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800634 "//aos:flatbuffers",
Austin Schuha6e7b212019-01-20 13:53:01 -0800635 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100636 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800637 ] + cpu_select({
638 "amd64": [
639 "//third_party/matplotlib-cpp",
640 ],
641 "arm": [],
642 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100643)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100644
645cc_library(
646 name = "trajectory",
647 srcs = ["trajectory.cc"],
648 hdrs = ["trajectory.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800649 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100650 deps = [
651 ":distance_spline",
652 ":drivetrain_config",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800653 ":spline_goal_fbs",
654 ":trajectory_fbs",
James Kuszmaul5e8ce312021-03-27 14:59:17 -0700655 "//aos/util:math",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100656 "//frc971/control_loops:c2d",
657 "//frc971/control_loops:dlqr",
658 "//frc971/control_loops:hybrid_state_feedback_loop",
659 "//frc971/control_loops:runge_kutta",
660 "//frc971/control_loops:state_feedback_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700661 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100662 ],
663)
664
James Kuszmaul75a18c52021-03-10 22:02:07 -0800665cc_library(
666 name = "trajectory_generator",
667 srcs = ["trajectory_generator.cc"],
668 hdrs = ["trajectory_generator.h"],
669 target_compatible_with = ["@platforms//os:linux"],
670 deps = [
671 ":distance_spline",
672 ":drivetrain_config",
673 ":spline_goal_fbs",
674 ":trajectory",
675 ":trajectory_fbs",
676 ],
677)
678
Austin Schuhec7f06d2019-01-04 07:47:15 +1100679cc_binary(
680 name = "trajectory_plot",
681 srcs = [
682 "trajectory_plot.cc",
683 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800684 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100685 deps = [
686 ":distance_spline",
687 ":trajectory",
688 "//aos/logging:implementations",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100689 "//aos/network:team_number",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100690 "//third_party/matplotlib-cpp",
Austin Schuh11043182019-03-23 22:29:12 -0700691 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100692 "@com_github_gflags_gflags//:gflags",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700693 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100694 ],
695)
696
697cc_test(
698 name = "trajectory_test",
699 srcs = [
700 "trajectory_test.cc",
701 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800702 defines =
703 cpu_select({
704 "amd64": [
705 "SUPPORT_PLOT=1",
706 ],
707 "arm": [],
708 }),
709 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800710 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100711 deps = [
712 ":trajectory",
James Kuszmaulea314d92019-02-18 19:45:06 -0800713 ":drivetrain_test_lib",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100714 "//aos/testing:googletest",
715 "//aos/testing:test_shm",
716 "//y2016:constants",
717 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaulea314d92019-02-18 19:45:06 -0800718 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuh719a33e2019-01-07 15:13:34 -0800719 ] + cpu_select({
720 "amd64": [
721 "//third_party/matplotlib-cpp",
722 ],
723 "arm": [],
724 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100725)
Austin Schuhca080812017-05-10 19:31:55 -0700726
727cc_library(
728 name = "improved_down_estimator",
729 srcs = [
730 "improved_down_estimator.cc",
731 ],
732 hdrs = [
733 "improved_down_estimator.h",
734 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800735 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700736 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800737 ":drivetrain_config",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800738 ":drivetrain_status_fbs",
739 "//aos/events:event_loop",
740 "//frc971/control_loops:control_loops_fbs",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700741 "//frc971/control_loops:quaternion_utils",
Austin Schuhca080812017-05-10 19:31:55 -0700742 "//frc971/control_loops:runge_kutta",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800743 "@//aos/time",
Austin Schuhca080812017-05-10 19:31:55 -0700744 "@com_github_google_glog//:glog",
745 "@org_tuxfamily_eigen//:eigen",
746 ],
747)
748
749cc_test(
750 name = "improved_down_estimator_test",
751 srcs = [
752 "improved_down_estimator_test.cc",
753 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800754 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700755 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800756 ":drivetrain_test_lib",
Austin Schuhca080812017-05-10 19:31:55 -0700757 "//aos/testing:googletest",
758 "//aos/testing:random_seed",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700759 "//frc971/control_loops:quaternion_utils",
Austin Schuhca080812017-05-10 19:31:55 -0700760 "//frc971/control_loops/drivetrain:improved_down_estimator",
761 "@org_tuxfamily_eigen//:eigen",
762 ],
763)
James Kuszmaulf4ede202020-02-14 08:47:40 -0800764
765cc_library(
766 name = "camera",
767 srcs = ["camera.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800768 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800769 visibility = ["//visibility:public"],
770 deps = [
771 "//aos/containers:sized_array",
772 "//frc971/control_loops:pose",
773 ],
774)
775
776cc_test(
777 name = "camera_test",
778 srcs = ["camera_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800779 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800780 deps = [
781 ":camera",
782 "//aos/testing:googletest",
783 ],
784)
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800785
786ts_library(
James Kuszmaulac2b6b42021-03-07 22:38:06 -0800787 name = "down_estimator_plotter",
788 srcs = ["down_estimator_plotter.ts"],
789 target_compatible_with = ["@platforms//os:linux"],
790 deps = [
791 "//aos/network/www:aos_plotter",
792 "//aos/network/www:colors",
793 "//aos/network/www:proxy",
794 "//frc971/wpilib:imu_plot_utils",
795 ],
796)
797
798ts_library(
James Kuszmaul73fc1352021-04-09 22:31:25 -0700799 name = "spline_plotter",
800 srcs = ["spline_plotter.ts"],
801 target_compatible_with = ["@platforms//os:linux"],
802 deps = [
803 "//aos/network/www:aos_plotter",
804 "//aos/network/www:colors",
805 "//aos/network/www:proxy",
806 ],
807)
808
809ts_library(
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800810 name = "drivetrain_plotter",
811 srcs = ["drivetrain_plotter.ts"],
812 target_compatible_with = ["@platforms//os:linux"],
813 deps = [
814 "//aos/network/www:aos_plotter",
James Kuszmaul933a9742021-03-07 19:59:06 -0800815 "//aos/network/www:colors",
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800816 "//aos/network/www:proxy",
817 "//frc971/wpilib:imu_plot_utils",
818 ],
819)
milind upadhyay9bd381d2021-01-23 13:44:13 -0800820
821ts_library(
822 name = "robot_state_plotter",
823 srcs = ["robot_state_plotter.ts"],
824 target_compatible_with = ["@platforms//os:linux"],
825 deps = [
826 "//aos/network/www:aos_plotter",
James Kuszmaul933a9742021-03-07 19:59:06 -0800827 "//aos/network/www:colors",
milind upadhyay9bd381d2021-01-23 13:44:13 -0800828 "//aos/network/www:proxy",
829 ],
830)