blob: 7b632fc06f769385d1d298dd3353c148f059c175 [file] [log] [blame]
James Kuszmaulf01da392023-12-14 11:22:14 -08001load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_py_library")
Austin Schuha1d006e2022-09-14 21:50:42 -07002load("@com_github_google_flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
Austin Schuh8f99c822024-05-05 22:43:40 -07003load("//aos:config.bzl", "aos_config")
4load("//aos/flatbuffers:generate.bzl", "static_flatbuffer")
Jim Ostrowski977850f2022-01-22 21:04:22 -08005
Yash Maheshwari997b3312024-05-18 17:08:44 -07006cc_binary(
7 name = "modify_extrinsics",
8 srcs = [
9 "modify_extrinsics.cc",
10 ],
11 target_compatible_with = ["@platforms//os:linux"],
12 visibility = ["//visibility:public"],
13 deps = [
14 "//aos:configuration",
15 "//aos:init",
16 "//aos/events:event_loop",
17 "//frc971/vision:calibration_fbs",
18 "//frc971/vision:vision_util_lib",
19 "@com_google_absl//absl/strings:str_format",
20 "@org_tuxfamily_eigen//:eigen",
21 ],
22)
23
24cc_binary(
25 name = "image_replay",
26 srcs = [
27 "image_replay.cc",
28 ],
29 target_compatible_with = ["@platforms//os:linux"],
30 visibility = ["//visibility:public"],
31 deps = [
32 "//aos:configuration",
33 "//aos:init",
34 "//aos/events:simulated_event_loop",
35 "//aos/events/logging:log_reader",
36 "//frc971/vision:vision_fbs",
37 "//third_party:opencv",
38 ],
39)
40
41cc_binary(
42 name = "image_logger",
43 srcs = [
44 "image_logger.cc",
45 ],
46 target_compatible_with = ["@platforms//os:linux"],
47 visibility = ["//visibility:public"],
48 deps = [
49 "//aos:configuration",
50 "//aos:init",
51 "//aos/events:shm_event_loop",
52 "//aos/events/logging:log_writer",
53 "//aos/logging:log_namer",
54 "//aos/util:filesystem_fbs",
55 "//frc971/input:joystick_state_fbs",
56 "@com_github_gflags_gflags//:gflags",
57 "@com_github_google_glog//:glog",
58 ],
59)
60
61cc_binary(
62 name = "foxglove_image_converter",
63 srcs = ["foxglove_image_converter.cc"],
64 visibility = ["//visibility:public"],
65 deps = [
66 "//aos:init",
67 "//aos/events:shm_event_loop",
68 "//frc971/vision:foxglove_image_converter_lib",
69 ],
70)
71
James Kuszmaulf01da392023-12-14 11:22:14 -080072static_flatbuffer(
Jim Ostrowski977850f2022-01-22 21:04:22 -080073 name = "vision_fbs",
74 srcs = ["vision.fbs"],
Jim Ostrowski977850f2022-01-22 21:04:22 -080075 target_compatible_with = ["@platforms//os:linux"],
76 visibility = ["//visibility:public"],
77)
78
79flatbuffer_ts_library(
80 name = "vision_ts_fbs",
81 srcs = ["vision.fbs"],
82 target_compatible_with = ["@platforms//os:linux"],
83 visibility = ["//visibility:public"],
84)
85
James Kuszmaulf01da392023-12-14 11:22:14 -080086static_flatbuffer(
milind-u2f101fc2023-01-21 12:28:49 -080087 name = "calibration_fbs",
88 srcs = ["calibration.fbs"],
milind-u2f101fc2023-01-21 12:28:49 -080089 target_compatible_with = ["@platforms//os:linux"],
90 visibility = ["//visibility:public"],
91)
92
93flatbuffer_ts_library(
94 name = "calibration_ts_fbs",
95 srcs = ["calibration.fbs"],
96 target_compatible_with = ["@platforms//os:linux"],
97 visibility = ["//visibility:public"],
98)
99
Milo Lin13906572023-03-15 20:55:22 -0700100flatbuffer_ts_library(
101 name = "target_map_ts_fbs",
102 srcs = ["target_map.fbs"],
103 target_compatible_with = ["@platforms//os:linux"],
104 visibility = ["//visibility:public"],
105)
106
milind-u2f101fc2023-01-21 12:28:49 -0800107flatbuffer_py_library(
108 name = "calibration_fbs_python",
109 srcs = [
110 "calibration.fbs",
111 ],
112 namespace = "frc971.vision.calibration",
113 tables = [
114 "CalibrationData",
115 "CameraCalibration",
116 "TransformationMatrix",
117 ],
118 target_compatible_with = ["@platforms//os:linux"],
119 visibility = ["//visibility:public"],
120)
121
milind-u959d6bd2023-01-21 12:32:52 -0800122py_library(
123 name = "create_calib_file",
124 srcs = [
125 "create_calib_file.py",
126 ],
127 target_compatible_with = ["@platforms//os:linux"],
128 visibility = ["//visibility:public"],
129 deps = [
130 ":calibration_fbs_python",
131 "@bazel_tools//tools/python/runfiles",
132 "@pip//glog",
133 "@pip//opencv_python",
134 ],
135)
136
Jim Ostrowski977850f2022-01-22 21:04:22 -0800137cc_library(
138 name = "v4l2_reader",
139 srcs = [
140 "v4l2_reader.cc",
141 ],
142 hdrs = [
143 "v4l2_reader.h",
144 ],
145 target_compatible_with = ["@platforms//os:linux"],
146 visibility = ["//visibility:public"],
147 deps = [
148 ":vision_fbs",
Ravago Jonesdc524752022-12-27 01:15:13 -0800149 "//aos/events:epoll",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800150 "//aos/events:event_loop",
151 "//aos/scoped:scoped_fd",
Ravago Jonesc6b919f2023-01-01 21:34:12 -0800152 "//aos/util:threaded_consumer",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800153 "@com_github_google_glog//:glog",
154 "@com_google_absl//absl/base",
155 ],
156)
Austin Schuhdcb6b362022-02-25 18:06:21 -0800157
158cc_library(
159 name = "charuco_lib",
160 srcs = [
161 "charuco_lib.cc",
162 ],
163 hdrs = [
164 "charuco_lib.h",
165 ],
166 target_compatible_with = ["@platforms//os:linux"],
167 visibility = ["//visibility:public"],
168 deps = [
169 "//aos:flatbuffers",
170 "//aos/events:event_loop",
171 "//aos/network:message_bridge_server_fbs",
172 "//aos/network:team_number",
173 "//frc971/control_loops:quaternion_utils",
James Kuszmaul7e958812023-02-11 15:34:31 -0800174 "//frc971/vision:calibration_fbs",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800175 "//frc971/vision:vision_fbs",
176 "//third_party:opencv",
James Kuszmaul969e4ab2023-01-28 16:09:19 -0800177 "@com_github_foxglove_schemas//:schemas",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800178 "@com_github_google_glog//:glog",
179 "@com_google_absl//absl/strings:str_format",
180 "@com_google_absl//absl/types:span",
181 "@org_tuxfamily_eigen//:eigen",
182 ],
183)
184
185cc_library(
186 name = "extrinsics_calibration",
187 srcs = [
188 "calibration_accumulator.cc",
189 "calibration_accumulator.h",
190 "extrinsics_calibration.cc",
191 "extrinsics_calibration.h",
192 ],
193 target_compatible_with = ["@platforms//os:linux"],
194 visibility = ["//visibility:public"],
195 deps = [
196 ":charuco_lib",
James Kuszmaul77d536c2023-02-11 17:30:59 -0800197 ":foxglove_image_converter_lib",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800198 "//aos:init",
199 "//aos/events/logging:log_reader",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800200 "//frc971/control_loops/drivetrain:improved_down_estimator",
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800201 "//frc971/vision:visualize_robot",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800202 "//frc971/wpilib:imu_batch_fbs",
203 "//frc971/wpilib:imu_fbs",
204 "//third_party:opencv",
James Kuszmaul969e4ab2023-01-28 16:09:19 -0800205 "@com_github_foxglove_schemas//:CompressedImage_schema",
206 "@com_github_foxglove_schemas//:ImageAnnotations_schema",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800207 "@com_google_absl//absl/strings:str_format",
208 "@com_google_ceres_solver//:ceres",
209 "@org_tuxfamily_eigen//:eigen",
Stephan Pleines85b295c2024-02-04 17:50:26 -0800210 ] + [
211 # TODO(Stephan): This is a whacky hack. If we include this
212 # in the proper spot above (alphabetically), then we get a
213 # linker error: duplicate symbol: crc32.
214 # It's part of both @zlib and @com_github_rawrtc_re.
215 "//aos/analysis:in_process_plotter",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800216 ],
217)
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700218
James Kuszmaulf01da392023-12-14 11:22:14 -0800219static_flatbuffer(
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800220 name = "target_map_fbs",
221 srcs = ["target_map.fbs"],
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800222 target_compatible_with = ["@platforms//os:linux"],
223 visibility = ["//visibility:public"],
224)
225
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700226cc_library(
Milind Upadhyay7c205222022-11-16 18:20:58 -0800227 name = "target_mapper",
228 srcs = ["target_mapper.cc"],
229 hdrs = ["target_mapper.h"],
Yash Chainanid5c7f0d2022-11-19 17:05:57 -0800230 data = ["target_map.json"],
Milind Upadhyay7c205222022-11-16 18:20:58 -0800231 target_compatible_with = ["@platforms//os:linux"],
232 visibility = ["//visibility:public"],
233 deps = [
234 ":geometry_lib",
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800235 ":target_map_fbs",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800236 "//aos/events:simulated_event_loop",
237 "//frc971/control_loops:control_loop",
milind-u8f4e43e2023-04-09 17:11:19 -0700238 "//frc971/vision:visualize_robot",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800239 "//frc971/vision/ceres:pose_graph_3d_lib",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800240 "//third_party:opencv",
241 "@com_google_ceres_solver//:ceres",
242 "@org_tuxfamily_eigen//:eigen",
243 ],
244)
245
246cc_test(
247 name = "target_mapper_test",
248 srcs = [
249 "target_mapper_test.cc",
250 ],
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800251 data = [":target_map.json"],
Milind Upadhyay7c205222022-11-16 18:20:58 -0800252 target_compatible_with = ["@platforms//os:linux"],
253 deps = [
254 ":target_mapper",
255 "//aos/events:simulated_event_loop",
256 "//aos/testing:googletest",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800257 "//aos/testing:path",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800258 "//aos/testing:random_seed",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800259 "//aos/util:math",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800260 ],
261)
262
263cc_library(
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700264 name = "geometry_lib",
265 hdrs = [
266 "geometry.h",
267 ],
268 target_compatible_with = ["@platforms//os:linux"],
269 visibility = ["//visibility:public"],
270 deps = [
271 "//aos/util:math",
272 "//third_party:opencv",
273 "@com_github_google_glog//:glog",
274 ],
275)
276
277cc_test(
278 name = "geometry_test",
279 srcs = [
280 "geometry_test.cc",
281 ],
282 deps = [
283 ":geometry_lib",
284 "//aos/testing:googletest",
285 ],
286)
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800287
288cc_library(
289 name = "visualize_robot",
290 srcs = [
291 "visualize_robot.cc",
292 ],
293 hdrs = [
294 "visualize_robot.h",
295 ],
Jim Ostrowski49be8232023-03-23 01:00:14 -0700296 visibility = ["//visibility:public"],
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800297 deps = [
298 "//aos:init",
299 "//third_party:opencv",
300 "@com_google_absl//absl/strings:str_format",
301 "@org_tuxfamily_eigen//:eigen",
302 ],
303)
304
305cc_binary(
306 name = "visualize_robot_sample",
307 srcs = [
308 "visualize_robot_sample.cc",
309 ],
310 target_compatible_with = ["@platforms//os:linux"],
311 visibility = ["//visibility:public"],
312 deps = [
313 "//aos:init",
314 "//frc971/vision:visualize_robot",
315 "//third_party:opencv",
316 "@com_github_google_glog//:glog",
317 "@com_google_ceres_solver//:ceres",
318 "@org_tuxfamily_eigen//:eigen",
319 ],
320)
Austin Schuhc97d48d2022-12-26 14:09:13 -0800321
322cc_library(
323 name = "media_device",
324 srcs = [
325 "media_device.cc",
326 ],
327 hdrs = ["media_device.h"],
328 visibility = ["//visibility:public"],
329 deps = [
330 "//aos/scoped:scoped_fd",
331 "//aos/util:file",
332 "@com_github_google_glog//:glog",
333 "@com_google_absl//absl/strings",
334 ],
335)
James Kuszmaul0c593962023-01-28 16:04:20 -0800336
337cc_library(
James Kuszmaul77d536c2023-02-11 17:30:59 -0800338 name = "foxglove_image_converter_lib",
339 srcs = ["foxglove_image_converter_lib.cc"],
340 hdrs = ["foxglove_image_converter_lib.h"],
James Kuszmaul0c593962023-01-28 16:04:20 -0800341 visibility = ["//visibility:public"],
342 deps = [
James Kuszmaul59a308f2023-01-28 19:14:07 -0800343 ":charuco_lib",
James Kuszmaul0c593962023-01-28 16:04:20 -0800344 ":vision_fbs",
345 "//aos/events:event_loop",
346 "//third_party:opencv",
347 "@com_github_foxglove_schemas//:schemas",
348 ],
349)
James Kuszmaul59a308f2023-01-28 19:14:07 -0800350
351aos_config(
352 name = "converter_config",
353 testonly = True,
354 src = "converter_test_config.json",
355 flatbuffers = [
356 "//frc971/vision:vision_fbs",
357 "//aos/events:event_loop_fbs",
358 "//aos/logging:log_message_fbs",
359 "//aos/network:message_bridge_client_fbs",
360 "//aos/network:message_bridge_server_fbs",
361 "//aos/network:timestamp_fbs",
362 "@com_github_foxglove_schemas//:schemas",
363 ],
364)
365
366cc_test(
367 name = "foxglove_image_converter_test",
368 srcs = ["foxglove_image_converter_test.cc"],
369 data = [
370 ":converter_config",
371 "@april_tag_test_image",
372 ],
373 deps = [
James Kuszmaul77d536c2023-02-11 17:30:59 -0800374 ":foxglove_image_converter_lib",
James Kuszmaul59a308f2023-01-28 19:14:07 -0800375 "//aos:configuration",
376 "//aos/events:simulated_event_loop",
377 "//aos/testing:googletest",
378 "//aos/testing:path",
379 "//aos/testing:tmpdir",
380 ],
381)
James Kuszmaul7e958812023-02-11 15:34:31 -0800382
383cc_library(
384 name = "intrinsics_calibration_lib",
385 srcs = [
386 "intrinsics_calibration_lib.cc",
387 ],
388 hdrs = [
389 "intrinsics_calibration_lib.h",
390 ],
391 target_compatible_with = ["@platforms//os:linux"],
392 deps = [
393 "//aos/events:event_loop",
394 "//frc971/control_loops/drivetrain:improved_down_estimator",
395 "//frc971/vision:charuco_lib",
396 "//frc971/vision:vision_fbs",
Jim Ostrowskib974cca2024-01-28 15:07:50 -0800397 "//frc971/vision:vision_util_lib",
James Kuszmaul7e958812023-02-11 15:34:31 -0800398 "//frc971/wpilib:imu_batch_fbs",
399 "//frc971/wpilib:imu_fbs",
400 "//third_party:opencv",
401 "@com_google_absl//absl/strings:str_format",
402 "@org_tuxfamily_eigen//:eigen",
403 ],
404)
405
406cc_binary(
407 name = "intrinsics_calibration",
408 srcs = [
409 "intrinsics_calibration.cc",
410 ],
411 target_compatible_with = ["@platforms//os:linux"],
412 visibility = [
413 "//y2020:__subpackages__",
414 "//y2022:__subpackages__",
415 "//y2023:__subpackages__",
Jim Ostrowski855b7442024-01-20 18:03:09 -0800416 "//y2024:__subpackages__",
Yash Maheshwari997b3312024-05-18 17:08:44 -0700417 "//y2024_swerve:__subpackages__",
James Kuszmaul7e958812023-02-11 15:34:31 -0800418 ],
419 deps = [
420 ":intrinsics_calibration_lib",
421 "//aos:init",
422 "//aos/events:shm_event_loop",
423 "//frc971/control_loops/drivetrain:improved_down_estimator",
424 "//frc971/vision:charuco_lib",
425 "//frc971/vision:vision_fbs",
426 "//frc971/wpilib:imu_batch_fbs",
427 "//frc971/wpilib:imu_fbs",
428 "//third_party:opencv",
429 "@com_google_absl//absl/strings:str_format",
430 "@org_tuxfamily_eigen//:eigen",
431 ],
432)
Jim Ostrowskicb8b4082024-01-21 02:23:46 -0800433
434cc_library(
435 name = "vision_util_lib",
436 srcs = ["vision_util_lib.cc"],
437 hdrs = ["vision_util_lib.h"],
438 visibility = ["//visibility:public"],
439 deps = [
440 "//frc971/vision:calibration_fbs",
441 "//third_party:opencv",
442 "@com_github_google_glog//:glog",
Jim Ostrowski33208982024-03-02 15:01:45 -0800443 "@com_google_absl//absl/strings:str_format",
Jim Ostrowskicb8b4082024-01-21 02:23:46 -0800444 ],
445)
Jim Ostrowskib974cca2024-01-28 15:07:50 -0800446
447cc_test(
448 name = "vision_util_lib_test",
449 srcs = ["vision_util_lib_test.cc"],
450 visibility = ["//visibility:public"],
451 deps = [
452 "//aos/testing:googletest",
453 "//frc971/vision:vision_util_lib",
454 "@com_github_google_glog//:glog",
455 ],
456)
James Kuszmaul9c3db182024-02-09 22:02:18 -0800457
458cc_library(
459 name = "target_map_utils",
460 srcs = ["target_map_utils.cc"],
461 hdrs = ["target_map_utils.h"],
462 visibility = ["//visibility:public"],
463 deps = [
464 "//frc971/vision:target_map_fbs",
465 "@org_tuxfamily_eigen//:eigen",
466 ],
467)