blob: c673aecf64f669e05359f1b39ad0cee121330125 [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
Stephan Pleinesf63bde82024-01-13 15:59:33 -08007namespace y2019::vision {
James Kuszmaul92ba0e52019-03-29 17:19:30 -07008void DumpPose(std::basic_ostream<char> *o, const vision::CameraGeometry &pose) {
9 *o << "{x: " << pose.location[0] << ", y: " << pose.location[1]
Philipp Schrader790cb542023-07-05 21:06:52 -070010 << ", theta: " << pose.heading << "}";
James Kuszmaul92ba0e52019-03-29 17:19:30 -070011}
12void 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 Kuszmauld6d37d12019-03-30 13:04:54 -070017 // TODO(james): Decide how to manage visualization for practice and code
18 // bots.
James Kuszmaul92ba0e52019-03-29 17:19:30 -070019 DumpPose(&out_file,
20 GetCamera(CameraSerialNumbers(CompBotTeensyId())[ii])->geometry);
21 out_file << ",\n";
22 }
23 out_file << "];\n";
24}
Stephan Pleinesf63bde82024-01-13 15:59:33 -080025} // namespace y2019::vision
James Kuszmaul92ba0e52019-03-29 17:19:30 -070026
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}