blob: 84f3be756615b61e59582b18f83c8a2ec0054c8c [file] [log] [blame]
milind-u2f101fc2023-01-21 12:28:49 -08001load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_py_library")
James Kuszmaul59a308f2023-01-28 19:14:07 -08002load("//aos:config.bzl", "aos_config")
Austin Schuha1d006e2022-09-14 21:50:42 -07003load("@com_github_google_flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
Jim Ostrowski977850f2022-01-22 21:04:22 -08004
5flatbuffer_cc_library(
6 name = "vision_fbs",
7 srcs = ["vision.fbs"],
8 gen_reflections = 1,
9 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
milind-u2f101fc2023-01-21 12:28:49 -080020flatbuffer_cc_library(
21 name = "calibration_fbs",
22 srcs = ["calibration.fbs"],
23 gen_reflections = 1,
24 target_compatible_with = ["@platforms//os:linux"],
25 visibility = ["//visibility:public"],
26)
27
28flatbuffer_ts_library(
29 name = "calibration_ts_fbs",
30 srcs = ["calibration.fbs"],
31 target_compatible_with = ["@platforms//os:linux"],
32 visibility = ["//visibility:public"],
33)
34
Milo Lin13906572023-03-15 20:55:22 -070035flatbuffer_ts_library(
36 name = "target_map_ts_fbs",
37 srcs = ["target_map.fbs"],
38 target_compatible_with = ["@platforms//os:linux"],
39 visibility = ["//visibility:public"],
40)
41
milind-u2f101fc2023-01-21 12:28:49 -080042flatbuffer_py_library(
43 name = "calibration_fbs_python",
44 srcs = [
45 "calibration.fbs",
46 ],
47 namespace = "frc971.vision.calibration",
48 tables = [
49 "CalibrationData",
50 "CameraCalibration",
51 "TransformationMatrix",
52 ],
53 target_compatible_with = ["@platforms//os:linux"],
54 visibility = ["//visibility:public"],
55)
56
milind-u959d6bd2023-01-21 12:32:52 -080057py_library(
58 name = "create_calib_file",
59 srcs = [
60 "create_calib_file.py",
61 ],
62 target_compatible_with = ["@platforms//os:linux"],
63 visibility = ["//visibility:public"],
64 deps = [
65 ":calibration_fbs_python",
66 "@bazel_tools//tools/python/runfiles",
67 "@pip//glog",
68 "@pip//opencv_python",
69 ],
70)
71
Jim Ostrowski977850f2022-01-22 21:04:22 -080072cc_library(
73 name = "v4l2_reader",
74 srcs = [
75 "v4l2_reader.cc",
76 ],
77 hdrs = [
78 "v4l2_reader.h",
79 ],
80 target_compatible_with = ["@platforms//os:linux"],
81 visibility = ["//visibility:public"],
82 deps = [
83 ":vision_fbs",
Ravago Jonesdc524752022-12-27 01:15:13 -080084 "//aos/events:epoll",
Jim Ostrowski977850f2022-01-22 21:04:22 -080085 "//aos/events:event_loop",
86 "//aos/scoped:scoped_fd",
Ravago Jonesc6b919f2023-01-01 21:34:12 -080087 "//aos/util:threaded_consumer",
Jim Ostrowski977850f2022-01-22 21:04:22 -080088 "@com_github_google_glog//:glog",
89 "@com_google_absl//absl/base",
90 ],
91)
Austin Schuhdcb6b362022-02-25 18:06:21 -080092
93cc_library(
94 name = "charuco_lib",
95 srcs = [
96 "charuco_lib.cc",
97 ],
98 hdrs = [
99 "charuco_lib.h",
100 ],
101 target_compatible_with = ["@platforms//os:linux"],
102 visibility = ["//visibility:public"],
103 deps = [
104 "//aos:flatbuffers",
105 "//aos/events:event_loop",
106 "//aos/network:message_bridge_server_fbs",
107 "//aos/network:team_number",
108 "//frc971/control_loops:quaternion_utils",
James Kuszmaul7e958812023-02-11 15:34:31 -0800109 "//frc971/vision:calibration_fbs",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800110 "//frc971/vision:vision_fbs",
111 "//third_party:opencv",
James Kuszmaul969e4ab2023-01-28 16:09:19 -0800112 "@com_github_foxglove_schemas//:schemas",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800113 "@com_github_google_glog//:glog",
114 "@com_google_absl//absl/strings:str_format",
115 "@com_google_absl//absl/types:span",
116 "@org_tuxfamily_eigen//:eigen",
117 ],
118)
119
120cc_library(
121 name = "extrinsics_calibration",
122 srcs = [
123 "calibration_accumulator.cc",
124 "calibration_accumulator.h",
125 "extrinsics_calibration.cc",
126 "extrinsics_calibration.h",
127 ],
128 target_compatible_with = ["@platforms//os:linux"],
129 visibility = ["//visibility:public"],
130 deps = [
131 ":charuco_lib",
James Kuszmaul77d536c2023-02-11 17:30:59 -0800132 ":foxglove_image_converter_lib",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800133 "//aos:init",
134 "//aos/events/logging:log_reader",
135 "//frc971/analysis:in_process_plotter",
136 "//frc971/control_loops/drivetrain:improved_down_estimator",
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800137 "//frc971/vision:visualize_robot",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800138 "//frc971/wpilib:imu_batch_fbs",
139 "//frc971/wpilib:imu_fbs",
140 "//third_party:opencv",
James Kuszmaul969e4ab2023-01-28 16:09:19 -0800141 "@com_github_foxglove_schemas//:CompressedImage_schema",
142 "@com_github_foxglove_schemas//:ImageAnnotations_schema",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800143 "@com_google_absl//absl/strings:str_format",
144 "@com_google_ceres_solver//:ceres",
145 "@org_tuxfamily_eigen//:eigen",
146 ],
147)
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700148
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800149flatbuffer_cc_library(
150 name = "target_map_fbs",
151 srcs = ["target_map.fbs"],
152 gen_reflections = 1,
153 target_compatible_with = ["@platforms//os:linux"],
154 visibility = ["//visibility:public"],
155)
156
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700157cc_library(
Milind Upadhyay7c205222022-11-16 18:20:58 -0800158 name = "target_mapper",
159 srcs = ["target_mapper.cc"],
160 hdrs = ["target_mapper.h"],
Yash Chainanid5c7f0d2022-11-19 17:05:57 -0800161 data = ["target_map.json"],
Milind Upadhyay7c205222022-11-16 18:20:58 -0800162 target_compatible_with = ["@platforms//os:linux"],
163 visibility = ["//visibility:public"],
164 deps = [
165 ":geometry_lib",
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800166 ":target_map_fbs",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800167 "//aos/events:simulated_event_loop",
168 "//frc971/control_loops:control_loop",
milind-u8f4e43e2023-04-09 17:11:19 -0700169 "//frc971/vision:visualize_robot",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800170 "//frc971/vision/ceres:pose_graph_3d_lib",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800171 "//third_party:opencv",
172 "@com_google_ceres_solver//:ceres",
173 "@org_tuxfamily_eigen//:eigen",
174 ],
175)
176
177cc_test(
178 name = "target_mapper_test",
179 srcs = [
180 "target_mapper_test.cc",
181 ],
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800182 data = [":target_map.json"],
Milind Upadhyay7c205222022-11-16 18:20:58 -0800183 target_compatible_with = ["@platforms//os:linux"],
184 deps = [
185 ":target_mapper",
186 "//aos/events:simulated_event_loop",
187 "//aos/testing:googletest",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800188 "//aos/testing:path",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800189 "//aos/testing:random_seed",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800190 "//aos/util:math",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800191 ],
192)
193
194cc_library(
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700195 name = "geometry_lib",
196 hdrs = [
197 "geometry.h",
198 ],
199 target_compatible_with = ["@platforms//os:linux"],
200 visibility = ["//visibility:public"],
201 deps = [
202 "//aos/util:math",
203 "//third_party:opencv",
204 "@com_github_google_glog//:glog",
205 ],
206)
207
208cc_test(
209 name = "geometry_test",
210 srcs = [
211 "geometry_test.cc",
212 ],
213 deps = [
214 ":geometry_lib",
215 "//aos/testing:googletest",
216 ],
217)
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800218
219cc_library(
220 name = "visualize_robot",
221 srcs = [
222 "visualize_robot.cc",
223 ],
224 hdrs = [
225 "visualize_robot.h",
226 ],
Jim Ostrowski49be8232023-03-23 01:00:14 -0700227 visibility = ["//visibility:public"],
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800228 deps = [
229 "//aos:init",
230 "//third_party:opencv",
231 "@com_google_absl//absl/strings:str_format",
232 "@org_tuxfamily_eigen//:eigen",
233 ],
234)
235
236cc_binary(
237 name = "visualize_robot_sample",
238 srcs = [
239 "visualize_robot_sample.cc",
240 ],
241 target_compatible_with = ["@platforms//os:linux"],
242 visibility = ["//visibility:public"],
243 deps = [
244 "//aos:init",
245 "//frc971/vision:visualize_robot",
246 "//third_party:opencv",
247 "@com_github_google_glog//:glog",
248 "@com_google_ceres_solver//:ceres",
249 "@org_tuxfamily_eigen//:eigen",
250 ],
251)
Austin Schuhc97d48d2022-12-26 14:09:13 -0800252
253cc_library(
254 name = "media_device",
255 srcs = [
256 "media_device.cc",
257 ],
258 hdrs = ["media_device.h"],
259 visibility = ["//visibility:public"],
260 deps = [
261 "//aos/scoped:scoped_fd",
262 "//aos/util:file",
263 "@com_github_google_glog//:glog",
264 "@com_google_absl//absl/strings",
265 ],
266)
James Kuszmaul0c593962023-01-28 16:04:20 -0800267
268cc_library(
James Kuszmaul77d536c2023-02-11 17:30:59 -0800269 name = "foxglove_image_converter_lib",
270 srcs = ["foxglove_image_converter_lib.cc"],
271 hdrs = ["foxglove_image_converter_lib.h"],
James Kuszmaul0c593962023-01-28 16:04:20 -0800272 visibility = ["//visibility:public"],
273 deps = [
James Kuszmaul59a308f2023-01-28 19:14:07 -0800274 ":charuco_lib",
James Kuszmaul0c593962023-01-28 16:04:20 -0800275 ":vision_fbs",
276 "//aos/events:event_loop",
277 "//third_party:opencv",
278 "@com_github_foxglove_schemas//:schemas",
279 ],
280)
James Kuszmaul59a308f2023-01-28 19:14:07 -0800281
282aos_config(
283 name = "converter_config",
284 testonly = True,
285 src = "converter_test_config.json",
286 flatbuffers = [
287 "//frc971/vision:vision_fbs",
288 "//aos/events:event_loop_fbs",
289 "//aos/logging:log_message_fbs",
290 "//aos/network:message_bridge_client_fbs",
291 "//aos/network:message_bridge_server_fbs",
292 "//aos/network:timestamp_fbs",
293 "@com_github_foxglove_schemas//:schemas",
294 ],
295)
296
297cc_test(
298 name = "foxglove_image_converter_test",
299 srcs = ["foxglove_image_converter_test.cc"],
300 data = [
301 ":converter_config",
302 "@april_tag_test_image",
303 ],
304 deps = [
James Kuszmaul77d536c2023-02-11 17:30:59 -0800305 ":foxglove_image_converter_lib",
James Kuszmaul59a308f2023-01-28 19:14:07 -0800306 "//aos:configuration",
307 "//aos/events:simulated_event_loop",
308 "//aos/testing:googletest",
309 "//aos/testing:path",
310 "//aos/testing:tmpdir",
311 ],
312)
James Kuszmaul7e958812023-02-11 15:34:31 -0800313
314cc_library(
315 name = "intrinsics_calibration_lib",
316 srcs = [
317 "intrinsics_calibration_lib.cc",
318 ],
319 hdrs = [
320 "intrinsics_calibration_lib.h",
321 ],
322 target_compatible_with = ["@platforms//os:linux"],
323 deps = [
324 "//aos/events:event_loop",
325 "//frc971/control_loops/drivetrain:improved_down_estimator",
326 "//frc971/vision:charuco_lib",
327 "//frc971/vision:vision_fbs",
328 "//frc971/wpilib:imu_batch_fbs",
329 "//frc971/wpilib:imu_fbs",
330 "//third_party:opencv",
331 "@com_google_absl//absl/strings:str_format",
332 "@org_tuxfamily_eigen//:eigen",
333 ],
334)
335
336cc_binary(
337 name = "intrinsics_calibration",
338 srcs = [
339 "intrinsics_calibration.cc",
340 ],
341 target_compatible_with = ["@platforms//os:linux"],
342 visibility = [
343 "//y2020:__subpackages__",
344 "//y2022:__subpackages__",
345 "//y2023:__subpackages__",
346 ],
347 deps = [
348 ":intrinsics_calibration_lib",
349 "//aos:init",
350 "//aos/events:shm_event_loop",
351 "//frc971/control_loops/drivetrain:improved_down_estimator",
352 "//frc971/vision:charuco_lib",
353 "//frc971/vision:vision_fbs",
354 "//frc971/wpilib:imu_batch_fbs",
355 "//frc971/wpilib:imu_fbs",
356 "//third_party:opencv",
357 "@com_google_absl//absl/strings:str_format",
358 "@org_tuxfamily_eigen//:eigen",
359 ],
360)