incorporate arm into superstructure.cc by adding arm constants

Change-Id: Icfd6ba91044b7a8f29f10edf8c4c44ae1a443d2c
Signed-off-by: Yash Maheshwari <yashmahe2018@gmail.com>
Signed-off-by: James (Peilun) Li <jamespeilunli@gmail.com>
diff --git a/y2024_bot3/constants/9971.json b/y2024_bot3/constants/9971.json
index 5583b44..4eb1acf 100644
--- a/y2024_bot3/constants/9971.json
+++ b/y2024_bot3/constants/9971.json
@@ -1,3 +1,5 @@
+{% from 'y2024_bot3/constants/common.jinja2' import arm_zero %}
+
 {
   "cameras": [
     {
@@ -13,6 +15,21 @@
       "calibration": {% include 'y2024_bot3/constants/calib_files/calibration_orin1-9971-1_cam-24-11_2024-03-24_11-52-49.json' %}
     }
   ],
-  "robot": {},
+  "robot": {
+    "arm_constants": {
+      {% set _ = arm_zero.update(
+          {
+              "measured_absolute_position" : 0.0992895926495078
+          }
+      ) %}
+      "zeroing_constants": {{ arm_zero | tojson(indent=2)}},
+      "potentiometer_offset": {{ 0 }},
+      "arm_positions": {
+        "intake": 0,
+        "idle": 1,
+        "amp": 2
+      }
+    }
+  },
   {% include 'y2024_bot3/constants/common.json' %}
 }
diff --git a/y2024_bot3/constants/BUILD b/y2024_bot3/constants/BUILD
index 1ce69a0..323bd49 100644
--- a/y2024_bot3/constants/BUILD
+++ b/y2024_bot3/constants/BUILD
@@ -26,6 +26,7 @@
         "common.jinja2",
         "common.json",
         "//y2024_bot3/constants/calib_files",
+        "//y2024_bot3/control_loops/superstructure/arm:arm_json",
         "//y2024_bot3/vision/maps",
     ],
     parameters = {},
@@ -40,6 +41,7 @@
         "common.jinja2",
         "common.json",
         "//y2024_bot3/constants/calib_files",
+        "//y2024_bot3/control_loops/superstructure/arm:arm_json",
         "//y2024_bot3/vision/maps",
     ],
     parameters = {},
diff --git a/y2024_bot3/constants/common.jinja2 b/y2024_bot3/constants/common.jinja2
index 9b7af82..809f8c8 100644
--- a/y2024_bot3/constants/common.jinja2
+++ b/y2024_bot3/constants/common.jinja2
@@ -1,3 +1,16 @@
 {% set pi = 3.14159265 %}
 
 {%set zeroing_sample_size = 200 %}
+
+{# Arm #}
+{% set arm_encoder_ratio = (4.0 / 1.0) %}
+
+{%
+set arm_zero = {
+    "average_filter_size": zeroing_sample_size,
+    "one_revolution_distance": pi * 2.0 * arm_encoder_ratio,
+    "zeroing_threshold": 0.0005,
+    "moving_buffer_size": 20,
+    "allowable_encoder_error": 0.9
+}
+%}
diff --git a/y2024_bot3/constants/common.json b/y2024_bot3/constants/common.json
index e7b70b4..d5abec0 100644
--- a/y2024_bot3/constants/common.json
+++ b/y2024_bot3/constants/common.json
@@ -1,2 +1,21 @@
 "common": {
+  "arm": {
+    "zeroing_voltage": 3.0,
+    "operating_voltage": 12.0,
+    "zeroing_profile_params": {
+      "max_velocity": 0.5,
+      "max_acceleration": 3.0
+    },
+    "default_profile_params":{
+      "max_velocity": 2.0,
+      "max_acceleration": 10.0
+    },
+    "range": {
+        "lower_hard": -50,
+        "upper_hard": 50,
+        "lower": -50,
+        "upper": 50
+    },
+    "loop": {% include 'y2024_bot3/control_loops/superstructure/arm/integral_arm_plant.json' %}
+  }
 }
diff --git a/y2024_bot3/constants/constants.fbs b/y2024_bot3/constants/constants.fbs
index 0c7a792..99999bd 100644
--- a/y2024_bot3/constants/constants.fbs
+++ b/y2024_bot3/constants/constants.fbs
@@ -10,12 +10,26 @@
   calibration:frc971.vision.calibration.CameraCalibration (id: 0);
 }
 
+table ArmPositions {
+  intake:double (id: 0);
+  idle:double (id: 1);
+  amp:double (id: 2);
+}
+
+table PotAndAbsEncoderConstants {
+  zeroing_constants:frc971.zeroing.PotAndAbsoluteEncoderZeroingConstants (id: 0);
+  potentiometer_offset:double (id: 1);
+  arm_positions:ArmPositions (id: 2);
+}
+
 table RobotConstants {
+  arm_constants:PotAndAbsEncoderConstants (id: 0);
 }
 
 // Common table for constants unrelated to the robot
 table Common {
   target_map:frc971.vision.TargetMap (id: 0);
+  arm:frc971.control_loops.StaticZeroingSingleDOFProfiledSubsystemCommonParams (id: 1);
 }
 
 table Constants {
diff --git a/y2024_bot3/constants/test_data/test_team.json b/y2024_bot3/constants/test_data/test_team.json
index deacef4..06286e7 100644
--- a/y2024_bot3/constants/test_data/test_team.json
+++ b/y2024_bot3/constants/test_data/test_team.json
@@ -1,4 +1,21 @@
+{% from 'y2024_bot3/constants/common.jinja2' import arm_zero %}
+
 {
-  "robot": {},
+  "robot": {
+    "arm_constants": {
+      {% set _ = arm_zero.update(
+          {
+              "measured_absolute_position" : 0.0992895926495078
+          }
+      ) %}
+      "zeroing_constants": {{ arm_zero | tojson(indent=2)}},
+      "potentiometer_offset": {{ 0 }},
+      "arm_positions": {
+        "intake": 0,
+        "idle": 1,
+        "amp": 2
+      }
+    }
+  },
   {% include 'y2024_bot3/constants/common.json' %}
 }