James Kuszmaul | 92ba0e5 | 2019-03-29 17:19:30 -0700 | [diff] [blame^] | 1 | #include "y2019/constants.h" |
| 2 | #include "y2019/vision/constants.h" |
| 3 | |
| 4 | #include <fstream> |
| 5 | #include <iostream> |
| 6 | |
| 7 | namespace y2019 { |
| 8 | namespace vision { |
| 9 | void DumpPose(std::basic_ostream<char> *o, const vision::CameraGeometry &pose) { |
| 10 | *o << "{x: " << pose.location[0] << ", y: " << pose.location[1] |
| 11 | << ", theta: " << pose.heading << "}"; |
| 12 | } |
| 13 | void DumpTypescriptConstants(const char *fname) { |
| 14 | ::std::ofstream out_file(fname); |
| 15 | out_file << "export const CAMERA_POSES = [\n"; |
| 16 | for (size_t ii = 0; ii < constants::Values::kNumCameras; ++ii) { |
| 17 | out_file << " "; |
| 18 | DumpPose(&out_file, |
| 19 | GetCamera(CameraSerialNumbers(CompBotTeensyId())[ii])->geometry); |
| 20 | out_file << ",\n"; |
| 21 | } |
| 22 | out_file << "];\n"; |
| 23 | } |
| 24 | } // namespace constants |
| 25 | } // namespace y2019 |
| 26 | |
| 27 | int main(int argc, char *argv[]) { |
| 28 | if (argc != 2) { |
| 29 | ::std::cout << "Must provide a filename for output as an argument\n"; |
| 30 | return 1; |
| 31 | } |
| 32 | ::y2019::vision::DumpTypescriptConstants(argv[1]); |
| 33 | } |