Swap y2023 wrist over to the constants.json
There are a couple of awkward constants that show up in json_codegen.cc
as still being managed from the C++ end; there are also a couple of
codegen'd constants from the wrist python code that we use in
constants.h. However, this does move *all* of the per-robot
configuration into the constants JSON file and should allow us to remove
the superstructure's dependency on the constants.h (if the arm were also
converted over).
Change-Id: Id9fc1e80830af823d96e5f3c1e469495eba454a4
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/y2023/constants/json_codegen.cc b/y2023/constants/json_codegen.cc
new file mode 100644
index 0000000..fc08df1
--- /dev/null
+++ b/y2023/constants/json_codegen.cc
@@ -0,0 +1,25 @@
+#include "aos/util/file.h"
+#include "y2023/constants.h"
+
+using namespace y2023::constants;
+
+// This file generates some JSON constants information that is currently
+// dependent on values that are located in C++ headers and would be
+// obnoxious/inappropriate to pull out.
+int main(int argc, char *argv[]) {
+ CHECK_EQ(argc, 2) << "Must supply file name to output to.";
+ std::string output_file = argv[1];
+
+ std::stringstream output;
+
+ output << "\"average_filter_size\": " << Values::kZeroingSampleSize << ",\n";
+ output << "\"one_revolution_distance\": "
+ << M_PI * 2.0 * Values::kCompWristEncoderRatio() << ",\n";
+ output << "\"zeroing_threshold\": 0.0005,\n";
+ output << "\"moving_buffer_size\": 20,\n";
+ output << "\"allowable_encoder_error\": 0.9,\n";
+ output << "\"middle_position\": " << Values::kCompWristRange().middle()
+ << "\n";
+ aos::util::WriteStringToFileOrDie(output_file, output.str());
+ return 0;
+}