blob: 97265425539231e6222bf755eb11309fded935cb [file] [log] [blame]
Austin Schuha1d006e2022-09-14 21:50:42 -07001load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_py_library")
2load("@com_github_google_flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
James Kuszmaulb35e2342022-03-06 15:44:00 -08003load("@npm//@bazel/typescript:index.bzl", "ts_library")
milind-u92195982022-01-22 20:29:31 -08004
Jim Ostrowski007e2ea2022-01-30 13:13:26 -08005flatbuffer_cc_library(
6 name = "calibration_fbs",
7 srcs = ["calibration.fbs"],
8 gen_reflections = 1,
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -08009 target_compatible_with = ["@platforms//os:linux"],
10 visibility = ["//y2022:__subpackages__"],
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080011)
12
Milind Upadhyayd836bce2022-03-25 21:49:57 -070013flatbuffer_ts_library(
14 name = "calibration_ts_fbs",
15 srcs = ["calibration.fbs"],
16 target_compatible_with = ["@platforms//os:linux"],
17)
18
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080019flatbuffer_py_library(
20 name = "calibration_fbs_python",
21 srcs = [
22 "calibration.fbs",
23 ],
24 namespace = "frc971.vision.calibration",
25 tables = [
26 "CalibrationData",
27 "CameraCalibration",
28 "TransformationMatrix",
29 ],
30 target_compatible_with = ["@platforms//os:linux"],
31 visibility = ["//visibility:public"],
32)
33
James Kuszmaulb35e2342022-03-06 15:44:00 -080034ts_library(
35 name = "vision_plotter",
36 srcs = ["vision_plotter.ts"],
37 target_compatible_with = ["@platforms//os:linux"],
38 visibility = ["//visibility:public"],
39 deps = [
Milind Upadhyayd836bce2022-03-25 21:49:57 -070040 ":target_estimate_ts_fbs",
41 "//aos:configuration_ts_fbs",
James Kuszmaulb35e2342022-03-06 15:44:00 -080042 "//aos/network/www:aos_plotter",
43 "//aos/network/www:colors",
44 "//aos/network/www:proxy",
Milind Upadhyayd836bce2022-03-25 21:49:57 -070045 "//aos/network/www:reflection_ts",
46 "@com_github_google_flatbuffers//reflection:reflection_ts_fbs",
47 "@com_github_google_flatbuffers//ts:flatbuffers_ts",
James Kuszmaulb35e2342022-03-06 15:44:00 -080048 ],
49)
50
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080051py_library(
52 name = "camera_definition",
53 srcs = [
54 "camera_definition.py",
55 ],
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -080056 deps = [
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080057 "//external:python-glog",
58 ],
59)
60
61py_binary(
62 name = "create_calib_file",
63 srcs = [
64 "create_calib_file.py",
65 ],
66 args = [
67 "calibration_data.h",
68 ],
69 data = glob(["calib_files/*.json"]),
70 target_compatible_with = ["@platforms//os:linux"],
71 deps = [
72 ":camera_definition",
73 "//external:python-glog",
74 "//y2022/vision:calibration_fbs_python",
75 "@bazel_tools//tools/python/runfiles",
76 "@opencv_contrib_nonfree_amd64//:python_opencv",
77 ],
78)
79
80genrule(
81 name = "run_calibration_data",
82 outs = [
83 "calibration_data.h",
84 ],
85 cmd = " ".join([
86 "$(location :create_calib_file)",
87 "$(location calibration_data.h)",
88 ]),
89 target_compatible_with = ["@platforms//os:linux"],
90 tools = [
91 ":create_calib_file",
92 ],
93)
94
95cc_library(
96 name = "calibration_data",
97 hdrs = [
98 "calibration_data.h",
99 ],
100 target_compatible_with = ["@platforms//os:linux"],
101 visibility = ["//visibility:public"],
102 deps = [
103 "@com_google_absl//absl/types:span",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800104 ],
105)
106
107cc_library(
108 name = "camera_reader_lib",
109 srcs = [
110 "camera_reader.cc",
111 ],
112 hdrs = [
113 "camera_reader.h",
Jim Ostrowski2a483b32022-02-15 18:19:14 -0800114 "gpio.h",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800115 ],
116 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800117 "//y2022:aos_config",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800118 ],
119 target_compatible_with = ["@platforms//os:linux"],
120 visibility = ["//y2022:__subpackages__"],
121 deps = [
milind-u92195982022-01-22 20:29:31 -0800122 ":blob_detector_lib",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800123 ":calibration_data",
124 ":calibration_fbs",
Henry Speisere45e7a22022-02-04 23:17:01 -0800125 ":target_estimate_fbs",
milind-u92195982022-01-22 20:29:31 -0800126 ":target_estimator_lib",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800127 "//aos:flatbuffer_merge",
128 "//aos/events:event_loop",
Henry Speiser1f34eea2022-01-30 14:35:21 -0800129 "//aos/events:shm_event_loop",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800130 "//aos/network:team_number",
131 "//frc971/vision:v4l2_reader",
132 "//frc971/vision:vision_fbs",
133 "//third_party:opencv",
Milind Upadhyayd67e9cf2022-03-13 13:56:57 -0700134 "//y2022/localizer:localizer_output_fbs",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800135 ],
136)
137
138cc_binary(
139 name = "camera_reader",
140 srcs = [
141 "camera_reader_main.cc",
142 ],
143 target_compatible_with = ["@platforms//os:linux"],
144 visibility = ["//y2022:__subpackages__"],
145 deps = [
146 ":camera_reader_lib",
147 "//aos:init",
148 "//aos/events:shm_event_loop",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800149 ],
150)
151
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700152cc_binary(
153 name = "ball_color_detector",
154 srcs = [
155 "ball_color_main.cc",
156 ],
157 target_compatible_with = ["@platforms//os:linux"],
158 visibility = ["//y2022:__subpackages__"],
159 deps = [
160 ":ball_color_lib",
161 "//aos:init",
162 "//aos/events:shm_event_loop",
163 ],
164)
165
166cc_test(
167 name = "ball_color_test",
168 srcs = [
169 "ball_color_test.cc",
170 ],
171 data = [
172 "test_ball_color_image.jpg",
173 ],
174 deps = [
175 ":ball_color_lib",
176 "//aos:json_to_flatbuffer",
177 "//aos/events:simulated_event_loop",
178 "//aos/testing:googletest",
179 "//aos/testing:test_logging",
180 "//y2022:constants",
181 ],
182)
183
184cc_library(
185 name = "ball_color_lib",
186 srcs = [
187 "ball_color.cc",
188 ],
189 hdrs = [
190 "ball_color.h",
191 ],
192 data = [
193 "//y2022:aos_config",
194 ],
195 target_compatible_with = ["@platforms//os:linux"],
196 visibility = ["//y2022:__subpackages__"],
197 deps = [
198 ":ball_color_fbs",
199 "//aos/events:event_loop",
200 "//aos/events:shm_event_loop",
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700201 "//frc971/input:joystick_state_fbs",
202 "//frc971/vision:vision_fbs",
203 "//third_party:opencv",
Milind Upadhyayc76bb4c2022-09-21 09:31:48 -0700204 "//y2022:constants",
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700205 ],
206)
207
208flatbuffer_cc_library(
209 name = "ball_color_fbs",
210 srcs = ["ball_color.fbs"],
211 gen_reflections = 1,
212 includes = [
213 "//frc971/input:joystick_state_fbs_includes",
214 ],
215 target_compatible_with = ["@platforms//os:linux"],
216 visibility = ["//y2022:__subpackages__"],
217)
218
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800219cc_library(
220 name = "blob_detector_lib",
221 srcs = [
222 "blob_detector.cc",
223 ],
224 hdrs = [
225 "blob_detector.h",
226 ],
227 target_compatible_with = ["@platforms//os:linux"],
228 visibility = ["//y2022:__subpackages__"],
229 deps = [
230 "//aos/network:team_number",
Milind Upadhyaye7aa40c2022-01-29 22:36:21 -0800231 "//aos/time",
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700232 "//frc971/vision:geometry_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800233 "//third_party:opencv",
234 ],
235)
236
milind-u92195982022-01-22 20:29:31 -0800237cc_library(
238 name = "target_estimator_lib",
239 srcs = [
240 "target_estimator.cc",
241 ],
242 hdrs = [
243 "target_estimator.h",
244 ],
245 target_compatible_with = ["@platforms//os:linux"],
246 visibility = ["//y2022:__subpackages__"],
247 deps = [
Milind Upadhyay8f38ad82022-03-03 10:06:18 -0800248 ":blob_detector_lib",
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800249 ":calibration_fbs",
milind-u92195982022-01-22 20:29:31 -0800250 ":target_estimate_fbs",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800251 "//aos/logging",
252 "//aos/time",
253 "//frc971/control_loops:quaternion_utils",
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700254 "//frc971/vision:geometry_lib",
milind-u92195982022-01-22 20:29:31 -0800255 "//third_party:opencv",
milind-ucafdd5d2022-03-01 19:58:57 -0800256 "//y2022:constants",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800257 "@com_google_absl//absl/strings:str_format",
258 "@com_google_ceres_solver//:ceres",
259 "@org_tuxfamily_eigen//:eigen",
milind-u92195982022-01-22 20:29:31 -0800260 ],
261)
262
263flatbuffer_cc_library(
264 name = "target_estimate_fbs",
265 srcs = ["target_estimate.fbs"],
266 gen_reflections = 1,
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800267 includes = [
268 ":calibration_fbs_includes",
269 ],
milind-u92195982022-01-22 20:29:31 -0800270 target_compatible_with = ["@platforms//os:linux"],
271 visibility = ["//y2022:__subpackages__"],
272)
273
Milind Upadhyayd836bce2022-03-25 21:49:57 -0700274flatbuffer_ts_library(
275 name = "target_estimate_ts_fbs",
276 srcs = ["target_estimate.fbs"],
277 target_compatible_with = ["@platforms//os:linux"],
278 deps = [
279 ":calibration_ts_fbs",
280 ],
281)
282
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800283cc_binary(
284 name = "viewer",
285 srcs = [
286 "viewer.cc",
287 ],
288 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800289 "//y2022:aos_config",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800290 ],
291 target_compatible_with = ["@platforms//os:linux"],
292 visibility = ["//y2022:__subpackages__"],
293 deps = [
294 ":blob_detector_lib",
milind-ucafdd5d2022-03-01 19:58:57 -0800295 ":calibration_data",
Milind Upadhyaya31f0272022-04-03 13:55:22 -0700296 ":camera_reader_lib",
milind-u92195982022-01-22 20:29:31 -0800297 ":target_estimator_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800298 "//aos:init",
299 "//aos/events:shm_event_loop",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800300 "//frc971/vision:vision_fbs",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800301 "//third_party:opencv",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800302 ],
303)
Austin Schuh3e145882022-02-26 16:48:43 -0800304
305cc_binary(
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800306 name = "viewer_replay",
307 srcs = [
308 "viewer_replay.cc",
309 ],
310 data = [
311 "//y2022:aos_config",
312 ],
313 target_compatible_with = ["@platforms//os:linux"],
314 visibility = ["//y2022:__subpackages__"],
315 deps = [
316 ":blob_detector_lib",
317 "//aos:init",
318 "//aos/events:simulated_event_loop",
319 "//aos/events/logging:log_reader",
Milind Upadhyaye3215862022-03-24 19:59:19 -0700320 "//frc971/control_loops:control_loops_fbs",
321 "//frc971/control_loops:profiled_subsystem_fbs",
322 "//frc971/control_loops/drivetrain:drivetrain_status_fbs",
323 "//frc971/input:joystick_state_fbs",
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800324 "//frc971/vision:vision_fbs",
325 "//third_party:opencv",
Milind Upadhyaye3215862022-03-24 19:59:19 -0700326 "//y2022/control_loops/superstructure:superstructure_status_fbs",
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800327 ],
328)
329
330cc_binary(
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800331 name = "calibrate_extrinsics",
Austin Schuh3e145882022-02-26 16:48:43 -0800332 srcs = [
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800333 "calibrate_extrinsics.cc",
Austin Schuh3e145882022-02-26 16:48:43 -0800334 ],
335 target_compatible_with = ["@platforms//os:linux"],
336 visibility = ["//y2022:__subpackages__"],
337 deps = [
338 "//aos:init",
339 "//aos/events/logging:log_reader",
340 "//frc971/control_loops:profiled_subsystem_fbs",
341 "//frc971/vision:extrinsics_calibration",
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800342 "//third_party:opencv",
Austin Schuh3e145882022-02-26 16:48:43 -0800343 "//y2022/control_loops/superstructure:superstructure_status_fbs",
344 ],
345)
James Kuszmaul3eb753d2022-03-12 15:21:12 -0800346
347cc_binary(
348 name = "image_decimator",
349 srcs = ["image_decimator.cc"],
350 visibility = ["//y2022:__subpackages__"],
351 deps = [
352 "//aos:flatbuffers",
353 "//aos:init",
354 "//aos/events:shm_event_loop",
355 "//frc971/vision:vision_fbs",
356 ],
357)