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/constants.h b/y2019/vision/constants.h
index cc6775e..3f07f87 100644
--- a/y2019/vision/constants.h
+++ b/y2019/vision/constants.h
@@ -79,7 +79,26 @@
const CameraCalibration *GetCamera(int camera_id);
-void DumpCameraConstants(int camera_id, const CameraCalibration &value);
+// Serial number of the teensy for each robot.
+constexpr uint32_t CodeBotTeensyId() { return 0xffff322e; }
+
+// Get the IDs of the cameras in each port for a particular teensy board.
+// inlined so that we don't have to deal with including it in the autogenerated
+// constants.cc.
+inline std::array<int, 5> CameraSerialNumbers(uint32_t processor_id) {
+ switch (processor_id) {
+ case CodeBotTeensyId():
+ return {{0, 0, 0, 16, 19}};
+ default:
+ return {{0, 0, 0, 0, 0}};
+ }
+}
+
+// Rewrites constants.cc, adding camera calibration constants for the camera_id
+// specified. If camera_id is less than zero, just rewrites the file without
+// changing anything.
+void DumpCameraConstants(const char *fname, int camera_id,
+ const CameraCalibration &value);
} // namespace vision
} // namespace y2019