blob: 523ee0450180d625858aeb187417c2fc828149b3 [file] [log] [blame]
James Kuszmaulf01da392023-12-14 11:22:14 -08001load("//aos/flatbuffers:generate.bzl", "static_flatbuffer")
Philipp Schrader3de4dfc2023-02-15 20:18:25 -08002load("//tools/build_rules:js.bzl", "ts_project")
Austin Schuha1d006e2022-09-14 21:50:42 -07003load("@com_github_google_flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
milind-u92195982022-01-22 20:29:31 -08004
Philipp Schrader3de4dfc2023-02-15 20:18:25 -08005ts_project(
James Kuszmaulb35e2342022-03-06 15:44:00 -08006 name = "vision_plotter",
7 srcs = ["vision_plotter.ts"],
8 target_compatible_with = ["@platforms//os:linux"],
9 visibility = ["//visibility:public"],
10 deps = [
Milind Upadhyayd836bce2022-03-25 21:49:57 -070011 ":target_estimate_ts_fbs",
12 "//aos:configuration_ts_fbs",
James Kuszmaulb35e2342022-03-06 15:44:00 -080013 "//aos/network/www:aos_plotter",
14 "//aos/network/www:colors",
15 "//aos/network/www:proxy",
Milind Upadhyayd836bce2022-03-25 21:49:57 -070016 "//aos/network/www:reflection_ts",
17 "@com_github_google_flatbuffers//reflection:reflection_ts_fbs",
18 "@com_github_google_flatbuffers//ts:flatbuffers_ts",
James Kuszmaulb35e2342022-03-06 15:44:00 -080019 ],
20)
21
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080022py_library(
23 name = "camera_definition",
24 srcs = [
25 "camera_definition.py",
26 ],
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -080027 deps = [
Philipp Schraderebb658f2022-09-17 17:31:09 -070028 "@pip//glog",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080029 ],
30)
31
32py_binary(
33 name = "create_calib_file",
34 srcs = [
35 "create_calib_file.py",
36 ],
37 args = [
38 "calibration_data.h",
39 ],
40 data = glob(["calib_files/*.json"]),
41 target_compatible_with = ["@platforms//os:linux"],
42 deps = [
43 ":camera_definition",
milind-u2f101fc2023-01-21 12:28:49 -080044 "//frc971/vision:calibration_fbs_python",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080045 "@bazel_tools//tools/python/runfiles",
Philipp Schraderebb658f2022-09-17 17:31:09 -070046 "@pip//glog",
47 "@pip//opencv_python",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080048 ],
49)
50
51genrule(
52 name = "run_calibration_data",
53 outs = [
54 "calibration_data.h",
55 ],
56 cmd = " ".join([
57 "$(location :create_calib_file)",
58 "$(location calibration_data.h)",
59 ]),
60 target_compatible_with = ["@platforms//os:linux"],
61 tools = [
62 ":create_calib_file",
63 ],
64)
65
66cc_library(
67 name = "calibration_data",
68 hdrs = [
69 "calibration_data.h",
70 ],
71 target_compatible_with = ["@platforms//os:linux"],
72 visibility = ["//visibility:public"],
73 deps = [
74 "@com_google_absl//absl/types:span",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -080075 ],
76)
77
78cc_library(
79 name = "camera_reader_lib",
80 srcs = [
81 "camera_reader.cc",
82 ],
83 hdrs = [
84 "camera_reader.h",
Jim Ostrowski2a483b32022-02-15 18:19:14 -080085 "gpio.h",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -080086 ],
87 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -080088 "//y2022:aos_config",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -080089 ],
90 target_compatible_with = ["@platforms//os:linux"],
91 visibility = ["//y2022:__subpackages__"],
92 deps = [
milind-u92195982022-01-22 20:29:31 -080093 ":blob_detector_lib",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080094 ":calibration_data",
Henry Speisere45e7a22022-02-04 23:17:01 -080095 ":target_estimate_fbs",
milind-u92195982022-01-22 20:29:31 -080096 ":target_estimator_lib",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -080097 "//aos:flatbuffer_merge",
98 "//aos/events:event_loop",
Henry Speiser1f34eea2022-01-30 14:35:21 -080099 "//aos/events:shm_event_loop",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800100 "//aos/network:team_number",
James Kuszmaule3df1ed2023-02-20 16:21:17 -0800101 "//frc971/control_loops/drivetrain/localization:localizer_output_fbs",
milind-u2f101fc2023-01-21 12:28:49 -0800102 "//frc971/vision:calibration_fbs",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800103 "//frc971/vision:v4l2_reader",
104 "//frc971/vision:vision_fbs",
105 "//third_party:opencv",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800106 ],
107)
108
109cc_binary(
110 name = "camera_reader",
111 srcs = [
112 "camera_reader_main.cc",
113 ],
114 target_compatible_with = ["@platforms//os:linux"],
115 visibility = ["//y2022:__subpackages__"],
116 deps = [
117 ":camera_reader_lib",
118 "//aos:init",
119 "//aos/events:shm_event_loop",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800120 ],
121)
122
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700123cc_binary(
124 name = "ball_color_detector",
125 srcs = [
126 "ball_color_main.cc",
127 ],
128 target_compatible_with = ["@platforms//os:linux"],
129 visibility = ["//y2022:__subpackages__"],
130 deps = [
131 ":ball_color_lib",
132 "//aos:init",
133 "//aos/events:shm_event_loop",
134 ],
135)
136
137cc_test(
138 name = "ball_color_test",
139 srcs = [
140 "ball_color_test.cc",
141 ],
142 data = [
143 "test_ball_color_image.jpg",
144 ],
145 deps = [
146 ":ball_color_lib",
147 "//aos:json_to_flatbuffer",
148 "//aos/events:simulated_event_loop",
149 "//aos/testing:googletest",
150 "//aos/testing:test_logging",
151 "//y2022:constants",
152 ],
153)
154
155cc_library(
156 name = "ball_color_lib",
157 srcs = [
158 "ball_color.cc",
159 ],
160 hdrs = [
161 "ball_color.h",
162 ],
163 data = [
164 "//y2022:aos_config",
165 ],
166 target_compatible_with = ["@platforms//os:linux"],
167 visibility = ["//y2022:__subpackages__"],
168 deps = [
169 ":ball_color_fbs",
170 "//aos/events:event_loop",
171 "//aos/events:shm_event_loop",
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700172 "//frc971/input:joystick_state_fbs",
173 "//frc971/vision:vision_fbs",
174 "//third_party:opencv",
Milind Upadhyayc76bb4c2022-09-21 09:31:48 -0700175 "//y2022:constants",
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700176 ],
177)
178
James Kuszmaulf01da392023-12-14 11:22:14 -0800179static_flatbuffer(
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700180 name = "ball_color_fbs",
181 srcs = ["ball_color.fbs"],
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700182 target_compatible_with = ["@platforms//os:linux"],
183 visibility = ["//y2022:__subpackages__"],
James Kuszmaulf01da392023-12-14 11:22:14 -0800184 deps = [
185 "//frc971/input:joystick_state_fbs",
186 ],
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700187)
188
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800189cc_library(
190 name = "blob_detector_lib",
191 srcs = [
192 "blob_detector.cc",
193 ],
194 hdrs = [
195 "blob_detector.h",
196 ],
197 target_compatible_with = ["@platforms//os:linux"],
198 visibility = ["//y2022:__subpackages__"],
199 deps = [
200 "//aos/network:team_number",
Milind Upadhyaye7aa40c2022-01-29 22:36:21 -0800201 "//aos/time",
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700202 "//frc971/vision:geometry_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800203 "//third_party:opencv",
204 ],
205)
206
milind-u92195982022-01-22 20:29:31 -0800207cc_library(
208 name = "target_estimator_lib",
209 srcs = [
210 "target_estimator.cc",
211 ],
212 hdrs = [
213 "target_estimator.h",
214 ],
215 target_compatible_with = ["@platforms//os:linux"],
216 visibility = ["//y2022:__subpackages__"],
217 deps = [
Milind Upadhyay8f38ad82022-03-03 10:06:18 -0800218 ":blob_detector_lib",
milind-u92195982022-01-22 20:29:31 -0800219 ":target_estimate_fbs",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800220 "//aos/logging",
221 "//aos/time",
222 "//frc971/control_loops:quaternion_utils",
milind-u2f101fc2023-01-21 12:28:49 -0800223 "//frc971/vision:calibration_fbs",
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700224 "//frc971/vision:geometry_lib",
milind-u92195982022-01-22 20:29:31 -0800225 "//third_party:opencv",
milind-ucafdd5d2022-03-01 19:58:57 -0800226 "//y2022:constants",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800227 "@com_google_absl//absl/strings:str_format",
228 "@com_google_ceres_solver//:ceres",
229 "@org_tuxfamily_eigen//:eigen",
milind-u92195982022-01-22 20:29:31 -0800230 ],
231)
232
James Kuszmaulf01da392023-12-14 11:22:14 -0800233static_flatbuffer(
milind-u92195982022-01-22 20:29:31 -0800234 name = "target_estimate_fbs",
235 srcs = ["target_estimate.fbs"],
milind-u92195982022-01-22 20:29:31 -0800236 target_compatible_with = ["@platforms//os:linux"],
237 visibility = ["//y2022:__subpackages__"],
James Kuszmaulf01da392023-12-14 11:22:14 -0800238 deps = [
239 "//frc971/vision:calibration_fbs",
240 ],
milind-u92195982022-01-22 20:29:31 -0800241)
242
Milind Upadhyayd836bce2022-03-25 21:49:57 -0700243flatbuffer_ts_library(
244 name = "target_estimate_ts_fbs",
245 srcs = ["target_estimate.fbs"],
246 target_compatible_with = ["@platforms//os:linux"],
247 deps = [
milind-u2f101fc2023-01-21 12:28:49 -0800248 "//frc971/vision:calibration_ts_fbs",
Milind Upadhyayd836bce2022-03-25 21:49:57 -0700249 ],
250)
251
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800252cc_binary(
253 name = "viewer",
254 srcs = [
255 "viewer.cc",
256 ],
257 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800258 "//y2022:aos_config",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800259 ],
260 target_compatible_with = ["@platforms//os:linux"],
261 visibility = ["//y2022:__subpackages__"],
262 deps = [
263 ":blob_detector_lib",
milind-ucafdd5d2022-03-01 19:58:57 -0800264 ":calibration_data",
Milind Upadhyaya31f0272022-04-03 13:55:22 -0700265 ":camera_reader_lib",
milind-u92195982022-01-22 20:29:31 -0800266 ":target_estimator_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800267 "//aos:init",
268 "//aos/events:shm_event_loop",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800269 "//frc971/vision:vision_fbs",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800270 "//third_party:opencv",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800271 ],
272)
Austin Schuh3e145882022-02-26 16:48:43 -0800273
274cc_binary(
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800275 name = "viewer_replay",
276 srcs = [
277 "viewer_replay.cc",
278 ],
279 data = [
280 "//y2022:aos_config",
281 ],
282 target_compatible_with = ["@platforms//os:linux"],
283 visibility = ["//y2022:__subpackages__"],
284 deps = [
285 ":blob_detector_lib",
286 "//aos:init",
287 "//aos/events:simulated_event_loop",
288 "//aos/events/logging:log_reader",
Milind Upadhyaye3215862022-03-24 19:59:19 -0700289 "//frc971/control_loops:control_loops_fbs",
290 "//frc971/control_loops:profiled_subsystem_fbs",
291 "//frc971/control_loops/drivetrain:drivetrain_status_fbs",
292 "//frc971/input:joystick_state_fbs",
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800293 "//frc971/vision:vision_fbs",
294 "//third_party:opencv",
Milind Upadhyaye3215862022-03-24 19:59:19 -0700295 "//y2022/control_loops/superstructure:superstructure_status_fbs",
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800296 ],
297)
298
299cc_binary(
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800300 name = "calibrate_extrinsics",
Austin Schuh3e145882022-02-26 16:48:43 -0800301 srcs = [
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800302 "calibrate_extrinsics.cc",
Austin Schuh3e145882022-02-26 16:48:43 -0800303 ],
304 target_compatible_with = ["@platforms//os:linux"],
305 visibility = ["//y2022:__subpackages__"],
306 deps = [
307 "//aos:init",
308 "//aos/events/logging:log_reader",
309 "//frc971/control_loops:profiled_subsystem_fbs",
310 "//frc971/vision:extrinsics_calibration",
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800311 "//third_party:opencv",
Austin Schuh3e145882022-02-26 16:48:43 -0800312 "//y2022/control_loops/superstructure:superstructure_status_fbs",
313 ],
314)
James Kuszmaul3eb753d2022-03-12 15:21:12 -0800315
316cc_binary(
317 name = "image_decimator",
318 srcs = ["image_decimator.cc"],
319 visibility = ["//y2022:__subpackages__"],
320 deps = [
321 "//aos:flatbuffers",
322 "//aos:init",
323 "//aos/events:shm_event_loop",
324 "//frc971/vision:vision_fbs",
325 ],
326)
milind-ub0773e92023-02-05 15:57:43 -0800327
328filegroup(
329 name = "image_streamer_start",
330 srcs = ["image_streamer_start.sh"],
331 visibility = ["//visibility:public"],
332)