Add time-since-last-target to server
And draw little cameras on the robot that turn green when we got a
target from that camera in the last 0.25sec.
Change-Id: Icd6107163fd3f5145fcba69ac6ebb2700f602f8d
diff --git a/y2019/vision/server/www/generate_camera.cc b/y2019/vision/server/www/generate_camera.cc
new file mode 100644
index 0000000..8e516c3
--- /dev/null
+++ b/y2019/vision/server/www/generate_camera.cc
@@ -0,0 +1,33 @@
+#include "y2019/constants.h"
+#include "y2019/vision/constants.h"
+
+#include <fstream>
+#include <iostream>
+
+namespace y2019 {
+namespace vision {
+void DumpPose(std::basic_ostream<char> *o, const vision::CameraGeometry &pose) {
+ *o << "{x: " << pose.location[0] << ", y: " << pose.location[1]
+ << ", theta: " << pose.heading << "}";
+}
+void DumpTypescriptConstants(const char *fname) {
+ ::std::ofstream out_file(fname);
+ out_file << "export const CAMERA_POSES = [\n";
+ for (size_t ii = 0; ii < constants::Values::kNumCameras; ++ii) {
+ out_file << " ";
+ DumpPose(&out_file,
+ GetCamera(CameraSerialNumbers(CompBotTeensyId())[ii])->geometry);
+ out_file << ",\n";
+ }
+ out_file << "];\n";
+}
+} // namespace constants
+} // namespace y2019
+
+int main(int argc, char *argv[]) {
+ if (argc != 2) {
+ ::std::cout << "Must provide a filename for output as an argument\n";
+ return 1;
+ }
+ ::y2019::vision::DumpTypescriptConstants(argv[1]);
+}