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