blob: 93b4a11971158f4b2bd329865a2607a0f59d9158 [file] [log] [blame]
Philipp Schrader3de4dfc2023-02-15 20:18:25 -08001load("//tools/build_rules:js.bzl", "ts_project")
Austin Schuha1d006e2022-09-14 21:50:42 -07002load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
3load("@com_github_google_flatbuffers//:typescript.bzl", "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")
Austin Schuh41fad8c2021-10-23 21:25:12 -07006load("//aos:flatbuffers.bzl", "cc_static_flatbuffer")
Comran Morshed5323ecb2015-12-26 20:50:55 +00007
Philipp Schradercc016b32021-12-30 08:59:58 -08008package(default_visibility = ["//visibility:public"])
9
Alex Perrycb7da4b2019-08-28 19:35:56 -070010flatbuffer_cc_library(
Maxwell Hendersoncef6f042023-05-26 14:38:09 -070011 name = "drivetrain_can_position_fbs",
12 srcs = ["drivetrain_can_position.fbs"],
13 gen_reflections = 1,
14)
15
16flatbuffer_cc_library(
James Kuszmaul75a18c52021-03-10 22:02:07 -080017 name = "spline_goal_fbs",
18 srcs = ["spline_goal.fbs"],
19 gen_reflections = 1,
20 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
21)
22
23flatbuffer_cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -070024 name = "drivetrain_goal_fbs",
25 srcs = ["drivetrain_goal.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070026 gen_reflections = 1,
James Kuszmaul75a18c52021-03-10 22:02:07 -080027 includes = [
28 ":spline_goal_fbs_includes",
29 "//frc971/control_loops:control_loops_fbs_includes",
30 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +000031)
32
Alex Perrycb7da4b2019-08-28 19:35:56 -070033flatbuffer_cc_library(
34 name = "drivetrain_output_fbs",
35 srcs = ["drivetrain_output.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070036 gen_reflections = 1,
37)
38
39flatbuffer_cc_library(
40 name = "drivetrain_position_fbs",
41 srcs = ["drivetrain_position.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070042 gen_reflections = 1,
43)
44
45flatbuffer_cc_library(
46 name = "drivetrain_status_fbs",
47 srcs = ["drivetrain_status.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070048 gen_reflections = 1,
49 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
50)
51
James Kuszmaul75a18c52021-03-10 22:02:07 -080052flatbuffer_cc_library(
53 name = "trajectory_fbs",
54 srcs = ["trajectory.fbs"],
55 gen_reflections = 1,
56 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
57)
58
Austin Schuh41fad8c2021-10-23 21:25:12 -070059cc_static_flatbuffer(
60 name = "trajectory_schema",
61 function = "frc971::control_loops::drivetrain::fb::TrajectorySchema",
62 target = ":trajectory_fbs_reflection_out",
63 visibility = ["//visibility:public"],
64)
65
Alex Perry2124ae82020-03-07 14:19:06 -080066flatbuffer_ts_library(
67 name = "drivetrain_status_ts_fbs",
68 srcs = ["drivetrain_status.fbs"],
Philipp Schraderdada1072020-11-24 11:34:46 -080069 target_compatible_with = ["@platforms//os:linux"],
James Kuszmauldac091f2022-03-22 09:35:06 -070070 deps = ["//frc971/control_loops:control_loops_ts_fbs"],
Alex Perry2124ae82020-03-07 14:19:06 -080071)
72
Alex Perrycb7da4b2019-08-28 19:35:56 -070073genrule(
74 name = "drivetrain_goal_float_fbs_generated",
75 srcs = ["drivetrain_goal.fbs"],
76 outs = ["drivetrain_goal_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_position_float_fbs_generated",
82 srcs = ["drivetrain_position.fbs"],
83 outs = ["drivetrain_position_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_output_float_fbs_generated",
89 srcs = ["drivetrain_output.fbs"],
90 outs = ["drivetrain_output_float.fbs"],
91 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070092)
93
94genrule(
95 name = "drivetrain_status_float_fbs_generated",
96 srcs = ["drivetrain_status.fbs"],
97 outs = ["drivetrain_status_float.fbs"],
98 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070099)
100
101flatbuffer_cc_library(
102 name = "drivetrain_goal_float_fbs",
103 srcs = ["drivetrain_goal_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700104 gen_reflections = 1,
James Kuszmaul75a18c52021-03-10 22:02:07 -0800105 includes = [
106 ":spline_goal_fbs_includes",
107 "//frc971/control_loops:control_loops_fbs_includes",
108 ],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700109)
110
111flatbuffer_cc_library(
112 name = "drivetrain_output_float_fbs",
113 srcs = ["drivetrain_output_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700114 gen_reflections = 1,
115)
116
117flatbuffer_cc_library(
118 name = "drivetrain_position_float_fbs",
119 srcs = ["drivetrain_position_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700120 gen_reflections = 1,
121)
122
123flatbuffer_cc_library(
124 name = "drivetrain_status_float_fbs",
125 srcs = ["drivetrain_status_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700126 gen_reflections = 1,
127 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
128)
129
130aos_config(
James Kuszmaul74d8f972020-02-11 17:13:17 -0800131 name = "simulation_channels",
132 src = "drivetrain_simulation_channels.json",
133 flatbuffers = [
134 ":drivetrain_status_fbs",
135 ],
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)
139
140aos_config(
141 name = "simulation_config",
142 src = "drivetrain_simulation_config.json",
Philipp Schraderdada1072020-11-24 11:34:46 -0800143 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800144 visibility = ["//visibility:public"],
145 deps = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800146 ":aos_config",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800147 ":simulation_channels",
148 ],
149)
150
151aos_config(
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800152 name = "aos_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700153 src = "drivetrain_config.json",
154 flatbuffers = [
155 ":drivetrain_goal_fbs",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800156 ":trajectory_fbs",
157 ":spline_goal_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700158 ":drivetrain_output_fbs",
159 ":drivetrain_status_fbs",
160 ":drivetrain_position_fbs",
161 ":localizer_fbs",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800162 "//frc971/queues:gyro_fbs",
163 "//frc971/queues:gyro_uid_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700164 "//frc971/wpilib:imu_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700165 "//frc971/wpilib:imu_batch_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700166 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800167 target_compatible_with = ["@platforms//os:linux"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700168 visibility = ["//visibility:public"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700169 deps = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800170 "//frc971/input:aos_config",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700171 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000172)
173
174cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700175 name = "drivetrain_config",
176 hdrs = [
177 "drivetrain_config.h",
178 ],
179 deps = [
180 "//frc971:shifter_hall_effect",
181 "//frc971/control_loops:state_feedback_loop",
Philipp Schraderdada1072020-11-24 11:34:46 -0800182 ] + select({
183 "@platforms//os:linux": ["//frc971/control_loops:hybrid_state_feedback_loop"],
184 "//conditions:default": [],
185 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000186)
187
188cc_library(
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800189 name = "hybrid_ekf",
190 hdrs = ["hybrid_ekf.h"],
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_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800194 "//aos:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800195 "//aos/containers:priority_queue",
James Kuszmaulfedc4612019-03-10 11:24:51 -0700196 "//aos/util:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800197 "//frc971/control_loops:c2d",
198 "//frc971/control_loops:runge_kutta",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700199 "@org_tuxfamily_eigen//:eigen",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800200 ],
201)
202
203cc_test(
204 name = "hybrid_ekf_test",
205 srcs = ["hybrid_ekf_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800206 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800207 deps = [
208 ":drivetrain_test_lib",
209 ":hybrid_ekf",
210 ":trajectory",
211 "//aos/testing:googletest",
212 "//aos/testing:random_seed",
213 "//aos/testing:test_shm",
214 ],
215)
216
Alex Perrycb7da4b2019-08-28 19:35:56 -0700217flatbuffer_cc_library(
218 name = "localizer_fbs",
219 srcs = ["localizer.fbs"],
220 gen_reflections = 1,
Philipp Schraderdada1072020-11-24 11:34:46 -0800221 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulef428a02019-03-02 22:19:41 -0800222)
223
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800224cc_library(
James Kuszmaul3431d622019-02-17 17:07:44 -0800225 name = "localizer",
226 hdrs = ["localizer.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800227 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul3431d622019-02-17 17:07:44 -0800228 deps = [
229 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800230 ":drivetrain_status_fbs",
James Kuszmaul3431d622019-02-17 17:07:44 -0800231 ":hybrid_ekf",
James Kuszmaul5398fae2020-02-17 16:44:03 -0800232 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800233 "//frc971/control_loops:pose",
James Kuszmaul3431d622019-02-17 17:07:44 -0800234 ],
235)
236
237cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700238 name = "gear",
239 hdrs = [
240 "gear.h",
241 ],
Austin Schuh093535c2016-03-05 23:21:00 -0800242)
243
244cc_library(
Alex Perry731b4602019-02-02 22:13:01 -0800245 name = "splinedrivetrain",
246 srcs = [
247 "splinedrivetrain.cc",
248 ],
249 hdrs = [
250 "splinedrivetrain.h",
251 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800252 target_compatible_with = ["@platforms//os:linux"],
Alex Perry731b4602019-02-02 22:13:01 -0800253 deps = [
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800254 ":distance_spline",
Alex Perry731b4602019-02-02 22:13:01 -0800255 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700256 ":drivetrain_goal_fbs",
257 ":drivetrain_output_fbs",
258 ":drivetrain_status_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800259 ":spline",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800260 ":spline_goal_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800261 ":trajectory",
Austin Schuh3d9ccd72020-08-01 15:42:40 -0700262 "//aos:condition",
Alex Perry1ec34522019-02-17 22:44:10 -0800263 "//aos:init",
James Kuszmaulc73bb222019-04-07 12:15:35 -0700264 "//aos/util:math",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700265 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800266 ],
Alex Perry731b4602019-02-02 22:13:01 -0800267)
268
269cc_library(
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800270 name = "line_follow_drivetrain",
271 srcs = [
272 "line_follow_drivetrain.cc",
273 ],
274 hdrs = [
275 "line_follow_drivetrain.h",
276 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800277 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800278 deps = [
279 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700280 ":drivetrain_goal_fbs",
281 ":drivetrain_output_fbs",
282 ":drivetrain_status_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800283 ":localizer",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800284 ":spline_goal_fbs",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800285 "//aos:math",
286 "//aos/util:math",
287 "//frc971/control_loops:c2d",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700288 "//frc971/control_loops:control_loops_fbs",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800289 "//frc971/control_loops:dlqr",
290 "//frc971/control_loops:pose",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700291 "//frc971/control_loops:profiled_subsystem_fbs",
292 "//y2019/control_loops/superstructure:superstructure_goal_fbs",
293 "@org_tuxfamily_eigen//:eigen",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800294 ],
295)
296
297cc_test(
298 name = "line_follow_drivetrain_test",
299 srcs = ["line_follow_drivetrain_test.cc"],
300 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800301 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800302 deps = [
303 ":drivetrain_config",
304 ":drivetrain_test_lib",
305 ":line_follow_drivetrain",
306 ":trajectory",
307 "//aos/testing:googletest",
308 "//aos/testing:test_shm",
309 "//third_party/matplotlib-cpp",
310 "@com_github_gflags_gflags//:gflags",
311 ],
312)
313
314cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700315 name = "ssdrivetrain",
316 srcs = [
317 "ssdrivetrain.cc",
318 ],
319 hdrs = [
320 "ssdrivetrain.h",
321 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800322 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700323 deps = [
324 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700325 ":drivetrain_goal_fbs",
326 ":drivetrain_output_fbs",
Austin Schuh95771d92021-01-23 14:42:25 -0800327 ":drivetrain_states",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700328 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700329 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800330 ":localizer",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800331 ":spline_goal_fbs",
John Park33858a32018-09-28 23:05:48 -0700332 "//aos:math",
John Park33858a32018-09-28 23:05:48 -0700333 "//aos/util:log_interval",
334 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700335 "//frc971:shifter_hall_effect",
336 "//frc971/control_loops:coerce_goal",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700337 "//frc971/control_loops:control_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700338 "//frc971/control_loops:control_loops_fbs",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700339 "//frc971/control_loops:polytope",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700340 "//frc971/control_loops:state_feedback_loop",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700341 "//frc971/input:robot_state_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700342 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000343)
344
345cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700346 name = "polydrivetrain",
347 srcs = [
348 "polydrivetrain.cc",
349 ],
350 hdrs = [
351 "polydrivetrain.h",
352 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800353 copts = select({
354 "@platforms//os:none": ["-Wno-type-limits"],
355 "//conditions:default": [],
356 }),
Austin Schuhbcce26a2018-03-26 23:41:24 -0700357 deps = [
358 ":drivetrain_config",
Austin Schuh95771d92021-01-23 14:42:25 -0800359 ":drivetrain_states",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700360 ":gear",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700361 ":spline_goal_fbs",
John Park33858a32018-09-28 23:05:48 -0700362 "//aos:math",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700363 "//frc971/control_loops:coerce_goal",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700364 "//frc971/control_loops:control_loops_fbs",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700365 "//frc971/control_loops:polytope",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700366 "//frc971/control_loops:state_feedback_loop",
Philipp Schraderdada1072020-11-24 11:34:46 -0800367 ] + select({
368 "@platforms//os:linux": [
369 ":drivetrain_goal_fbs",
370 ":drivetrain_output_fbs",
371 ":drivetrain_position_fbs",
372 ":drivetrain_status_fbs",
Philipp Schraderdada1072020-11-24 11:34:46 -0800373 "//aos/util:log_interval",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700374 "//frc971/input:robot_state_fbs",
Philipp Schraderdada1072020-11-24 11:34:46 -0800375 ],
376 "@platforms//os:none": [
377 ":drivetrain_goal_float_fbs",
378 ":drivetrain_output_float_fbs",
379 ":drivetrain_position_float_fbs",
380 ":drivetrain_status_float_fbs",
381 ],
382 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000383)
384
Austin Schuh05c5a612016-04-02 15:10:25 -0700385genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700386 name = "genrule_down_estimator",
387 outs = [
388 "down_estimator.h",
389 "down_estimator.cc",
390 ],
391 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
Philipp Schraderdada1072020-11-24 11:34:46 -0800392 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700393 tools = [
394 "//frc971/control_loops/python:down_estimator",
395 ],
396 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700397)
398
399cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700400 name = "down_estimator",
401 srcs = [
402 "down_estimator.cc",
403 ],
404 hdrs = [
405 "down_estimator.h",
406 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800407 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700408 deps = [
409 "//frc971/control_loops:state_feedback_loop",
410 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700411)
412
Comran Morshed5323ecb2015-12-26 20:50:55 +0000413cc_library(
Austin Schuh95771d92021-01-23 14:42:25 -0800414 name = "drivetrain_states",
415 hdrs = ["drivetrain_states.h"],
416)
417
418cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700419 name = "drivetrain_lib",
420 srcs = [
421 "drivetrain.cc",
422 ],
423 hdrs = [
424 "drivetrain.h",
425 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800426 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700427 deps = [
428 ":down_estimator",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700429 ":drivetrain_goal_fbs",
430 ":drivetrain_output_fbs",
431 ":drivetrain_position_fbs",
Austin Schuh95771d92021-01-23 14:42:25 -0800432 ":drivetrain_states",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700433 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700434 ":gear",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800435 ":improved_down_estimator",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800436 ":line_follow_drivetrain",
James Kuszmaul3431d622019-02-17 17:07:44 -0800437 ":localizer",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700438 ":localizer_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700439 ":polydrivetrain",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800440 ":spline_goal_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800441 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800442 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700443 "//aos/util:log_interval",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700444 "//frc971/control_loops:control_loop",
Austin Schuh3a378462019-01-04 21:48:04 -0800445 "//frc971/control_loops:runge_kutta",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800446 "//frc971/queues:gyro_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700447 "//frc971/wpilib:imu_batch_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700448 "//frc971/wpilib:imu_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800449 "//frc971/zeroing:imu_zeroer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700450 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000451)
452
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800453cc_library(
454 name = "drivetrain_test_lib",
455 testonly = True,
456 srcs = ["drivetrain_test_lib.cc"],
457 hdrs = ["drivetrain_test_lib.h"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800458 defines =
459 cpu_select({
460 "amd64": [
461 "SUPPORT_PLOT=1",
462 ],
463 "arm": [],
464 }),
Philipp Schraderdada1072020-11-24 11:34:46 -0800465 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800466 deps = [
467 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700468 ":drivetrain_goal_fbs",
469 ":drivetrain_output_fbs",
470 ":drivetrain_position_fbs",
471 ":drivetrain_status_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800472 ":trajectory",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700473 "//aos/events:event_loop",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800474 "//aos/testing:googletest",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700475 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800476 "//frc971/control_loops:state_feedback_loop",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800477 "//frc971/queues:gyro_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700478 "//frc971/wpilib:imu_batch_fbs",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700479 "//frc971/wpilib:imu_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800480 "//y2016:constants",
481 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800482 ] + cpu_select({
483 "amd64": [
484 "//third_party/matplotlib-cpp",
485 ],
486 "arm": [],
487 }),
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800488)
489
Comran Morshed5323ecb2015-12-26 20:50:55 +0000490cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700491 name = "drivetrain_lib_test",
492 srcs = [
493 "drivetrain_lib_test.cc",
494 ],
Austin Schuh14d7d3d2020-09-10 18:14:36 -0700495 data = [":simulation_config"],
Alex Perry04300d62019-02-17 14:37:04 -0800496 defines =
497 cpu_select({
498 "amd64": [
499 "SUPPORT_PLOT=1",
500 ],
501 "arm": [],
502 }),
503 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800504 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700505 deps = [
506 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700507 ":drivetrain_goal_fbs",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700508 ":drivetrain_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700509 ":drivetrain_output_fbs",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700510 ":drivetrain_position_fbs",
511 ":drivetrain_status_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800512 ":drivetrain_test_lib",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700513 ":localizer_fbs",
514 ":trajectory_generator",
Austin Schuhb06f03b2021-02-17 22:00:37 -0800515 "//aos/events/logging:log_writer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700516 "//aos/testing:googletest",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700517 "//frc971/control_loops:control_loop_test",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800518 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800519 "//frc971/wpilib:imu_fbs",
Alex Perry04300d62019-02-17 14:37:04 -0800520 ] + cpu_select({
521 "amd64": [
522 "//third_party/matplotlib-cpp",
523 ],
524 "arm": [],
525 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000526)
Brian Silverman6260c092018-01-14 15:21:36 -0800527
528genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700529 name = "genrule_haptic_wheel",
530 outs = [
531 "haptic_wheel.h",
532 "haptic_wheel.cc",
533 "integral_haptic_wheel.h",
534 "integral_haptic_wheel.cc",
535 "haptic_trigger.h",
536 "haptic_trigger.cc",
537 "integral_haptic_trigger.h",
538 "integral_haptic_trigger.cc",
539 ],
540 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700541 tools = [
542 "//frc971/control_loops/python:haptic_wheel",
543 ],
544 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800545)
546
547cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700548 name = "haptic_wheel",
549 srcs = [
550 "haptic_trigger.cc",
551 "haptic_wheel.cc",
552 "integral_haptic_trigger.cc",
553 "integral_haptic_wheel.cc",
554 ],
555 hdrs = [
556 "haptic_trigger.h",
557 "haptic_wheel.h",
558 "integral_haptic_trigger.h",
559 "integral_haptic_wheel.h",
560 ],
561 deps = [
562 "//frc971/control_loops:state_feedback_loop",
563 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800564)
Austin Schuhc2b08772018-12-19 18:05:06 +1100565
566cc_library(
567 name = "spline",
568 srcs = ["spline.cc"],
569 hdrs = ["spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800570 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100571 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800572 "//frc971/control_loops:binomial",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700573 "@org_tuxfamily_eigen//:eigen",
Austin Schuhc2b08772018-12-19 18:05:06 +1100574 ],
575)
576
Alex Perrya60da442019-01-21 19:00:27 -0500577cc_binary(
578 name = "spline.so",
579 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800580 linkshared = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800581 target_compatible_with = ["@platforms//os:linux"],
Alex Perrya60da442019-01-21 19:00:27 -0500582 deps = [
583 ":distance_spline",
584 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800585 ":trajectory",
586 "//aos/logging:implementations",
587 "//aos/network:team_number",
James Kuszmaul8aa37cb2020-03-01 10:27:58 -0800588 "//y2020/control_loops/drivetrain:drivetrain_base",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700589 "@org_tuxfamily_eigen//:eigen",
Alex Perrya60da442019-01-21 19:00:27 -0500590 ],
Alex Perrya60da442019-01-21 19:00:27 -0500591)
592
Austin Schuhc2b08772018-12-19 18:05:06 +1100593cc_test(
594 name = "spline_test",
595 srcs = [
596 "spline_test.cc",
597 ],
James Kuszmaule32fa932021-05-11 21:38:16 -0700598 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800599 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100600 deps = [
601 ":spline",
602 "//aos/testing:googletest",
James Kuszmaule32fa932021-05-11 21:38:16 -0700603 "//frc971/analysis:in_process_plotter",
Austin Schuhc2b08772018-12-19 18:05:06 +1100604 "@com_github_gflags_gflags//:gflags",
605 ],
606)
Austin Schuh941b46d2018-12-19 18:06:05 +1100607
608cc_library(
609 name = "distance_spline",
610 srcs = ["distance_spline.cc"],
611 hdrs = ["distance_spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800612 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100613 deps = [
614 ":spline",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800615 ":trajectory_fbs",
Austin Schuhf7c65202022-11-04 21:28:20 -0700616 "//aos/containers:sized_array",
Austin Schuha6e7b212019-01-20 13:53:01 -0800617 "//aos/logging",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800618 "//frc971/control_loops:control_loops_fbs",
Austin Schuh941b46d2018-12-19 18:06:05 +1100619 "//frc971/control_loops:fixed_quadrature",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800620 "@com_github_google_glog//:glog",
Austin Schuhf7c65202022-11-04 21:28:20 -0700621 "@com_google_absl//absl/types:span",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700622 "@org_tuxfamily_eigen//:eigen",
Austin Schuh941b46d2018-12-19 18:06:05 +1100623 ],
624)
625
626cc_test(
627 name = "distance_spline_test",
628 srcs = [
629 "distance_spline_test.cc",
630 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800631 defines =
632 cpu_select({
633 "amd64": [
634 "SUPPORT_PLOT=1",
635 ],
636 "arm": [],
637 }),
638 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800639 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100640 deps = [
641 ":distance_spline",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800642 "//aos:flatbuffers",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700643 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800644 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100645 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800646 ] + cpu_select({
647 "amd64": [
648 "//third_party/matplotlib-cpp",
649 ],
650 "arm": [],
651 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100652)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100653
654cc_library(
655 name = "trajectory",
656 srcs = ["trajectory.cc"],
657 hdrs = ["trajectory.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800658 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100659 deps = [
660 ":distance_spline",
661 ":drivetrain_config",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800662 ":spline_goal_fbs",
663 ":trajectory_fbs",
James Kuszmaul5e8ce312021-03-27 14:59:17 -0700664 "//aos/util:math",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100665 "//frc971/control_loops:c2d",
666 "//frc971/control_loops:dlqr",
667 "//frc971/control_loops:hybrid_state_feedback_loop",
668 "//frc971/control_loops:runge_kutta",
669 "//frc971/control_loops:state_feedback_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700670 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100671 ],
672)
673
James Kuszmaul75a18c52021-03-10 22:02:07 -0800674cc_library(
675 name = "trajectory_generator",
676 srcs = ["trajectory_generator.cc"],
677 hdrs = ["trajectory_generator.h"],
678 target_compatible_with = ["@platforms//os:linux"],
679 deps = [
680 ":distance_spline",
681 ":drivetrain_config",
682 ":spline_goal_fbs",
683 ":trajectory",
684 ":trajectory_fbs",
685 ],
686)
687
Austin Schuhec7f06d2019-01-04 07:47:15 +1100688cc_binary(
689 name = "trajectory_plot",
690 srcs = [
691 "trajectory_plot.cc",
692 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800693 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100694 deps = [
695 ":distance_spline",
696 ":trajectory",
697 "//aos/logging:implementations",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100698 "//aos/network:team_number",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100699 "//third_party/matplotlib-cpp",
Austin Schuh11043182019-03-23 22:29:12 -0700700 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100701 "@com_github_gflags_gflags//:gflags",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700702 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100703 ],
704)
705
706cc_test(
707 name = "trajectory_test",
708 srcs = [
709 "trajectory_test.cc",
710 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800711 defines =
712 cpu_select({
713 "amd64": [
714 "SUPPORT_PLOT=1",
715 ],
716 "arm": [],
717 }),
718 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800719 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100720 deps = [
James Kuszmaulea314d92019-02-18 19:45:06 -0800721 ":drivetrain_test_lib",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700722 ":trajectory",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100723 "//aos/testing:googletest",
724 "//aos/testing:test_shm",
725 "//y2016:constants",
726 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaulea314d92019-02-18 19:45:06 -0800727 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuh719a33e2019-01-07 15:13:34 -0800728 ] + cpu_select({
729 "amd64": [
730 "//third_party/matplotlib-cpp",
731 ],
732 "arm": [],
733 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100734)
Austin Schuhca080812017-05-10 19:31:55 -0700735
736cc_library(
737 name = "improved_down_estimator",
738 srcs = [
739 "improved_down_estimator.cc",
740 ],
741 hdrs = [
742 "improved_down_estimator.h",
743 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800744 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700745 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800746 ":drivetrain_config",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800747 ":drivetrain_status_fbs",
748 "//aos/events:event_loop",
749 "//frc971/control_loops:control_loops_fbs",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700750 "//frc971/control_loops:quaternion_utils",
Austin Schuhca080812017-05-10 19:31:55 -0700751 "//frc971/control_loops:runge_kutta",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800752 "@//aos/time",
Austin Schuhca080812017-05-10 19:31:55 -0700753 "@com_github_google_glog//:glog",
754 "@org_tuxfamily_eigen//:eigen",
755 ],
756)
757
758cc_test(
759 name = "improved_down_estimator_test",
760 srcs = [
761 "improved_down_estimator_test.cc",
762 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800763 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700764 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800765 ":drivetrain_test_lib",
Austin Schuhca080812017-05-10 19:31:55 -0700766 "//aos/testing:googletest",
767 "//aos/testing:random_seed",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700768 "//frc971/control_loops:quaternion_utils",
Austin Schuhca080812017-05-10 19:31:55 -0700769 "//frc971/control_loops/drivetrain:improved_down_estimator",
770 "@org_tuxfamily_eigen//:eigen",
771 ],
772)
James Kuszmaulf4ede202020-02-14 08:47:40 -0800773
774cc_library(
775 name = "camera",
776 srcs = ["camera.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800777 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800778 visibility = ["//visibility:public"],
779 deps = [
780 "//aos/containers:sized_array",
781 "//frc971/control_loops:pose",
782 ],
783)
784
785cc_test(
786 name = "camera_test",
787 srcs = ["camera_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800788 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800789 deps = [
790 ":camera",
791 "//aos/testing:googletest",
792 ],
793)
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800794
Philipp Schrader3de4dfc2023-02-15 20:18:25 -0800795ts_project(
James Kuszmaulac2b6b42021-03-07 22:38:06 -0800796 name = "down_estimator_plotter",
797 srcs = ["down_estimator_plotter.ts"],
798 target_compatible_with = ["@platforms//os:linux"],
799 deps = [
800 "//aos/network/www:aos_plotter",
801 "//aos/network/www:colors",
802 "//aos/network/www:proxy",
803 "//frc971/wpilib:imu_plot_utils",
804 ],
805)
806
Philipp Schrader3de4dfc2023-02-15 20:18:25 -0800807ts_project(
James Kuszmaul73fc1352021-04-09 22:31:25 -0700808 name = "spline_plotter",
809 srcs = ["spline_plotter.ts"],
810 target_compatible_with = ["@platforms//os:linux"],
811 deps = [
812 "//aos/network/www:aos_plotter",
813 "//aos/network/www:colors",
814 "//aos/network/www:proxy",
815 ],
816)
817
Philipp Schrader3de4dfc2023-02-15 20:18:25 -0800818ts_project(
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800819 name = "drivetrain_plotter",
820 srcs = ["drivetrain_plotter.ts"],
821 target_compatible_with = ["@platforms//os:linux"],
822 deps = [
823 "//aos/network/www:aos_plotter",
James Kuszmaul933a9742021-03-07 19:59:06 -0800824 "//aos/network/www:colors",
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800825 "//aos/network/www:proxy",
826 "//frc971/wpilib:imu_plot_utils",
827 ],
828)
milind upadhyay9bd381d2021-01-23 13:44:13 -0800829
Philipp Schrader3de4dfc2023-02-15 20:18:25 -0800830ts_project(
milind upadhyay9bd381d2021-01-23 13:44:13 -0800831 name = "robot_state_plotter",
832 srcs = ["robot_state_plotter.ts"],
833 target_compatible_with = ["@platforms//os:linux"],
834 deps = [
835 "//aos/network/www:aos_plotter",
James Kuszmaul933a9742021-03-07 19:59:06 -0800836 "//aos/network/www:colors",
milind upadhyay9bd381d2021-01-23 13:44:13 -0800837 "//aos/network/www:proxy",
838 ],
839)