blob: 02f7fc7e4b2684cddc7bbfe9e0a4505f344f5126 [file] [log] [blame]
Jim Ostrowski007e2ea2022-01-30 13:13:26 -08001load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_py_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
12flatbuffer_py_library(
13 name = "calibration_fbs_python",
14 srcs = [
15 "calibration.fbs",
16 ],
17 namespace = "frc971.vision.calibration",
18 tables = [
19 "CalibrationData",
20 "CameraCalibration",
21 "TransformationMatrix",
22 ],
23 target_compatible_with = ["@platforms//os:linux"],
24 visibility = ["//visibility:public"],
25)
26
James Kuszmaulb35e2342022-03-06 15:44:00 -080027ts_library(
28 name = "vision_plotter",
29 srcs = ["vision_plotter.ts"],
30 target_compatible_with = ["@platforms//os:linux"],
31 visibility = ["//visibility:public"],
32 deps = [
33 "//aos/network/www:aos_plotter",
34 "//aos/network/www:colors",
35 "//aos/network/www:proxy",
36 ],
37)
38
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080039py_library(
40 name = "camera_definition",
41 srcs = [
42 "camera_definition.py",
43 ],
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -080044 deps = [
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080045 "//external:python-glog",
46 ],
47)
48
49py_binary(
50 name = "create_calib_file",
51 srcs = [
52 "create_calib_file.py",
53 ],
54 args = [
55 "calibration_data.h",
56 ],
57 data = glob(["calib_files/*.json"]),
58 target_compatible_with = ["@platforms//os:linux"],
59 deps = [
60 ":camera_definition",
61 "//external:python-glog",
62 "//y2022/vision:calibration_fbs_python",
63 "@bazel_tools//tools/python/runfiles",
64 "@opencv_contrib_nonfree_amd64//:python_opencv",
65 ],
66)
67
68genrule(
69 name = "run_calibration_data",
70 outs = [
71 "calibration_data.h",
72 ],
73 cmd = " ".join([
74 "$(location :create_calib_file)",
75 "$(location calibration_data.h)",
76 ]),
77 target_compatible_with = ["@platforms//os:linux"],
78 tools = [
79 ":create_calib_file",
80 ],
81)
82
83cc_library(
84 name = "calibration_data",
85 hdrs = [
86 "calibration_data.h",
87 ],
88 target_compatible_with = ["@platforms//os:linux"],
89 visibility = ["//visibility:public"],
90 deps = [
91 "@com_google_absl//absl/types:span",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -080092 ],
93)
94
95cc_library(
96 name = "camera_reader_lib",
97 srcs = [
98 "camera_reader.cc",
99 ],
100 hdrs = [
101 "camera_reader.h",
Jim Ostrowski2a483b32022-02-15 18:19:14 -0800102 "gpio.h",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800103 ],
104 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800105 "//y2022:aos_config",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800106 ],
107 target_compatible_with = ["@platforms//os:linux"],
108 visibility = ["//y2022:__subpackages__"],
109 deps = [
milind-u92195982022-01-22 20:29:31 -0800110 ":blob_detector_lib",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800111 ":calibration_data",
112 ":calibration_fbs",
milind-udb98afa2022-03-01 19:54:57 -0800113 ":geometry_lib",
Henry Speisere45e7a22022-02-04 23:17:01 -0800114 ":target_estimate_fbs",
milind-u92195982022-01-22 20:29:31 -0800115 ":target_estimator_lib",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800116 "//aos:flatbuffer_merge",
117 "//aos/events:event_loop",
Henry Speiser1f34eea2022-01-30 14:35:21 -0800118 "//aos/events:shm_event_loop",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800119 "//aos/network:team_number",
120 "//frc971/vision:v4l2_reader",
121 "//frc971/vision:vision_fbs",
122 "//third_party:opencv",
Milind Upadhyayd67e9cf2022-03-13 13:56:57 -0700123 "//y2022/localizer:localizer_output_fbs",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800124 ],
125)
126
127cc_binary(
128 name = "camera_reader",
129 srcs = [
130 "camera_reader_main.cc",
131 ],
132 target_compatible_with = ["@platforms//os:linux"],
133 visibility = ["//y2022:__subpackages__"],
134 deps = [
135 ":camera_reader_lib",
136 "//aos:init",
137 "//aos/events:shm_event_loop",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800138 ],
139)
140
141cc_library(
milind-udb98afa2022-03-01 19:54:57 -0800142 name = "geometry_lib",
143 hdrs = [
144 "geometry.h",
145 ],
146 target_compatible_with = ["@platforms//os:linux"],
147 visibility = ["//y2022:__subpackages__"],
148 deps = [
149 "//aos/util:math",
150 "//third_party:opencv",
151 "@com_github_google_glog//:glog",
152 ],
153)
154
155cc_test(
156 name = "geometry_test",
157 srcs = [
158 "geometry_test.cc",
159 ],
160 deps = [
161 ":geometry_lib",
162 "//aos/testing:googletest",
163 ],
164)
165
166cc_library(
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800167 name = "blob_detector_lib",
168 srcs = [
169 "blob_detector.cc",
170 ],
171 hdrs = [
172 "blob_detector.h",
173 ],
174 target_compatible_with = ["@platforms//os:linux"],
175 visibility = ["//y2022:__subpackages__"],
176 deps = [
milind-udb98afa2022-03-01 19:54:57 -0800177 ":geometry_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800178 "//aos/network:team_number",
Milind Upadhyaye7aa40c2022-01-29 22:36:21 -0800179 "//aos/time",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800180 "//third_party:opencv",
181 ],
182)
183
milind-u92195982022-01-22 20:29:31 -0800184cc_library(
185 name = "target_estimator_lib",
186 srcs = [
187 "target_estimator.cc",
188 ],
189 hdrs = [
190 "target_estimator.h",
191 ],
192 target_compatible_with = ["@platforms//os:linux"],
193 visibility = ["//y2022:__subpackages__"],
194 deps = [
Milind Upadhyay8f38ad82022-03-03 10:06:18 -0800195 ":blob_detector_lib",
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800196 ":calibration_fbs",
milind-u92195982022-01-22 20:29:31 -0800197 ":target_estimate_fbs",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800198 "//aos/logging",
199 "//aos/time",
200 "//frc971/control_loops:quaternion_utils",
milind-u92195982022-01-22 20:29:31 -0800201 "//third_party:opencv",
milind-ucafdd5d2022-03-01 19:58:57 -0800202 "//y2022:constants",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800203 "@com_google_absl//absl/strings:str_format",
204 "@com_google_ceres_solver//:ceres",
205 "@org_tuxfamily_eigen//:eigen",
milind-u92195982022-01-22 20:29:31 -0800206 ],
207)
208
209flatbuffer_cc_library(
210 name = "target_estimate_fbs",
211 srcs = ["target_estimate.fbs"],
212 gen_reflections = 1,
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800213 includes = [
214 ":calibration_fbs_includes",
215 ],
milind-u92195982022-01-22 20:29:31 -0800216 target_compatible_with = ["@platforms//os:linux"],
217 visibility = ["//y2022:__subpackages__"],
218)
219
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800220cc_binary(
221 name = "viewer",
222 srcs = [
223 "viewer.cc",
224 ],
225 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800226 "//y2022:aos_config",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800227 ],
228 target_compatible_with = ["@platforms//os:linux"],
229 visibility = ["//y2022:__subpackages__"],
230 deps = [
231 ":blob_detector_lib",
milind-ucafdd5d2022-03-01 19:58:57 -0800232 ":calibration_data",
milind-u92195982022-01-22 20:29:31 -0800233 ":target_estimator_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800234 "//aos:init",
235 "//aos/events:shm_event_loop",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800236 "//frc971/vision:vision_fbs",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800237 "//third_party:opencv",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800238 ],
239)
Austin Schuh3e145882022-02-26 16:48:43 -0800240
241cc_binary(
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800242 name = "viewer_replay",
243 srcs = [
244 "viewer_replay.cc",
245 ],
246 data = [
247 "//y2022:aos_config",
248 ],
249 target_compatible_with = ["@platforms//os:linux"],
250 visibility = ["//y2022:__subpackages__"],
251 deps = [
252 ":blob_detector_lib",
253 "//aos:init",
254 "//aos/events:simulated_event_loop",
255 "//aos/events/logging:log_reader",
256 "//frc971/vision:vision_fbs",
257 "//third_party:opencv",
258 ],
259)
260
261cc_binary(
Austin Schuh3e145882022-02-26 16:48:43 -0800262 name = "extrinsics_calibration",
263 srcs = [
264 "extrinsics_calibration.cc",
265 ],
266 target_compatible_with = ["@platforms//os:linux"],
267 visibility = ["//y2022:__subpackages__"],
268 deps = [
269 "//aos:init",
270 "//aos/events/logging:log_reader",
271 "//frc971/control_loops:profiled_subsystem_fbs",
272 "//frc971/vision:extrinsics_calibration",
273 "//y2022/control_loops/superstructure:superstructure_status_fbs",
274 ],
275)
James Kuszmaul3eb753d2022-03-12 15:21:12 -0800276
277cc_binary(
278 name = "image_decimator",
279 srcs = ["image_decimator.cc"],
280 visibility = ["//y2022:__subpackages__"],
281 deps = [
282 "//aos:flatbuffers",
283 "//aos:init",
284 "//aos/events:shm_event_loop",
285 "//frc971/vision:vision_fbs",
286 ],
287)