Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 1 | include "frc971/control_loops/control_loops.fbs"; |
| 2 | include "frc971/control_loops/profiled_subsystem.fbs"; |
| 3 | |
| 4 | namespace y2024.control_loops.superstructure; |
| 5 | |
Filip Kujawa | 7a79960 | 2024-02-23 12:27:47 -0800 | [diff] [blame] | 6 | enum SuperstructureState : ubyte { |
| 7 | // Before a note has been intaked, the extend should be retracted. |
| 8 | IDLE = 0, |
James Kuszmaul | 0281e15 | 2024-02-26 22:26:16 -0800 | [diff] [blame] | 9 | // Intaking a note and transferring it to the extned through the |
Filip Kujawa | 7a79960 | 2024-02-23 12:27:47 -0800 | [diff] [blame] | 10 | // intake, transfer, and extend rollers. |
| 11 | INTAKING = 1, |
| 12 | // The note is in the extend and the extend is not moving. |
| 13 | LOADED = 2, |
James Kuszmaul | 0281e15 | 2024-02-26 22:26:16 -0800 | [diff] [blame] | 14 | // The note is in the extend and the extend is moving towards a goal, |
Filip Kujawa | 7a79960 | 2024-02-23 12:27:47 -0800 | [diff] [blame] | 15 | // either the catapult, amp, or trap. |
| 16 | MOVING = 3, |
| 17 | // For Catapult Path, the note is being transferred between the extend and the catapult. |
| 18 | LOADING_CATAPULT = 4, |
| 19 | // The note is either: |
| 20 | // 1. Loaded in the catapult and ready to fire |
| 21 | // 2. In the extend and the extend is at the amp or trap scoring position. |
| 22 | READY = 5, |
| 23 | // Fire goal recieved and the note is being fired from the catapult or being scored in the amp or trap. |
| 24 | FIRING = 6, |
| 25 | } |
| 26 | |
Niko Sohmers | 58e64c8 | 2024-01-14 12:49:54 -0800 | [diff] [blame] | 27 | // Contains if intake is intaking |
Filip Kujawa | 102a9b2 | 2024-02-18 09:40:23 -0800 | [diff] [blame] | 28 | enum IntakeRollerStatus : ubyte { |
Niko Sohmers | 58e64c8 | 2024-01-14 12:49:54 -0800 | [diff] [blame] | 29 | NONE = 0, |
| 30 | SPITTING = 1, |
| 31 | INTAKING = 2, |
| 32 | } |
| 33 | |
Niko Sohmers | c4d2c50 | 2024-02-19 19:35:35 -0800 | [diff] [blame] | 34 | enum CatapultState: ubyte { |
Maxwell Henderson | ed97029 | 2024-02-02 20:08:08 -0800 | [diff] [blame] | 35 | // Means we are waiting for a game piece |
Niko Sohmers | c4d2c50 | 2024-02-19 19:35:35 -0800 | [diff] [blame] | 36 | READY = 0, |
Maxwell Henderson | ed97029 | 2024-02-02 20:08:08 -0800 | [diff] [blame] | 37 | // Means we have a game piece |
| 38 | LOADED = 1, |
| 39 | // Means we are firing a game piece |
| 40 | FIRING = 2, |
Niko Sohmers | c4d2c50 | 2024-02-19 19:35:35 -0800 | [diff] [blame] | 41 | // We are retracting the bucket to do it again. |
| 42 | RETRACTING = 3, |
| 43 | } |
| 44 | |
| 45 | table AimerStatus { |
| 46 | // The current goal angle for the turret auto-tracking, in radians. |
| 47 | turret_position:double (id: 0); |
| 48 | // The current goal velocity for the turret, in radians / sec. |
| 49 | turret_velocity:double (id: 1); |
| 50 | // The current distance to the target, in meters. |
| 51 | target_distance:double (id: 2); |
| 52 | // The current "shot distance." When shooting on the fly, this may be |
| 53 | // different from the static distance to the target. |
| 54 | shot_distance:double (id: 3); |
Maxwell Henderson | ed97029 | 2024-02-02 20:08:08 -0800 | [diff] [blame] | 55 | } |
| 56 | |
Niko Sohmers | 5006fc4 | 2024-03-01 17:14:22 -0800 | [diff] [blame] | 57 | // Enum representing where the superstructure |
| 58 | // is currently trying to send the note. |
| 59 | enum NoteStatus : ubyte { |
| 60 | NONE = 0, |
| 61 | CATAPULT = 1, |
| 62 | AMP = 2, |
| 63 | TRAP = 3, |
| 64 | } |
| 65 | |
Maxwell Henderson | bf04fb6 | 2024-01-19 17:56:07 -0800 | [diff] [blame] | 66 | table ShooterStatus { |
| 67 | // Estimated angle and angular velocitiy of the turret. |
Filip Kujawa | 102a9b2 | 2024-02-18 09:40:23 -0800 | [diff] [blame] | 68 | turret:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 0); |
Maxwell Henderson | bf04fb6 | 2024-01-19 17:56:07 -0800 | [diff] [blame] | 69 | |
| 70 | // Estimated angle and angular velocitiy of the catapult. |
Filip Kujawa | 102a9b2 | 2024-02-18 09:40:23 -0800 | [diff] [blame] | 71 | catapult:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 1); |
Maxwell Henderson | bf04fb6 | 2024-01-19 17:56:07 -0800 | [diff] [blame] | 72 | |
| 73 | // Estimated angle and angular velocitiy of the altitude. |
Filip Kujawa | 102a9b2 | 2024-02-18 09:40:23 -0800 | [diff] [blame] | 74 | altitude:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 2); |
Maxwell Henderson | ed97029 | 2024-02-02 20:08:08 -0800 | [diff] [blame] | 75 | |
Niko Sohmers | c4d2c50 | 2024-02-19 19:35:35 -0800 | [diff] [blame] | 76 | catapult_state: CatapultState (id: 3); |
| 77 | |
| 78 | // Status of the aimer |
| 79 | aimer:AimerStatus (id: 4); |
Niko Sohmers | cc3aa45 | 2024-03-03 17:20:04 -0800 | [diff] [blame] | 80 | |
James Kuszmaul | df3a3cb | 2024-03-15 22:03:37 -0700 | [diff] [blame] | 81 | // True if auto-aiming. |
| 82 | auto_aiming:bool (id: 5); |
| 83 | |
| 84 | turret_in_range:bool (id: 6); |
| 85 | altitude_in_range:bool (id: 7); |
| 86 | altitude_above_min_angle:bool (id: 8); |
Maxwell Henderson | bf04fb6 | 2024-01-19 17:56:07 -0800 | [diff] [blame] | 87 | } |
| 88 | |
Niko Sohmers | 78f7135 | 2024-02-02 16:47:40 -0800 | [diff] [blame] | 89 | // Contains status of transfer rollers |
Filip Kujawa | 102a9b2 | 2024-02-18 09:40:23 -0800 | [diff] [blame] | 90 | enum TransferRollerStatus : ubyte { |
Niko Sohmers | 78f7135 | 2024-02-02 16:47:40 -0800 | [diff] [blame] | 91 | NONE = 0, |
| 92 | TRANSFERING_IN = 1, |
| 93 | TRANSFERING_OUT = 2, |
James Kuszmaul | 6cae7d7 | 2024-03-01 21:29:56 -0800 | [diff] [blame] | 94 | EXTEND_MOVING = 3, |
Niko Sohmers | 78f7135 | 2024-02-02 16:47:40 -0800 | [diff] [blame] | 95 | } |
| 96 | |
Filip Kujawa | 102a9b2 | 2024-02-18 09:40:23 -0800 | [diff] [blame] | 97 | // Contains status of extend rollers |
Filip Kujawa | 102a9b2 | 2024-02-18 09:40:23 -0800 | [diff] [blame] | 98 | enum ExtendRollerStatus: ubyte { |
Filip Kujawa | 7a79960 | 2024-02-23 12:27:47 -0800 | [diff] [blame] | 99 | // Means the rollers are not moving. |
| 100 | IDLE = 0, |
| 101 | // Means we're transfer from the transfer rollers into the extend rollers. |
| 102 | TRANSFERING_TO_EXTEND = 1, |
| 103 | // Means we are transfering from the extend to the catapult. |
| 104 | TRANSFERING_TO_CATAPULT = 2, |
| 105 | // Means we're trying to score in the amp/trap |
| 106 | SCORING_IN_AMP = 3, |
| 107 | SCORING_IN_TRAP = 4, |
| 108 | } |
| 109 | |
| 110 | // Contains the status of the extend subsystem |
| 111 | enum ExtendStatus : ubyte { |
| 112 | // Means we are near 0 and ready to transfer a game piece. |
| 113 | RETRACTED = 0, |
| 114 | // Means we are moving to some goal. |
| 115 | MOVING = 1, |
| 116 | // Means we are currently at the catapult. |
| 117 | CATAPULT = 2, |
| 118 | // Means we are at the amp position. |
| 119 | AMP = 3, |
| 120 | // Means we are at the trap positon. |
| 121 | TRAP = 4, |
Filip Kujawa | 102a9b2 | 2024-02-18 09:40:23 -0800 | [diff] [blame] | 122 | } |
| 123 | |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 124 | table Status { |
| 125 | // All subsystems know their location. |
| 126 | zeroed:bool (id: 0); |
| 127 | |
| 128 | // If true, we have aborted. This is the or of all subsystem estops. |
| 129 | estopped:bool (id: 1); |
Niko Sohmers | 58e64c8 | 2024-01-14 12:49:54 -0800 | [diff] [blame] | 130 | |
Filip Kujawa | 7a79960 | 2024-02-23 12:27:47 -0800 | [diff] [blame] | 131 | state : SuperstructureState (id: 2); |
| 132 | |
Filip Kujawa | 102a9b2 | 2024-02-18 09:40:23 -0800 | [diff] [blame] | 133 | // Status of the rollers |
Filip Kujawa | 7a79960 | 2024-02-23 12:27:47 -0800 | [diff] [blame] | 134 | intake_roller:IntakeRollerStatus (id: 3); |
Niko Sohmers | 58e64c8 | 2024-01-14 12:49:54 -0800 | [diff] [blame] | 135 | |
| 136 | // Estimated angle and angular velocitiy of the intake. |
Filip Kujawa | 7a79960 | 2024-02-23 12:27:47 -0800 | [diff] [blame] | 137 | intake_pivot:frc971.control_loops.AbsoluteEncoderProfiledJointStatus (id: 4); |
Niko Sohmers | 78f7135 | 2024-02-02 16:47:40 -0800 | [diff] [blame] | 138 | |
Filip Kujawa | 102a9b2 | 2024-02-18 09:40:23 -0800 | [diff] [blame] | 139 | // Status of transfer rollers |
Filip Kujawa | 7a79960 | 2024-02-23 12:27:47 -0800 | [diff] [blame] | 140 | transfer_roller:TransferRollerStatus (id: 5); |
Filip Kujawa | 5750715 | 2024-01-31 20:09:25 -0800 | [diff] [blame] | 141 | |
| 142 | // Estimated angle and angular velocitiy of the climber. |
Niko Sohmers | 4d93d4c | 2024-03-24 14:48:26 -0700 | [diff] [blame] | 143 | // Deprecated now because climber no longer has an encoder |
| 144 | // and climber status is not used |
| 145 | climber:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 6, deprecated); |
Niko Sohmers | 1101711 | 2024-02-18 16:03:58 -0800 | [diff] [blame] | 146 | |
| 147 | // Status of the subsytems involved in the shooter |
Filip Kujawa | 7a79960 | 2024-02-23 12:27:47 -0800 | [diff] [blame] | 148 | shooter:ShooterStatus (id: 7); |
Filip Kujawa | 102a9b2 | 2024-02-18 09:40:23 -0800 | [diff] [blame] | 149 | |
| 150 | // Estimated angle and angular velocitiy of the extend. |
Filip Kujawa | 7a79960 | 2024-02-23 12:27:47 -0800 | [diff] [blame] | 151 | extend:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 8); |
Filip Kujawa | 102a9b2 | 2024-02-18 09:40:23 -0800 | [diff] [blame] | 152 | |
| 153 | // State of the extender rollers |
Filip Kujawa | 7a79960 | 2024-02-23 12:27:47 -0800 | [diff] [blame] | 154 | extend_roller:ExtendRollerStatus (id: 9); |
Niko Sohmers | ac4d887 | 2024-02-23 13:55:47 -0800 | [diff] [blame] | 155 | |
| 156 | // The status of if the turret and intake is colliding |
Filip Kujawa | 7a79960 | 2024-02-23 12:27:47 -0800 | [diff] [blame] | 157 | collided: bool (id: 10); |
| 158 | |
| 159 | extend_status:ExtendStatus (id: 11); |
James Kuszmaul | 0281e15 | 2024-02-26 22:26:16 -0800 | [diff] [blame] | 160 | |
| 161 | // Indicates that the extend is in position to allow a game piece to |
| 162 | // be transfered into it. |
| 163 | extend_ready_for_transfer:bool (id: 12); |
| 164 | |
| 165 | // Indicates that the turret is in position to avoid the extend. |
Niko Sohmers | 5006fc4 | 2024-03-01 17:14:22 -0800 | [diff] [blame] | 166 | turret_ready_for_extend_move:bool (id: 13, deprecated); |
| 167 | |
| 168 | uncompleted_note_goal:NoteStatus = NONE (id: 14); |
Niko Sohmers | 2a251cd | 2024-03-02 19:16:15 -0800 | [diff] [blame] | 169 | |
| 170 | // Indicates if the extend is close enough to the retracted position to be |
| 171 | // considered ready to accept note from the transfer rollers. |
| 172 | extend_at_retracted:bool (id: 15); |
| 173 | |
| 174 | // Indicates if the turret is at the position to accept the note from extend |
| 175 | turret_ready_for_load:bool (id: 16); |
| 176 | |
| 177 | // Indicates if the altitude is at the position to accept the note from |
| 178 | // extend |
| 179 | altitude_ready_for_load:bool (id: 17); |
| 180 | |
| 181 | // Indicates if the extend is at the position to load the catapult |
| 182 | extend_ready_for_catapult_transfer:bool (id: 18); |
| 183 | |
| 184 | extend_beambreak:bool (id: 19); |
| 185 | catapult_beambreak:bool (id: 20); |
Niko Sohmers | 2ac60c5 | 2024-03-16 18:44:54 -0700 | [diff] [blame] | 186 | transfer_beambreak:bool (id: 22); |
James Kuszmaul | df3a3cb | 2024-03-15 22:03:37 -0700 | [diff] [blame] | 187 | |
| 188 | // Number of shots we have taken. |
| 189 | shot_count:uint32 (id:21); |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | root_type Status; |