blob: 455b0a9618fd23ae7f1bd8494596732807e1581b [file] [log] [blame]
James Kuszmaul92ba0e52019-03-29 17:19:30 -07001#include <fstream>
2#include <iostream>
3
Philipp Schrader790cb542023-07-05 21:06:52 -07004#include "y2019/constants.h"
5#include "y2019/vision/constants.h"
6
James Kuszmaul92ba0e52019-03-29 17:19:30 -07007namespace y2019 {
8namespace vision {
9void DumpPose(std::basic_ostream<char> *o, const vision::CameraGeometry &pose) {
10 *o << "{x: " << pose.location[0] << ", y: " << pose.location[1]
Philipp Schrader790cb542023-07-05 21:06:52 -070011 << ", theta: " << pose.heading << "}";
James Kuszmaul92ba0e52019-03-29 17:19:30 -070012}
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 << " ";
James Kuszmauld6d37d12019-03-30 13:04:54 -070018 // TODO(james): Decide how to manage visualization for practice and code
19 // bots.
James Kuszmaul92ba0e52019-03-29 17:19:30 -070020 DumpPose(&out_file,
21 GetCamera(CameraSerialNumbers(CompBotTeensyId())[ii])->geometry);
22 out_file << ",\n";
23 }
24 out_file << "];\n";
25}
Philipp Schrader790cb542023-07-05 21:06:52 -070026} // namespace vision
James Kuszmaul92ba0e52019-03-29 17:19:30 -070027} // namespace y2019
28
29int main(int argc, char *argv[]) {
30 if (argc != 2) {
31 ::std::cout << "Must provide a filename for output as an argument\n";
32 return 1;
33 }
34 ::y2019::vision::DumpTypescriptConstants(argv[1]);
35}