milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 1 | include "frc971/control_loops/control_loops.fbs"; |
| 2 | include "frc971/control_loops/profiled_subsystem.fbs"; |
| 3 | |
| 4 | namespace y2022.control_loops.superstructure; |
| 5 | |
Ravago Jones | 5da0635 | 2022-03-04 20:26:24 -0800 | [diff] [blame] | 6 | // Contains which intake has a ball |
| 7 | enum IntakeState : ubyte { |
| 8 | NO_BALL, |
| 9 | INTAKE_FRONT_BALL, |
| 10 | INTAKE_BACK_BALL, |
| 11 | } |
| 12 | |
| 13 | // State of the superstructure state machine |
| 14 | enum SuperstructureState : ubyte { |
| 15 | // Before a ball is intaked, when neither intake beambreak is triggered |
Milind Upadhyay | 803bbf0 | 2022-03-11 17:56:26 -0800 | [diff] [blame] | 16 | IDLE = 0, |
Ravago Jones | 5da0635 | 2022-03-04 20:26:24 -0800 | [diff] [blame] | 17 | // Transferring ball with transfer rollers. Moves turret to loading position. |
Milind Upadhyay | 803bbf0 | 2022-03-11 17:56:26 -0800 | [diff] [blame] | 18 | TRANSFERRING = 1, |
Ravago Jones | 5da0635 | 2022-03-04 20:26:24 -0800 | [diff] [blame] | 19 | // Loading the ball into the catapult |
Milind Upadhyay | 803bbf0 | 2022-03-11 17:56:26 -0800 | [diff] [blame] | 20 | LOADING = 2, |
Ravago Jones | 5da0635 | 2022-03-04 20:26:24 -0800 | [diff] [blame] | 21 | // The ball is loaded into the catapult |
Milind Upadhyay | 803bbf0 | 2022-03-11 17:56:26 -0800 | [diff] [blame] | 22 | LOADED = 3, |
Ravago Jones | 5da0635 | 2022-03-04 20:26:24 -0800 | [diff] [blame] | 23 | // Waiting for the turret to be at shooting goal and then telling the |
| 24 | // catapult to fire. |
Milind Upadhyay | 803bbf0 | 2022-03-11 17:56:26 -0800 | [diff] [blame] | 25 | SHOOTING = 4, |
Ravago Jones | 5da0635 | 2022-03-04 20:26:24 -0800 | [diff] [blame] | 26 | } |
| 27 | |
James Kuszmaul | 84083f4 | 2022-02-27 17:24:38 -0800 | [diff] [blame] | 28 | table AimerStatus { |
| 29 | // The current goal angle for the turret auto-tracking, in radians. |
| 30 | turret_position:double (id: 0); |
| 31 | // The current goal velocity for the turret, in radians / sec. |
| 32 | turret_velocity:double (id: 1); |
| 33 | // The current distance to the target, in meters. |
| 34 | target_distance:double (id: 2); |
| 35 | // The current "shot distance." When shooting on the fly, this may be |
| 36 | // different from the static distance to the target. |
| 37 | shot_distance:double (id: 3); |
| 38 | } |
| 39 | |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 40 | table Status { |
| 41 | // All subsystems know their location. |
| 42 | zeroed:bool (id: 0); |
| 43 | |
| 44 | // If true, we have aborted. This is the or of all subsystem estops. |
| 45 | estopped:bool (id: 1); |
Ravago Jones | 5da0635 | 2022-03-04 20:26:24 -0800 | [diff] [blame] | 46 | // The state of the superstructure |
| 47 | |
| 48 | state:SuperstructureState (id: 10); |
| 49 | // Intaking state |
| 50 | intake_state:IntakeState (id: 11); |
James Kuszmaul | 4052695 | 2022-03-13 15:56:38 -0700 | [diff] [blame] | 51 | // Whether the front/rear intakes currently are holding balls. |
| 52 | front_intake_has_ball:bool (id: 18); |
| 53 | back_intake_has_ball:bool (id: 19); |
Ravago Jones | 5da0635 | 2022-03-04 20:26:24 -0800 | [diff] [blame] | 54 | // Whether the flippers are open for shooting |
| 55 | flippers_open:bool (id: 12); |
| 56 | // Whether the flippers failed to open and we are retrying |
| 57 | reseating_in_catapult:bool (id: 13); |
Milind Upadhyay | 9d68b13 | 2022-04-01 10:58:18 -0700 | [diff] [blame^] | 58 | // Whether the turret/catapult is collided with the intake |
| 59 | collided:bool(id: 23); |
Henry Speiser | 77747b7 | 2022-03-06 17:18:29 -0800 | [diff] [blame] | 60 | // Whether the turret is ready for firing |
| 61 | ready_to_fire:bool (id: 20); |
Henry Speiser | a9c49a2 | 2022-04-01 15:22:35 -0700 | [diff] [blame] | 62 | // Whether the robot is moving too fast to shoot |
| 63 | moving_too_fast:bool (id: 21); |
Ravago Jones | d51af7a | 2022-03-26 21:44:20 -0700 | [diff] [blame] | 64 | // True if the robot has detected that it is holding |
| 65 | // the wrong color ball and is now discarding it. |
| 66 | discarding_ball:bool (id: 22); |
Ravago Jones | 5da0635 | 2022-03-04 20:26:24 -0800 | [diff] [blame] | 67 | // Whether the catapult was told to fire, |
| 68 | // meaning that the turret and flippers are ready for firing |
| 69 | // and we were asked to fire. Different from fire flag in goal. |
| 70 | fire:bool (id: 14); |
Griffin Bui | 67abb91 | 2022-01-22 16:16:21 -0800 | [diff] [blame] | 71 | |
Siddhant Kanwar | 0e37f59 | 2022-02-21 19:26:50 -0800 | [diff] [blame] | 72 | // Subsystem statuses |
| 73 | climber:frc971.control_loops.RelativeEncoderProfiledJointStatus (id: 2); |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 74 | |
| 75 | // Estimated angles and angular velocities of the intakes. |
| 76 | intake_front:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 3); |
| 77 | intake_back:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 4); |
| 78 | |
| 79 | turret:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 5); |
Austin Schuh | 39f26f6 | 2022-02-24 21:34:46 -0800 | [diff] [blame] | 80 | |
| 81 | catapult:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 6); |
| 82 | |
| 83 | solve_time:double (id: 7); |
Austin Schuh | 4147255 | 2022-03-13 18:09:41 -0700 | [diff] [blame] | 84 | mpc_horizon:uint8 (id: 8); |
Ravago Jones | 3283ce0 | 2022-03-09 19:31:29 -0800 | [diff] [blame] | 85 | shot_position:double (id: 16); |
| 86 | shot_velocity:double (id: 17); |
Austin Schuh | 80fc275 | 2022-02-25 13:33:56 -0800 | [diff] [blame] | 87 | |
| 88 | // The number of shots we have taken. |
| 89 | shot_count:int32 (id: 9); |
James Kuszmaul | 84083f4 | 2022-02-27 17:24:38 -0800 | [diff] [blame] | 90 | |
| 91 | aimer:AimerStatus (id: 15); |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 92 | } |
| 93 | |
Austin Schuh | 39f26f6 | 2022-02-24 21:34:46 -0800 | [diff] [blame] | 94 | root_type Status; |