Add Extend Flatbuffers

Signed-off-by: Mirabel Wang <mirabel.17.wang@gmail.com>
Signed-off-by: Filip Kujawa <filip.j.kujawa@gmail.com>
Change-Id: I71c60a7d3e0018c6669f46d1d14e401e569dc61c
diff --git a/y2024/control_loops/superstructure/superstructure.cc b/y2024/control_loops/superstructure/superstructure.cc
index 1d7c5b5..43a2453 100644
--- a/y2024/control_loops/superstructure/superstructure.cc
+++ b/y2024/control_loops/superstructure/superstructure.cc
@@ -66,7 +66,7 @@
         robot_constants_->common()->intake_pivot_set_points()->extended();
   }
 
-  IntakeRollerState intake_roller_state = IntakeRollerState::NONE;
+  IntakeRollerStatus intake_roller_state = IntakeRollerStatus::NONE;
 
   switch (unsafe_goal != nullptr ? unsafe_goal->intake_roller_goal()
                                  : IntakeRollerGoal::NONE) {
@@ -75,19 +75,19 @@
       break;
     case IntakeRollerGoal::SPIT:
       transfer_goal_ = TransferRollerGoal::TRANSFER_OUT;
-      intake_roller_state = IntakeRollerState::SPITTING;
+      intake_roller_state = IntakeRollerStatus::SPITTING;
       output_struct.intake_roller_voltage =
           robot_constants_->common()->intake_roller_voltages()->spitting();
       break;
     case IntakeRollerGoal::INTAKE:
       transfer_goal_ = TransferRollerGoal::TRANSFER_IN;
-      intake_roller_state = IntakeRollerState::INTAKING;
+      intake_roller_state = IntakeRollerStatus::INTAKING;
       output_struct.intake_roller_voltage =
           robot_constants_->common()->intake_roller_voltages()->intaking();
       break;
   }
 
-  TransferRollerState transfer_roller_state = TransferRollerState::NONE;
+  TransferRollerStatus transfer_roller_state = TransferRollerStatus::NONE;
 
   switch (unsafe_goal != nullptr ? transfer_goal_ : TransferRollerGoal::NONE) {
     case TransferRollerGoal::NONE:
@@ -96,16 +96,16 @@
     case TransferRollerGoal::TRANSFER_IN:
       if (position->transfer_beambreak()) {
         transfer_goal_ = TransferRollerGoal::NONE;
-        transfer_roller_state = TransferRollerState::NONE;
+        transfer_roller_state = TransferRollerStatus::NONE;
         output_struct.transfer_roller_voltage = 0.0;
         break;
       }
-      transfer_roller_state = TransferRollerState::TRANSFERING_IN;
+      transfer_roller_state = TransferRollerStatus::TRANSFERING_IN;
       output_struct.transfer_roller_voltage =
           robot_constants_->common()->transfer_roller_voltages()->transfer_in();
       break;
     case TransferRollerGoal::TRANSFER_OUT:
-      transfer_roller_state = TransferRollerState::TRANSFERING_OUT;
+      transfer_roller_state = TransferRollerStatus::TRANSFERING_OUT;
       output_struct.transfer_roller_voltage = robot_constants_->common()
                                                   ->transfer_roller_voltages()
                                                   ->transfer_out();
@@ -186,10 +186,10 @@
 
   status_builder.add_zeroed(zeroed);
   status_builder.add_estopped(estopped);
-  status_builder.add_intake_roller_state(intake_roller_state);
-  status_builder.add_intake_pivot_state(intake_pivot_status_offset);
-  status_builder.add_transfer_roller_state(transfer_roller_state);
-  status_builder.add_climber_state(climber_status_offset);
+  status_builder.add_intake_roller(intake_roller_state);
+  status_builder.add_intake_pivot(intake_pivot_status_offset);
+  status_builder.add_transfer_roller(transfer_roller_state);
+  status_builder.add_climber(climber_status_offset);
 
   (void)status->Send(status_builder.Finish());
 }
diff --git a/y2024/control_loops/superstructure/superstructure_can_position.fbs b/y2024/control_loops/superstructure/superstructure_can_position.fbs
index 0f751ab..efe0db2 100644
--- a/y2024/control_loops/superstructure/superstructure_can_position.fbs
+++ b/y2024/control_loops/superstructure/superstructure_can_position.fbs
@@ -32,6 +32,12 @@
 
     // CAN Position of the shooter altitude falcon
     altitude:frc971.control_loops.CANTalonFX (id: 8);
+
+    // CAN Position of the extend falcon
+    extend:frc971.control_loops.CANTalonFX (id: 9);
+
+    // CAN Position of the extend roller fancon
+    extend_roller:frc971.control_loops.CANTalonFX (id: 10);
 }
 
 root_type CANPosition;
diff --git a/y2024/control_loops/superstructure/superstructure_goal.fbs b/y2024/control_loops/superstructure/superstructure_goal.fbs
index 6ec954f..4d46d1e 100644
--- a/y2024/control_loops/superstructure/superstructure_goal.fbs
+++ b/y2024/control_loops/superstructure/superstructure_goal.fbs
@@ -48,6 +48,23 @@
     altitude_position: frc971.control_loops.StaticZeroingSingleDOFProfiledSubsystemGoal (id: 4);
 }
 
+// Represents goal for extend
+// RETRACT is for retracting the extender to stowed position
+// In the retracted position, the game piece may be transfered to the catapult
+// AMP is for extending the extender to the AMP scoring position
+// TRAP is for extending the extender to the TRAP scoring position
+enum ExtendGoal : ubyte {
+    RETRACT = 0,
+    AMP = 1,
+    TRAP = 2,
+}
+
+enum ExtendRollerGoal : ubyte {
+    NONE = 0,
+    SCORING = 1,
+    REVERSING = 2,
+}
+
 table Goal {
     intake_roller_goal:IntakeRollerGoal (id: 0);
     intake_pivot_goal:IntakePivotGoal (id: 1);
@@ -55,5 +72,7 @@
     transfer_roller_goal:TransferRollerGoal (id: 3);
     climber_goal:ClimberGoal (id: 4);
     shooter_goal:ShooterGoal (id: 5);
+    extend_goal:ExtendGoal (id: 6);
+    extend_roller_goal:ExtendRollerGoal (id: 7);
 }
 root_type Goal;
diff --git a/y2024/control_loops/superstructure/superstructure_lib_test.cc b/y2024/control_loops/superstructure/superstructure_lib_test.cc
index 8e719d4..78bbbdd 100644
--- a/y2024/control_loops/superstructure/superstructure_lib_test.cc
+++ b/y2024/control_loops/superstructure/superstructure_lib_test.cc
@@ -109,10 +109,10 @@
 
             intake_pivot_.Simulate(
                 superstructure_output_fetcher_->intake_pivot_voltage(),
-                superstructure_status_fetcher_->intake_pivot_state());
+                superstructure_status_fetcher_->intake_pivot());
 
             climber_.Simulate(superstructure_output_fetcher_->climber_voltage(),
-                              superstructure_status_fetcher_->climber_state());
+                              superstructure_status_fetcher_->climber());
           }
           first_ = false;
           SendPositionMessage();
@@ -240,13 +240,12 @@
                       ->extended();
     }
 
-    EXPECT_NEAR(
-        set_point,
-        superstructure_status_fetcher_->intake_pivot_state()->position(),
-        0.001);
+    EXPECT_NEAR(set_point,
+                superstructure_status_fetcher_->intake_pivot()->position(),
+                0.001);
 
-    if (superstructure_status_fetcher_->intake_roller_state() ==
-        IntakeRollerState::NONE) {
+    if (superstructure_status_fetcher_->intake_roller() ==
+        IntakeRollerStatus::NONE) {
       EXPECT_EQ(superstructure_output_fetcher_->intake_roller_voltage(), 0.0);
     }
 
@@ -267,8 +266,7 @@
       }
 
       EXPECT_NEAR(set_point,
-                  superstructure_status_fetcher_->climber_state()->position(),
-                  0.001);
+                  superstructure_status_fetcher_->climber()->position(), 0.001);
     }
   }
 
diff --git a/y2024/control_loops/superstructure/superstructure_output.fbs b/y2024/control_loops/superstructure/superstructure_output.fbs
index ddfc5ac..db756b4 100644
--- a/y2024/control_loops/superstructure/superstructure_output.fbs
+++ b/y2024/control_loops/superstructure/superstructure_output.fbs
@@ -29,6 +29,16 @@
     // Voltage of the retention rollers
     // Positive voltage will hold the game piece in the catapult.
     retention_roller_voltage: double (id: 7);
+
+    // Voltage of extend
+    // Positive voltage extends the extend
+    // Negative voltage retracts the extend
+    extend_voltage:double (id: 8);
+
+    // Voltage of the extend rollers
+    // Positive voltage rolls the game piece up towards the scoring mechanisms,
+    // either the catapult or amp/trap mechanism
+    extend_roller_voltage:double (id: 9);
 }
 
 root_type Output;
diff --git a/y2024/control_loops/superstructure/superstructure_position.fbs b/y2024/control_loops/superstructure/superstructure_position.fbs
index 8d2b7ca..7ab49a3 100644
--- a/y2024/control_loops/superstructure/superstructure_position.fbs
+++ b/y2024/control_loops/superstructure/superstructure_position.fbs
@@ -25,6 +25,13 @@
 
     // True if there is a game piece in the catapult
     catapult_beam_break:bool (id: 6);
+
+    // Values of the encoder and potentiometer at the extend motor
+    // Zero is fully retracted, positive is extended outward.
+    extend:frc971.PotAndAbsolutePosition (id: 7);
+
+    // True means there is a game piece in the extend.
+    extend_beambreak:bool (id: 8);
 }
 
 root_type Position;
diff --git a/y2024/control_loops/superstructure/superstructure_status.fbs b/y2024/control_loops/superstructure/superstructure_status.fbs
index ceed417..bda9bbf 100644
--- a/y2024/control_loops/superstructure/superstructure_status.fbs
+++ b/y2024/control_loops/superstructure/superstructure_status.fbs
@@ -4,7 +4,7 @@
 namespace y2024.control_loops.superstructure;
 
 // Contains if intake is intaking
-enum IntakeRollerState : ubyte {
+enum IntakeRollerStatus : ubyte {
   NONE = 0,
   SPITTING = 1,
   INTAKING = 2,
@@ -21,24 +21,32 @@
 
 table ShooterStatus {
   // Estimated angle and angular velocitiy of the turret.
-  turret_state:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 0);
+  turret:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 0);
 
   // Estimated angle and angular velocitiy of the catapult.
-  catapult_state:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 1);
+  catapult:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 1);
 
   // Estimated angle and angular velocitiy of the altitude.
-  altitude_state:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 2);
+  altitude:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 2);
 
-  catapult_status: CatapultStatus (id: 3);
+  catapult_state: CatapultStatus (id: 3);
 }
 
 // Contains status of transfer rollers
-enum TransferRollerState : ubyte {
+enum TransferRollerStatus : ubyte {
     NONE = 0,
     TRANSFERING_IN = 1,
     TRANSFERING_OUT = 2,
 }
 
+// Contains status of extend rollers
+// HAS_GAME_PIECE means we have a game piece
+// EMPTY means we don't have a game piece
+enum ExtendRollerStatus: ubyte {
+  HAS_GAME_PIECE = 0,
+  EMPTY = 1
+}
+
 table Status {
   // All subsystems know their location.
   zeroed:bool (id: 0);
@@ -46,20 +54,26 @@
   // If true, we have aborted. This is the or of all subsystem estops.
   estopped:bool (id: 1);
 
-  // State of the rollers
-  intake_roller_state:IntakeRollerState (id: 2);
+  // Status of the rollers
+  intake_roller:IntakeRollerStatus (id: 2);
 
   // Estimated angle and angular velocitiy of the intake.
-  intake_pivot_state:frc971.control_loops.AbsoluteEncoderProfiledJointStatus (id: 3);
+  intake_pivot:frc971.control_loops.AbsoluteEncoderProfiledJointStatus (id: 3);
 
-  // State of transfer rollers
-  transfer_roller_state:TransferRollerState (id: 4);
+  // Status of transfer rollers
+  transfer_roller:TransferRollerStatus (id: 4);
 
   // Estimated angle and angular velocitiy of the climber.
-  climber_state:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 5);
+  climber:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 5);
 
   // Status of the subsytems involved in the shooter
-  shooter_status:ShooterStatus (id: 6);
+  shooter:ShooterStatus (id: 6);
+
+  // Estimated angle and angular velocitiy of the extend.
+  extend:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 7);
+
+  // State of the extender rollers
+  extend_roller:ExtendRollerStatus (id: 8);
 }
 
 root_type Status;