Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 1 | include "frc971/control_loops/control_loops.fbs"; |
Maxwell Henderson | bf1bcec | 2023-03-05 18:00:20 -0800 | [diff] [blame^] | 2 | include "y2023/vision/game_pieces.fbs"; |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 3 | include "frc971/control_loops/profiled_subsystem.fbs"; |
| 4 | |
| 5 | namespace y2023.control_loops.superstructure; |
| 6 | |
milind-u | 3738518 | 2023-02-20 15:07:28 -0800 | [diff] [blame] | 7 | enum ArmState : ubyte { |
| 8 | UNINITIALIZED = 0, |
| 9 | ZEROING = 1, |
| 10 | DISABLED = 2, |
| 11 | GOTO_PATH = 3, |
| 12 | RUNNING = 4, |
| 13 | ESTOP = 5, |
| 14 | } |
| 15 | |
| 16 | table ArmStatus { |
| 17 | // State of the estimators. |
| 18 | proximal_estimator_state:frc971.PotAndAbsoluteEncoderEstimatorState (id: 0); |
| 19 | distal_estimator_state:frc971.PotAndAbsoluteEncoderEstimatorState (id: 1); |
milind-u | 18a901d | 2023-02-17 21:51:55 -0800 | [diff] [blame] | 20 | roll_joint_estimator_state:frc971.PotAndAbsoluteEncoderEstimatorState (id: 18); |
milind-u | 3738518 | 2023-02-20 15:07:28 -0800 | [diff] [blame] | 21 | |
| 22 | // The node we are currently going to. |
| 23 | current_node:uint32 (id: 2); |
| 24 | // Distance (in radians) to the end of the path. |
| 25 | path_distance_to_go:float (id: 3); |
| 26 | // Goal position and velocity (radians) |
| 27 | goal_theta0:float (id: 4); |
| 28 | goal_theta1:float (id: 5); |
milind-u | 18a901d | 2023-02-17 21:51:55 -0800 | [diff] [blame] | 29 | goal_theta2:float (id: 19); |
milind-u | 3738518 | 2023-02-20 15:07:28 -0800 | [diff] [blame] | 30 | goal_omega0:float (id: 6); |
| 31 | goal_omega1:float (id: 7); |
milind-u | 18a901d | 2023-02-17 21:51:55 -0800 | [diff] [blame] | 32 | goal_omega2:float (id: 20); |
milind-u | 3738518 | 2023-02-20 15:07:28 -0800 | [diff] [blame] | 33 | |
| 34 | // Current position and velocity (radians) |
| 35 | theta0:float (id: 8); |
| 36 | theta1:float (id: 9); |
milind-u | 18a901d | 2023-02-17 21:51:55 -0800 | [diff] [blame] | 37 | theta2:float (id: 21); |
milind-u | 3738518 | 2023-02-20 15:07:28 -0800 | [diff] [blame] | 38 | |
| 39 | omega0:float (id: 10); |
| 40 | omega1:float (id: 11); |
milind-u | 18a901d | 2023-02-17 21:51:55 -0800 | [diff] [blame] | 41 | omega2:float (id: 22); |
milind-u | 3738518 | 2023-02-20 15:07:28 -0800 | [diff] [blame] | 42 | |
| 43 | // Estimated voltage error for the two joints. |
| 44 | voltage_error0:float (id: 12); |
| 45 | voltage_error1:float (id: 13); |
milind-u | 18a901d | 2023-02-17 21:51:55 -0800 | [diff] [blame] | 46 | voltage_error2:float (id: 23); |
milind-u | 3738518 | 2023-02-20 15:07:28 -0800 | [diff] [blame] | 47 | |
milind-u | 3b91b75 | 2023-02-25 15:21:06 -0800 | [diff] [blame] | 48 | // Current arm position in meters for use with UI |
| 49 | arm_x:float (id: 24); |
| 50 | arm_y:float (id: 25); |
| 51 | // Circular index to handle theta wrapping |
| 52 | arm_circular_index:int (id: 26); |
| 53 | |
milind-u | 3738518 | 2023-02-20 15:07:28 -0800 | [diff] [blame] | 54 | // True if we are zeroed. |
| 55 | zeroed:bool (id: 14); |
| 56 | |
| 57 | // True if the arm is zeroed. |
| 58 | estopped:bool (id: 15); |
| 59 | |
| 60 | // The current state machine state. |
| 61 | state:ArmState (id: 16); |
| 62 | |
| 63 | // The number of times the LQR solver failed. |
| 64 | failed_solutions:uint32 (id: 17); |
| 65 | } |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 66 | |
Maxwell Henderson | 589cf27 | 2023-02-22 15:56:40 -0800 | [diff] [blame] | 67 | // State of the superstructure state machine |
| 68 | enum EndEffectorState : ubyte { |
| 69 | // Not doing anything |
| 70 | IDLE = 0, |
| 71 | // Intaking the game object into the end effector |
| 72 | INTAKING = 1, |
| 73 | // The game object is loaded into the end effector |
| 74 | LOADED = 2, |
| 75 | // Waiting for the arm to be at shooting goal and then telling the |
| 76 | // end effector to spit |
| 77 | SPITTING = 3, |
| 78 | } |
| 79 | |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 80 | table Status { |
| 81 | // All subsystems know their location. |
| 82 | zeroed:bool (id: 0); |
| 83 | |
| 84 | // If true, we have aborted. This is the or of all subsystem estops. |
| 85 | estopped:bool (id: 1); |
Nikita Narang | 27610fc | 2023-02-08 19:40:31 -0800 | [diff] [blame] | 86 | |
milind-u | 3738518 | 2023-02-20 15:07:28 -0800 | [diff] [blame] | 87 | arm:ArmStatus (id: 2); |
Nikita Narang | 27610fc | 2023-02-08 19:40:31 -0800 | [diff] [blame] | 88 | |
milind-u | 18a901d | 2023-02-17 21:51:55 -0800 | [diff] [blame] | 89 | wrist:frc971.control_loops.AbsoluteEncoderProfiledJointStatus (id: 3); |
Maxwell Henderson | 589cf27 | 2023-02-22 15:56:40 -0800 | [diff] [blame] | 90 | |
| 91 | end_effector_state:EndEffectorState (id: 4); |
Maxwell Henderson | bf1bcec | 2023-03-05 18:00:20 -0800 | [diff] [blame^] | 92 | game_piece:vision.Class (id: 5); |
Maxwell Henderson | ad31234 | 2023-01-10 12:07:47 -0800 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | root_type Status; |