blob: 8e516c35250a9892e32d1237e188a85225bd6fa7 [file] [log] [blame]
James Kuszmaul92ba0e52019-03-29 17:19:30 -07001#include "y2019/constants.h"
2#include "y2019/vision/constants.h"
3
4#include <fstream>
5#include <iostream>
6
7namespace y2019 {
8namespace vision {
9void 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}
13void 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
27int 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}