blob: 4ca85617eb2f22db9d9ea787137eed8e62282761 [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",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800123 ],
124)
125
126cc_binary(
127 name = "camera_reader",
128 srcs = [
129 "camera_reader_main.cc",
130 ],
131 target_compatible_with = ["@platforms//os:linux"],
132 visibility = ["//y2022:__subpackages__"],
133 deps = [
134 ":camera_reader_lib",
135 "//aos:init",
136 "//aos/events:shm_event_loop",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800137 ],
138)
139
140cc_library(
milind-udb98afa2022-03-01 19:54:57 -0800141 name = "geometry_lib",
142 hdrs = [
143 "geometry.h",
144 ],
145 target_compatible_with = ["@platforms//os:linux"],
146 visibility = ["//y2022:__subpackages__"],
147 deps = [
148 "//aos/util:math",
149 "//third_party:opencv",
150 "@com_github_google_glog//:glog",
151 ],
152)
153
154cc_test(
155 name = "geometry_test",
156 srcs = [
157 "geometry_test.cc",
158 ],
159 deps = [
160 ":geometry_lib",
161 "//aos/testing:googletest",
162 ],
163)
164
165cc_library(
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800166 name = "blob_detector_lib",
167 srcs = [
168 "blob_detector.cc",
169 ],
170 hdrs = [
171 "blob_detector.h",
172 ],
173 target_compatible_with = ["@platforms//os:linux"],
174 visibility = ["//y2022:__subpackages__"],
175 deps = [
milind-udb98afa2022-03-01 19:54:57 -0800176 ":geometry_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800177 "//aos/network:team_number",
Milind Upadhyaye7aa40c2022-01-29 22:36:21 -0800178 "//aos/time",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800179 "//third_party:opencv",
180 ],
181)
182
milind-u92195982022-01-22 20:29:31 -0800183cc_library(
184 name = "target_estimator_lib",
185 srcs = [
186 "target_estimator.cc",
187 ],
188 hdrs = [
189 "target_estimator.h",
190 ],
191 target_compatible_with = ["@platforms//os:linux"],
192 visibility = ["//y2022:__subpackages__"],
193 deps = [
Milind Upadhyay8f38ad82022-03-03 10:06:18 -0800194 ":blob_detector_lib",
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800195 ":calibration_fbs",
milind-u92195982022-01-22 20:29:31 -0800196 ":target_estimate_fbs",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800197 "//aos/logging",
198 "//aos/time",
199 "//frc971/control_loops:quaternion_utils",
milind-u92195982022-01-22 20:29:31 -0800200 "//third_party:opencv",
milind-ucafdd5d2022-03-01 19:58:57 -0800201 "//y2022:constants",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800202 "@com_google_absl//absl/strings:str_format",
203 "@com_google_ceres_solver//:ceres",
204 "@org_tuxfamily_eigen//:eigen",
milind-u92195982022-01-22 20:29:31 -0800205 ],
206)
207
208flatbuffer_cc_library(
209 name = "target_estimate_fbs",
210 srcs = ["target_estimate.fbs"],
211 gen_reflections = 1,
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800212 includes = [
213 ":calibration_fbs_includes",
214 ],
milind-u92195982022-01-22 20:29:31 -0800215 target_compatible_with = ["@platforms//os:linux"],
216 visibility = ["//y2022:__subpackages__"],
217)
218
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800219cc_binary(
220 name = "viewer",
221 srcs = [
222 "viewer.cc",
223 ],
224 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800225 "//y2022:aos_config",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800226 ],
227 target_compatible_with = ["@platforms//os:linux"],
228 visibility = ["//y2022:__subpackages__"],
229 deps = [
230 ":blob_detector_lib",
milind-ucafdd5d2022-03-01 19:58:57 -0800231 ":calibration_data",
milind-u92195982022-01-22 20:29:31 -0800232 ":target_estimator_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800233 "//aos:init",
234 "//aos/events:shm_event_loop",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800235 "//frc971/vision:vision_fbs",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800236 "//third_party:opencv",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800237 ],
238)
Austin Schuh3e145882022-02-26 16:48:43 -0800239
240cc_binary(
241 name = "extrinsics_calibration",
242 srcs = [
243 "extrinsics_calibration.cc",
244 ],
245 target_compatible_with = ["@platforms//os:linux"],
246 visibility = ["//y2022:__subpackages__"],
247 deps = [
248 "//aos:init",
249 "//aos/events/logging:log_reader",
250 "//frc971/control_loops:profiled_subsystem_fbs",
251 "//frc971/vision:extrinsics_calibration",
252 "//y2022/control_loops/superstructure:superstructure_status_fbs",
253 ],
254)