blob: 233465e2baa7c7591113d83aed34cc9ec77ef6e2 [file] [log] [blame]
Milind Upadhyayd836bce2022-03-25 21:49:57 -07001load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_py_library", "flatbuffer_ts_library")
James Kuszmaulb35e2342022-03-06 15:44:00 -08002load("@npm//@bazel/typescript:index.bzl", "ts_library")
milind-u92195982022-01-22 20:29:31 -08003
Jim Ostrowski007e2ea2022-01-30 13:13:26 -08004flatbuffer_cc_library(
5 name = "calibration_fbs",
6 srcs = ["calibration.fbs"],
7 gen_reflections = 1,
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -08008 target_compatible_with = ["@platforms//os:linux"],
9 visibility = ["//y2022:__subpackages__"],
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080010)
11
Milind Upadhyayd836bce2022-03-25 21:49:57 -070012flatbuffer_ts_library(
13 name = "calibration_ts_fbs",
14 srcs = ["calibration.fbs"],
15 target_compatible_with = ["@platforms//os:linux"],
16)
17
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080018flatbuffer_py_library(
19 name = "calibration_fbs_python",
20 srcs = [
21 "calibration.fbs",
22 ],
23 namespace = "frc971.vision.calibration",
24 tables = [
25 "CalibrationData",
26 "CameraCalibration",
27 "TransformationMatrix",
28 ],
29 target_compatible_with = ["@platforms//os:linux"],
30 visibility = ["//visibility:public"],
31)
32
James Kuszmaulb35e2342022-03-06 15:44:00 -080033ts_library(
34 name = "vision_plotter",
35 srcs = ["vision_plotter.ts"],
36 target_compatible_with = ["@platforms//os:linux"],
37 visibility = ["//visibility:public"],
38 deps = [
Milind Upadhyayd836bce2022-03-25 21:49:57 -070039 ":target_estimate_ts_fbs",
40 "//aos:configuration_ts_fbs",
James Kuszmaulb35e2342022-03-06 15:44:00 -080041 "//aos/network/www:aos_plotter",
42 "//aos/network/www:colors",
43 "//aos/network/www:proxy",
Milind Upadhyayd836bce2022-03-25 21:49:57 -070044 "//aos/network/www:reflection_ts",
45 "@com_github_google_flatbuffers//reflection:reflection_ts_fbs",
46 "@com_github_google_flatbuffers//ts:flatbuffers_ts",
James Kuszmaulb35e2342022-03-06 15:44:00 -080047 ],
48)
49
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080050py_library(
51 name = "camera_definition",
52 srcs = [
53 "camera_definition.py",
54 ],
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -080055 deps = [
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080056 "//external:python-glog",
57 ],
58)
59
60py_binary(
61 name = "create_calib_file",
62 srcs = [
63 "create_calib_file.py",
64 ],
65 args = [
66 "calibration_data.h",
67 ],
68 data = glob(["calib_files/*.json"]),
69 target_compatible_with = ["@platforms//os:linux"],
70 deps = [
71 ":camera_definition",
72 "//external:python-glog",
73 "//y2022/vision:calibration_fbs_python",
74 "@bazel_tools//tools/python/runfiles",
75 "@opencv_contrib_nonfree_amd64//:python_opencv",
76 ],
77)
78
79genrule(
80 name = "run_calibration_data",
81 outs = [
82 "calibration_data.h",
83 ],
84 cmd = " ".join([
85 "$(location :create_calib_file)",
86 "$(location calibration_data.h)",
87 ]),
88 target_compatible_with = ["@platforms//os:linux"],
89 tools = [
90 ":create_calib_file",
91 ],
92)
93
94cc_library(
95 name = "calibration_data",
96 hdrs = [
97 "calibration_data.h",
98 ],
99 target_compatible_with = ["@platforms//os:linux"],
100 visibility = ["//visibility:public"],
101 deps = [
102 "@com_google_absl//absl/types:span",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800103 ],
104)
105
106cc_library(
107 name = "camera_reader_lib",
108 srcs = [
109 "camera_reader.cc",
110 ],
111 hdrs = [
112 "camera_reader.h",
Jim Ostrowski2a483b32022-02-15 18:19:14 -0800113 "gpio.h",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800114 ],
115 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800116 "//y2022:aos_config",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800117 ],
118 target_compatible_with = ["@platforms//os:linux"],
119 visibility = ["//y2022:__subpackages__"],
120 deps = [
milind-u92195982022-01-22 20:29:31 -0800121 ":blob_detector_lib",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800122 ":calibration_data",
123 ":calibration_fbs",
Henry Speisere45e7a22022-02-04 23:17:01 -0800124 ":target_estimate_fbs",
milind-u92195982022-01-22 20:29:31 -0800125 ":target_estimator_lib",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800126 "//aos:flatbuffer_merge",
127 "//aos/events:event_loop",
Henry Speiser1f34eea2022-01-30 14:35:21 -0800128 "//aos/events:shm_event_loop",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800129 "//aos/network:team_number",
130 "//frc971/vision:v4l2_reader",
131 "//frc971/vision:vision_fbs",
132 "//third_party:opencv",
Milind Upadhyayd67e9cf2022-03-13 13:56:57 -0700133 "//y2022/localizer:localizer_output_fbs",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800134 ],
135)
136
137cc_binary(
138 name = "camera_reader",
139 srcs = [
140 "camera_reader_main.cc",
141 ],
142 target_compatible_with = ["@platforms//os:linux"],
143 visibility = ["//y2022:__subpackages__"],
144 deps = [
145 ":camera_reader_lib",
146 "//aos:init",
147 "//aos/events:shm_event_loop",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800148 ],
149)
150
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700151cc_binary(
152 name = "ball_color_detector",
153 srcs = [
154 "ball_color_main.cc",
155 ],
156 target_compatible_with = ["@platforms//os:linux"],
157 visibility = ["//y2022:__subpackages__"],
158 deps = [
159 ":ball_color_lib",
160 "//aos:init",
161 "//aos/events:shm_event_loop",
162 ],
163)
164
165cc_test(
166 name = "ball_color_test",
167 srcs = [
168 "ball_color_test.cc",
169 ],
170 data = [
171 "test_ball_color_image.jpg",
172 ],
173 deps = [
174 ":ball_color_lib",
175 "//aos:json_to_flatbuffer",
176 "//aos/events:simulated_event_loop",
177 "//aos/testing:googletest",
178 "//aos/testing:test_logging",
179 "//y2022:constants",
180 ],
181)
182
183cc_library(
184 name = "ball_color_lib",
185 srcs = [
186 "ball_color.cc",
187 ],
188 hdrs = [
189 "ball_color.h",
190 ],
191 data = [
192 "//y2022:aos_config",
193 ],
194 target_compatible_with = ["@platforms//os:linux"],
195 visibility = ["//y2022:__subpackages__"],
196 deps = [
197 ":ball_color_fbs",
198 "//aos/events:event_loop",
199 "//aos/events:shm_event_loop",
200 "//aos/network:team_number",
201 "//frc971/input:joystick_state_fbs",
202 "//frc971/vision:vision_fbs",
203 "//third_party:opencv",
204 ],
205)
206
207flatbuffer_cc_library(
208 name = "ball_color_fbs",
209 srcs = ["ball_color.fbs"],
210 gen_reflections = 1,
211 includes = [
212 "//frc971/input:joystick_state_fbs_includes",
213 ],
214 target_compatible_with = ["@platforms//os:linux"],
215 visibility = ["//y2022:__subpackages__"],
216)
217
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800218cc_library(
219 name = "blob_detector_lib",
220 srcs = [
221 "blob_detector.cc",
222 ],
223 hdrs = [
224 "blob_detector.h",
225 ],
226 target_compatible_with = ["@platforms//os:linux"],
227 visibility = ["//y2022:__subpackages__"],
228 deps = [
229 "//aos/network:team_number",
Milind Upadhyaye7aa40c2022-01-29 22:36:21 -0800230 "//aos/time",
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700231 "//frc971/vision:geometry_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800232 "//third_party:opencv",
233 ],
234)
235
milind-u92195982022-01-22 20:29:31 -0800236cc_library(
237 name = "target_estimator_lib",
238 srcs = [
239 "target_estimator.cc",
240 ],
241 hdrs = [
242 "target_estimator.h",
243 ],
244 target_compatible_with = ["@platforms//os:linux"],
245 visibility = ["//y2022:__subpackages__"],
246 deps = [
Milind Upadhyay8f38ad82022-03-03 10:06:18 -0800247 ":blob_detector_lib",
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800248 ":calibration_fbs",
milind-u92195982022-01-22 20:29:31 -0800249 ":target_estimate_fbs",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800250 "//aos/logging",
251 "//aos/time",
252 "//frc971/control_loops:quaternion_utils",
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700253 "//frc971/vision:geometry_lib",
milind-u92195982022-01-22 20:29:31 -0800254 "//third_party:opencv",
milind-ucafdd5d2022-03-01 19:58:57 -0800255 "//y2022:constants",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800256 "@com_google_absl//absl/strings:str_format",
257 "@com_google_ceres_solver//:ceres",
258 "@org_tuxfamily_eigen//:eigen",
milind-u92195982022-01-22 20:29:31 -0800259 ],
260)
261
262flatbuffer_cc_library(
263 name = "target_estimate_fbs",
264 srcs = ["target_estimate.fbs"],
265 gen_reflections = 1,
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800266 includes = [
267 ":calibration_fbs_includes",
268 ],
milind-u92195982022-01-22 20:29:31 -0800269 target_compatible_with = ["@platforms//os:linux"],
270 visibility = ["//y2022:__subpackages__"],
271)
272
Milind Upadhyayd836bce2022-03-25 21:49:57 -0700273flatbuffer_ts_library(
274 name = "target_estimate_ts_fbs",
275 srcs = ["target_estimate.fbs"],
276 target_compatible_with = ["@platforms//os:linux"],
277 deps = [
278 ":calibration_ts_fbs",
279 ],
280)
281
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800282cc_binary(
283 name = "viewer",
284 srcs = [
285 "viewer.cc",
286 ],
287 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800288 "//y2022:aos_config",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800289 ],
290 target_compatible_with = ["@platforms//os:linux"],
291 visibility = ["//y2022:__subpackages__"],
292 deps = [
293 ":blob_detector_lib",
milind-ucafdd5d2022-03-01 19:58:57 -0800294 ":calibration_data",
Milind Upadhyaya31f0272022-04-03 13:55:22 -0700295 ":camera_reader_lib",
milind-u92195982022-01-22 20:29:31 -0800296 ":target_estimator_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800297 "//aos:init",
298 "//aos/events:shm_event_loop",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800299 "//frc971/vision:vision_fbs",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800300 "//third_party:opencv",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800301 ],
302)
Austin Schuh3e145882022-02-26 16:48:43 -0800303
304cc_binary(
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800305 name = "viewer_replay",
306 srcs = [
307 "viewer_replay.cc",
308 ],
309 data = [
310 "//y2022:aos_config",
311 ],
312 target_compatible_with = ["@platforms//os:linux"],
313 visibility = ["//y2022:__subpackages__"],
314 deps = [
315 ":blob_detector_lib",
316 "//aos:init",
317 "//aos/events:simulated_event_loop",
318 "//aos/events/logging:log_reader",
Milind Upadhyaye3215862022-03-24 19:59:19 -0700319 "//frc971/control_loops:control_loops_fbs",
320 "//frc971/control_loops:profiled_subsystem_fbs",
321 "//frc971/control_loops/drivetrain:drivetrain_status_fbs",
322 "//frc971/input:joystick_state_fbs",
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800323 "//frc971/vision:vision_fbs",
324 "//third_party:opencv",
Milind Upadhyaye3215862022-03-24 19:59:19 -0700325 "//y2022/control_loops/superstructure:superstructure_status_fbs",
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800326 ],
327)
328
329cc_binary(
Austin Schuh3e145882022-02-26 16:48:43 -0800330 name = "extrinsics_calibration",
331 srcs = [
332 "extrinsics_calibration.cc",
333 ],
334 target_compatible_with = ["@platforms//os:linux"],
335 visibility = ["//y2022:__subpackages__"],
336 deps = [
337 "//aos:init",
338 "//aos/events/logging:log_reader",
339 "//frc971/control_loops:profiled_subsystem_fbs",
340 "//frc971/vision:extrinsics_calibration",
341 "//y2022/control_loops/superstructure:superstructure_status_fbs",
342 ],
343)
James Kuszmaul3eb753d2022-03-12 15:21:12 -0800344
345cc_binary(
346 name = "image_decimator",
347 srcs = ["image_decimator.cc"],
348 visibility = ["//y2022:__subpackages__"],
349 deps = [
350 "//aos:flatbuffers",
351 "//aos:init",
352 "//aos/events:shm_event_loop",
353 "//frc971/vision:vision_fbs",
354 ],
355)