Unify source of camera geometry data

Due to parallel development, camera pose information ended up being
populated in two constants files. This makes //y2019/vision:constants
the source for all of the constants.

Also, because the camera 19 calibration was done as if it was a front
camera, I had to negate its x/y position and offset the angle by 180
degrees.

This commit also adds validation for //y2019/vision:constants.cc to
ensure that it is not accidentally changed in a way that the codegen
cannot account for.

Change-Id: I85654d973e15ae7bf76589be63c3d0eaf72c3a45
diff --git a/y2019/vision/BUILD b/y2019/vision/BUILD
index 2bdfd9c..90c7dff 100644
--- a/y2019/vision/BUILD
+++ b/y2019/vision/BUILD
@@ -12,12 +12,41 @@
 
 cc_library(
     name = "constants",
-    srcs = ["constants.cc"],
+    srcs = [
+        "constants.cc",
+        "constants_formatting.cc",
+    ],
     hdrs = ["constants.h"],
     compatible_with = mcu_cpus,
     visibility = ["//visibility:public"],
 )
 
+cc_binary(
+    name = "constants_formatting",
+    srcs = ["constants_formatting_main.cc"],
+    deps = [":constants"],
+)
+
+genrule(
+    name = "generate_constants",
+    outs = ["validate_constants.cc"],
+    cmd = "$(location :constants_formatting) $(OUTS)",
+    tools = [":constants_formatting"],
+)
+
+sh_test(
+    name = "constants_formatting_test",
+    srcs = ["constants_formatting_test.sh"],
+    args = [
+        "$(location :constants.cc)",
+        "$(location :validate_constants.cc)",
+    ],
+    data = [
+        ":constants.cc",
+        ":validate_constants.cc",
+    ],
+)
+
 cc_library(
     name = "target_finder",
     srcs = [
@@ -104,7 +133,6 @@
 cc_binary(
     name = "global_calibration",
     srcs = [
-        "constants_formatting.cc",
         "global_calibration.cc",
     ],
     restricted_to = VISION_TARGETS,