James Kuszmaul | 92ba0e5 | 2019-03-29 17:19:30 -0700 | [diff] [blame] | 1 | #include <fstream> |
| 2 | #include <iostream> |
| 3 | |
Philipp Schrader | 790cb54 | 2023-07-05 21:06:52 -0700 | [diff] [blame] | 4 | #include "y2019/constants.h" |
| 5 | #include "y2019/vision/constants.h" |
| 6 | |
Stephan Pleines | f63bde8 | 2024-01-13 15:59:33 -0800 | [diff] [blame^] | 7 | namespace y2019::vision { |
James Kuszmaul | 92ba0e5 | 2019-03-29 17:19:30 -0700 | [diff] [blame] | 8 | void DumpPose(std::basic_ostream<char> *o, const vision::CameraGeometry &pose) { |
| 9 | *o << "{x: " << pose.location[0] << ", y: " << pose.location[1] |
Philipp Schrader | 790cb54 | 2023-07-05 21:06:52 -0700 | [diff] [blame] | 10 | << ", theta: " << pose.heading << "}"; |
James Kuszmaul | 92ba0e5 | 2019-03-29 17:19:30 -0700 | [diff] [blame] | 11 | } |
| 12 | void DumpTypescriptConstants(const char *fname) { |
| 13 | ::std::ofstream out_file(fname); |
| 14 | out_file << "export const CAMERA_POSES = [\n"; |
| 15 | for (size_t ii = 0; ii < constants::Values::kNumCameras; ++ii) { |
| 16 | out_file << " "; |
James Kuszmaul | d6d37d1 | 2019-03-30 13:04:54 -0700 | [diff] [blame] | 17 | // TODO(james): Decide how to manage visualization for practice and code |
| 18 | // bots. |
James Kuszmaul | 92ba0e5 | 2019-03-29 17:19:30 -0700 | [diff] [blame] | 19 | DumpPose(&out_file, |
| 20 | GetCamera(CameraSerialNumbers(CompBotTeensyId())[ii])->geometry); |
| 21 | out_file << ",\n"; |
| 22 | } |
| 23 | out_file << "];\n"; |
| 24 | } |
Stephan Pleines | f63bde8 | 2024-01-13 15:59:33 -0800 | [diff] [blame^] | 25 | } // namespace y2019::vision |
James Kuszmaul | 92ba0e5 | 2019-03-29 17:19:30 -0700 | [diff] [blame] | 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 | } |