blob: 46b7ceaa91c8c9ccbf221a9bc34e82d33f849705 [file] [log] [blame]
James Kuszmaulf01da392023-12-14 11:22:14 -08001load("//aos/flatbuffers:generate.bzl", "static_flatbuffer")
2load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_py_library")
James Kuszmaul59a308f2023-01-28 19:14:07 -08003load("//aos:config.bzl", "aos_config")
Austin Schuha1d006e2022-09-14 21:50:42 -07004load("@com_github_google_flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
Jim Ostrowski977850f2022-01-22 21:04:22 -08005
James Kuszmaulf01da392023-12-14 11:22:14 -08006static_flatbuffer(
Jim Ostrowski977850f2022-01-22 21:04:22 -08007 name = "vision_fbs",
8 srcs = ["vision.fbs"],
Jim Ostrowski977850f2022-01-22 21:04:22 -08009 target_compatible_with = ["@platforms//os:linux"],
10 visibility = ["//visibility:public"],
11)
12
13flatbuffer_ts_library(
14 name = "vision_ts_fbs",
15 srcs = ["vision.fbs"],
16 target_compatible_with = ["@platforms//os:linux"],
17 visibility = ["//visibility:public"],
18)
19
James Kuszmaulf01da392023-12-14 11:22:14 -080020static_flatbuffer(
milind-u2f101fc2023-01-21 12:28:49 -080021 name = "calibration_fbs",
22 srcs = ["calibration.fbs"],
milind-u2f101fc2023-01-21 12:28:49 -080023 target_compatible_with = ["@platforms//os:linux"],
24 visibility = ["//visibility:public"],
25)
26
27flatbuffer_ts_library(
28 name = "calibration_ts_fbs",
29 srcs = ["calibration.fbs"],
30 target_compatible_with = ["@platforms//os:linux"],
31 visibility = ["//visibility:public"],
32)
33
Milo Lin13906572023-03-15 20:55:22 -070034flatbuffer_ts_library(
35 name = "target_map_ts_fbs",
36 srcs = ["target_map.fbs"],
37 target_compatible_with = ["@platforms//os:linux"],
38 visibility = ["//visibility:public"],
39)
40
milind-u2f101fc2023-01-21 12:28:49 -080041flatbuffer_py_library(
42 name = "calibration_fbs_python",
43 srcs = [
44 "calibration.fbs",
45 ],
46 namespace = "frc971.vision.calibration",
47 tables = [
48 "CalibrationData",
49 "CameraCalibration",
50 "TransformationMatrix",
51 ],
52 target_compatible_with = ["@platforms//os:linux"],
53 visibility = ["//visibility:public"],
54)
55
milind-u959d6bd2023-01-21 12:32:52 -080056py_library(
57 name = "create_calib_file",
58 srcs = [
59 "create_calib_file.py",
60 ],
61 target_compatible_with = ["@platforms//os:linux"],
62 visibility = ["//visibility:public"],
63 deps = [
64 ":calibration_fbs_python",
65 "@bazel_tools//tools/python/runfiles",
66 "@pip//glog",
67 "@pip//opencv_python",
68 ],
69)
70
Jim Ostrowski977850f2022-01-22 21:04:22 -080071cc_library(
72 name = "v4l2_reader",
73 srcs = [
74 "v4l2_reader.cc",
75 ],
76 hdrs = [
77 "v4l2_reader.h",
78 ],
79 target_compatible_with = ["@platforms//os:linux"],
80 visibility = ["//visibility:public"],
81 deps = [
82 ":vision_fbs",
Ravago Jonesdc524752022-12-27 01:15:13 -080083 "//aos/events:epoll",
Jim Ostrowski977850f2022-01-22 21:04:22 -080084 "//aos/events:event_loop",
85 "//aos/scoped:scoped_fd",
Ravago Jonesc6b919f2023-01-01 21:34:12 -080086 "//aos/util:threaded_consumer",
Jim Ostrowski977850f2022-01-22 21:04:22 -080087 "@com_github_google_glog//:glog",
88 "@com_google_absl//absl/base",
89 ],
90)
Austin Schuhdcb6b362022-02-25 18:06:21 -080091
92cc_library(
93 name = "charuco_lib",
94 srcs = [
95 "charuco_lib.cc",
96 ],
97 hdrs = [
98 "charuco_lib.h",
99 ],
100 target_compatible_with = ["@platforms//os:linux"],
101 visibility = ["//visibility:public"],
102 deps = [
103 "//aos:flatbuffers",
104 "//aos/events:event_loop",
105 "//aos/network:message_bridge_server_fbs",
106 "//aos/network:team_number",
107 "//frc971/control_loops:quaternion_utils",
James Kuszmaul7e958812023-02-11 15:34:31 -0800108 "//frc971/vision:calibration_fbs",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800109 "//frc971/vision:vision_fbs",
110 "//third_party:opencv",
James Kuszmaul969e4ab2023-01-28 16:09:19 -0800111 "@com_github_foxglove_schemas//:schemas",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800112 "@com_github_google_glog//:glog",
113 "@com_google_absl//absl/strings:str_format",
114 "@com_google_absl//absl/types:span",
115 "@org_tuxfamily_eigen//:eigen",
116 ],
117)
118
119cc_library(
120 name = "extrinsics_calibration",
121 srcs = [
122 "calibration_accumulator.cc",
123 "calibration_accumulator.h",
124 "extrinsics_calibration.cc",
125 "extrinsics_calibration.h",
126 ],
127 target_compatible_with = ["@platforms//os:linux"],
128 visibility = ["//visibility:public"],
129 deps = [
130 ":charuco_lib",
James Kuszmaul77d536c2023-02-11 17:30:59 -0800131 ":foxglove_image_converter_lib",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800132 "//aos:init",
133 "//aos/events/logging:log_reader",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800134 "//frc971/control_loops/drivetrain:improved_down_estimator",
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800135 "//frc971/vision:visualize_robot",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800136 "//frc971/wpilib:imu_batch_fbs",
137 "//frc971/wpilib:imu_fbs",
138 "//third_party:opencv",
James Kuszmaul969e4ab2023-01-28 16:09:19 -0800139 "@com_github_foxglove_schemas//:CompressedImage_schema",
140 "@com_github_foxglove_schemas//:ImageAnnotations_schema",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800141 "@com_google_absl//absl/strings:str_format",
142 "@com_google_ceres_solver//:ceres",
143 "@org_tuxfamily_eigen//:eigen",
Stephan Pleines85b295c2024-02-04 17:50:26 -0800144 ] + [
145 # TODO(Stephan): This is a whacky hack. If we include this
146 # in the proper spot above (alphabetically), then we get a
147 # linker error: duplicate symbol: crc32.
148 # It's part of both @zlib and @com_github_rawrtc_re.
149 "//aos/analysis:in_process_plotter",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800150 ],
151)
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700152
James Kuszmaulf01da392023-12-14 11:22:14 -0800153static_flatbuffer(
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800154 name = "target_map_fbs",
155 srcs = ["target_map.fbs"],
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800156 target_compatible_with = ["@platforms//os:linux"],
157 visibility = ["//visibility:public"],
158)
159
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700160cc_library(
Milind Upadhyay7c205222022-11-16 18:20:58 -0800161 name = "target_mapper",
162 srcs = ["target_mapper.cc"],
163 hdrs = ["target_mapper.h"],
Yash Chainanid5c7f0d2022-11-19 17:05:57 -0800164 data = ["target_map.json"],
Milind Upadhyay7c205222022-11-16 18:20:58 -0800165 target_compatible_with = ["@platforms//os:linux"],
166 visibility = ["//visibility:public"],
167 deps = [
168 ":geometry_lib",
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800169 ":target_map_fbs",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800170 "//aos/events:simulated_event_loop",
171 "//frc971/control_loops:control_loop",
milind-u8f4e43e2023-04-09 17:11:19 -0700172 "//frc971/vision:visualize_robot",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800173 "//frc971/vision/ceres:pose_graph_3d_lib",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800174 "//third_party:opencv",
175 "@com_google_ceres_solver//:ceres",
176 "@org_tuxfamily_eigen//:eigen",
177 ],
178)
179
180cc_test(
181 name = "target_mapper_test",
182 srcs = [
183 "target_mapper_test.cc",
184 ],
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800185 data = [":target_map.json"],
Milind Upadhyay7c205222022-11-16 18:20:58 -0800186 target_compatible_with = ["@platforms//os:linux"],
187 deps = [
188 ":target_mapper",
189 "//aos/events:simulated_event_loop",
190 "//aos/testing:googletest",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800191 "//aos/testing:path",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800192 "//aos/testing:random_seed",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800193 "//aos/util:math",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800194 ],
195)
196
197cc_library(
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700198 name = "geometry_lib",
199 hdrs = [
200 "geometry.h",
201 ],
202 target_compatible_with = ["@platforms//os:linux"],
203 visibility = ["//visibility:public"],
204 deps = [
205 "//aos/util:math",
206 "//third_party:opencv",
207 "@com_github_google_glog//:glog",
208 ],
209)
210
211cc_test(
212 name = "geometry_test",
213 srcs = [
214 "geometry_test.cc",
215 ],
216 deps = [
217 ":geometry_lib",
218 "//aos/testing:googletest",
219 ],
220)
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800221
222cc_library(
223 name = "visualize_robot",
224 srcs = [
225 "visualize_robot.cc",
226 ],
227 hdrs = [
228 "visualize_robot.h",
229 ],
Jim Ostrowski49be8232023-03-23 01:00:14 -0700230 visibility = ["//visibility:public"],
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800231 deps = [
232 "//aos:init",
233 "//third_party:opencv",
234 "@com_google_absl//absl/strings:str_format",
235 "@org_tuxfamily_eigen//:eigen",
236 ],
237)
238
239cc_binary(
240 name = "visualize_robot_sample",
241 srcs = [
242 "visualize_robot_sample.cc",
243 ],
244 target_compatible_with = ["@platforms//os:linux"],
245 visibility = ["//visibility:public"],
246 deps = [
247 "//aos:init",
248 "//frc971/vision:visualize_robot",
249 "//third_party:opencv",
250 "@com_github_google_glog//:glog",
251 "@com_google_ceres_solver//:ceres",
252 "@org_tuxfamily_eigen//:eigen",
253 ],
254)
Austin Schuhc97d48d2022-12-26 14:09:13 -0800255
256cc_library(
257 name = "media_device",
258 srcs = [
259 "media_device.cc",
260 ],
261 hdrs = ["media_device.h"],
262 visibility = ["//visibility:public"],
263 deps = [
264 "//aos/scoped:scoped_fd",
265 "//aos/util:file",
266 "@com_github_google_glog//:glog",
267 "@com_google_absl//absl/strings",
268 ],
269)
James Kuszmaul0c593962023-01-28 16:04:20 -0800270
271cc_library(
James Kuszmaul77d536c2023-02-11 17:30:59 -0800272 name = "foxglove_image_converter_lib",
273 srcs = ["foxglove_image_converter_lib.cc"],
274 hdrs = ["foxglove_image_converter_lib.h"],
James Kuszmaul0c593962023-01-28 16:04:20 -0800275 visibility = ["//visibility:public"],
276 deps = [
James Kuszmaul59a308f2023-01-28 19:14:07 -0800277 ":charuco_lib",
James Kuszmaul0c593962023-01-28 16:04:20 -0800278 ":vision_fbs",
279 "//aos/events:event_loop",
280 "//third_party:opencv",
281 "@com_github_foxglove_schemas//:schemas",
282 ],
283)
James Kuszmaul59a308f2023-01-28 19:14:07 -0800284
285aos_config(
286 name = "converter_config",
287 testonly = True,
288 src = "converter_test_config.json",
289 flatbuffers = [
290 "//frc971/vision:vision_fbs",
291 "//aos/events:event_loop_fbs",
292 "//aos/logging:log_message_fbs",
293 "//aos/network:message_bridge_client_fbs",
294 "//aos/network:message_bridge_server_fbs",
295 "//aos/network:timestamp_fbs",
296 "@com_github_foxglove_schemas//:schemas",
297 ],
298)
299
300cc_test(
301 name = "foxglove_image_converter_test",
302 srcs = ["foxglove_image_converter_test.cc"],
303 data = [
304 ":converter_config",
305 "@april_tag_test_image",
306 ],
307 deps = [
James Kuszmaul77d536c2023-02-11 17:30:59 -0800308 ":foxglove_image_converter_lib",
James Kuszmaul59a308f2023-01-28 19:14:07 -0800309 "//aos:configuration",
310 "//aos/events:simulated_event_loop",
311 "//aos/testing:googletest",
312 "//aos/testing:path",
313 "//aos/testing:tmpdir",
314 ],
315)
James Kuszmaul7e958812023-02-11 15:34:31 -0800316
317cc_library(
318 name = "intrinsics_calibration_lib",
319 srcs = [
320 "intrinsics_calibration_lib.cc",
321 ],
322 hdrs = [
323 "intrinsics_calibration_lib.h",
324 ],
325 target_compatible_with = ["@platforms//os:linux"],
326 deps = [
327 "//aos/events:event_loop",
328 "//frc971/control_loops/drivetrain:improved_down_estimator",
329 "//frc971/vision:charuco_lib",
330 "//frc971/vision:vision_fbs",
Jim Ostrowskib974cca2024-01-28 15:07:50 -0800331 "//frc971/vision:vision_util_lib",
James Kuszmaul7e958812023-02-11 15:34:31 -0800332 "//frc971/wpilib:imu_batch_fbs",
333 "//frc971/wpilib:imu_fbs",
334 "//third_party:opencv",
335 "@com_google_absl//absl/strings:str_format",
336 "@org_tuxfamily_eigen//:eigen",
337 ],
338)
339
340cc_binary(
341 name = "intrinsics_calibration",
342 srcs = [
343 "intrinsics_calibration.cc",
344 ],
345 target_compatible_with = ["@platforms//os:linux"],
346 visibility = [
347 "//y2020:__subpackages__",
348 "//y2022:__subpackages__",
349 "//y2023:__subpackages__",
Jim Ostrowski855b7442024-01-20 18:03:09 -0800350 "//y2024:__subpackages__",
James Kuszmaul7e958812023-02-11 15:34:31 -0800351 ],
352 deps = [
353 ":intrinsics_calibration_lib",
354 "//aos:init",
355 "//aos/events:shm_event_loop",
356 "//frc971/control_loops/drivetrain:improved_down_estimator",
357 "//frc971/vision:charuco_lib",
358 "//frc971/vision:vision_fbs",
359 "//frc971/wpilib:imu_batch_fbs",
360 "//frc971/wpilib:imu_fbs",
361 "//third_party:opencv",
362 "@com_google_absl//absl/strings:str_format",
363 "@org_tuxfamily_eigen//:eigen",
364 ],
365)
Jim Ostrowskicb8b4082024-01-21 02:23:46 -0800366
367cc_library(
368 name = "vision_util_lib",
369 srcs = ["vision_util_lib.cc"],
370 hdrs = ["vision_util_lib.h"],
371 visibility = ["//visibility:public"],
372 deps = [
373 "//frc971/vision:calibration_fbs",
374 "//third_party:opencv",
375 "@com_github_google_glog//:glog",
Jim Ostrowski33208982024-03-02 15:01:45 -0800376 "@com_google_absl//absl/strings:str_format",
Jim Ostrowskicb8b4082024-01-21 02:23:46 -0800377 ],
378)
Jim Ostrowskib974cca2024-01-28 15:07:50 -0800379
380cc_test(
381 name = "vision_util_lib_test",
382 srcs = ["vision_util_lib_test.cc"],
383 visibility = ["//visibility:public"],
384 deps = [
385 "//aos/testing:googletest",
386 "//frc971/vision:vision_util_lib",
387 "@com_github_google_glog//:glog",
388 ],
389)
James Kuszmaul9c3db182024-02-09 22:02:18 -0800390
391cc_library(
392 name = "target_map_utils",
393 srcs = ["target_map_utils.cc"],
394 hdrs = ["target_map_utils.h"],
395 visibility = ["//visibility:public"],
396 deps = [
397 "//frc971/vision:target_map_fbs",
398 "@org_tuxfamily_eigen//:eigen",
399 ],
400)