Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 1 | package y2017.control_loops; |
| 2 | |
| 3 | import "aos/common/controls/control_loops.q"; |
Austin Schuh | 3634ed3 | 2017-02-05 16:28:49 -0800 | [diff] [blame] | 4 | import "frc971/control_loops/profiled_subsystem.q"; |
| 5 | // TODO(austin): Add this back in when the queue compiler supports diamond |
| 6 | // inheritance. |
| 7 | //import "frc971/control_loops/control_loops.q"; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 8 | |
| 9 | struct IntakeGoal { |
Brian Silverman | 052e69d | 2017-02-12 16:19:55 -0800 | [diff] [blame] | 10 | // Zero for the intake is when the front tube is tangent with the front of the |
| 11 | // frame. Positive is out. |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 12 | |
| 13 | // Goal distance of the intake. |
| 14 | double distance; |
| 15 | |
| 16 | // Caps on velocity/acceleration for profiling. 0 for the default. |
| 17 | .frc971.ProfileParameters profile_params; |
| 18 | |
| 19 | // Voltage to send to the rollers. Positive is sucking in. |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 20 | double voltage_rollers; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 21 | }; |
| 22 | |
Brian Silverman | 052e69d | 2017-02-12 16:19:55 -0800 | [diff] [blame] | 23 | struct IndexerGoal { |
| 24 | // Indexer angular velocity goals in radians/second. |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 25 | double angular_velocity; |
Campbell Crowley | 651c4b4 | 2017-02-17 22:30:50 -0800 | [diff] [blame] | 26 | |
| 27 | // Roller voltage. Positive is sucking in. |
| 28 | double voltage_rollers; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 29 | }; |
| 30 | |
| 31 | struct TurretGoal { |
Campbell Crowley | 065a081 | 2017-02-04 22:27:17 -0800 | [diff] [blame] | 32 | // An angle of zero means the turrent faces toward the front of the |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 33 | // robot where the intake is located. The angle increases when the turret |
Campbell Crowley | 065a081 | 2017-02-04 22:27:17 -0800 | [diff] [blame] | 34 | // turns clockwise (towards right from the front), and decreases when |
| 35 | // the turrent turns counter-clockwise (towards left from the front). |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 36 | // These are from a top view above the robot. |
Campbell Crowley | 065a081 | 2017-02-04 22:27:17 -0800 | [diff] [blame] | 37 | double angle; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 38 | |
| 39 | // Caps on velocity/acceleration for profiling. 0 for the default. |
| 40 | .frc971.ProfileParameters profile_params; |
| 41 | }; |
| 42 | |
| 43 | struct HoodGoal { |
Brian Silverman | 052e69d | 2017-02-12 16:19:55 -0800 | [diff] [blame] | 44 | // Angle the hood is currently at. An angle of zero is at the lower hard |
| 45 | // stop, angle increases as hood rises. |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 46 | double angle; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 47 | |
| 48 | // Caps on velocity/acceleration for profiling. 0 for the default. |
| 49 | .frc971.ProfileParameters profile_params; |
| 50 | }; |
| 51 | |
| 52 | struct ShooterGoal { |
Brian Silverman | 052e69d | 2017-02-12 16:19:55 -0800 | [diff] [blame] | 53 | // Angular velocity goals in radians/second. Positive is shooting out of the |
| 54 | // robot. |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 55 | double angular_velocity; |
| 56 | }; |
| 57 | |
Brian Silverman | 052e69d | 2017-02-12 16:19:55 -0800 | [diff] [blame] | 58 | struct IndexerStatus { |
| 59 | // The current average velocity in radians/second. Positive is moving balls up |
| 60 | // towards the shooter. This is the angular velocity of the inner piece. |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 61 | double avg_angular_velocity; |
| 62 | |
| 63 | // The current instantaneous filtered velocity in radians/second. |
| 64 | double angular_velocity; |
| 65 | |
Brian Silverman | 052e69d | 2017-02-12 16:19:55 -0800 | [diff] [blame] | 66 | // True if the indexer is ready. It is better to compare the velocities |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 67 | // directly so there isn't confusion on if the goal is up to date. |
| 68 | bool ready; |
| 69 | |
Austin Schuh | cd3237a | 2017-02-18 14:19:26 -0800 | [diff] [blame] | 70 | // True if the indexer is stuck. |
| 71 | bool stuck; |
Austin Schuh | a4dd26d | 2017-02-24 19:14:39 -0800 | [diff] [blame^] | 72 | float stuck_voltage; |
Austin Schuh | cd3237a | 2017-02-18 14:19:26 -0800 | [diff] [blame] | 73 | |
| 74 | // The state of the indexer state machine. |
| 75 | int32_t state; |
| 76 | |
| 77 | // The estimated voltage error from the kalman filter in volts. |
| 78 | double voltage_error; |
| 79 | // The estimated voltage error from the stuck indexer kalman filter. |
| 80 | double stuck_voltage_error; |
| 81 | |
| 82 | // The current velocity measured as delta x / delta t in radians/sec. |
| 83 | double instantaneous_velocity; |
| 84 | |
| 85 | // The error between our measurement and expected measurement in radians. |
| 86 | double position_error; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 87 | }; |
| 88 | |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 89 | struct ShooterStatus { |
| 90 | // The current average velocity in radians/second. |
| 91 | double avg_angular_velocity; |
| 92 | |
| 93 | // The current instantaneous filtered velocity in radians/second. |
| 94 | double angular_velocity; |
| 95 | |
| 96 | // True if the shooter is ready. It is better to compare the velocities |
| 97 | // directly so there isn't confusion on if the goal is up to date. |
| 98 | bool ready; |
| 99 | |
Tyler Chatow | 2737d2a | 2017-02-08 21:20:51 -0800 | [diff] [blame] | 100 | // The estimated voltage error from the kalman filter in volts. |
| 101 | double voltage_error; |
| 102 | |
| 103 | // The current velocity measured as delta x / delta t in radians/sec. |
| 104 | double instantaneous_velocity; |
| 105 | |
| 106 | // The error between our measurement and expected measurement in radians. |
| 107 | double position_error; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | queue_group SuperstructureQueue { |
| 111 | implements aos.control_loops.ControlLoop; |
| 112 | |
| 113 | message Goal { |
| 114 | IntakeGoal intake; |
Brian Silverman | 052e69d | 2017-02-12 16:19:55 -0800 | [diff] [blame] | 115 | IndexerGoal indexer; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 116 | TurretGoal turret; |
| 117 | HoodGoal hood; |
| 118 | ShooterGoal shooter; |
| 119 | }; |
| 120 | |
| 121 | message Status { |
| 122 | // Are all the subsystems zeroed? |
| 123 | bool zeroed; |
| 124 | |
| 125 | // If true, we have aborted. This is the or of all subsystem estops. |
| 126 | bool estopped; |
| 127 | |
| 128 | // Each subsystems status. |
Adam Snaider | 79900c2 | 2017-02-08 20:23:15 -0800 | [diff] [blame] | 129 | .frc971.control_loops.AbsoluteProfiledJointStatus intake; |
| 130 | .frc971.control_loops.AbsoluteProfiledJointStatus turret; |
Austin Schuh | 6a90cd9 | 2017-02-19 20:55:33 -0800 | [diff] [blame] | 131 | .frc971.control_loops.IndexProfiledJointStatus hood; |
Brian Silverman | 052e69d | 2017-02-12 16:19:55 -0800 | [diff] [blame] | 132 | IndexerStatus indexer; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 133 | ShooterStatus shooter; |
| 134 | }; |
| 135 | |
| 136 | message Position { |
| 137 | // Position of the intake, zero when the intake is in, positive when it is |
| 138 | // out. |
Adam Snaider | 79900c2 | 2017-02-08 20:23:15 -0800 | [diff] [blame] | 139 | .frc971.PotAndAbsolutePosition intake; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 140 | |
Brian Silverman | 052e69d | 2017-02-12 16:19:55 -0800 | [diff] [blame] | 141 | // Indexer angle in radians. |
| 142 | double theta_indexer; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 143 | |
Campbell Crowley | 065a081 | 2017-02-04 22:27:17 -0800 | [diff] [blame] | 144 | // The sensor readings for the turret. The units and sign are defined the |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 145 | // same as what's in the Goal message. |
Adam Snaider | 79900c2 | 2017-02-08 20:23:15 -0800 | [diff] [blame] | 146 | .frc971.PotAndAbsolutePosition turret; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 147 | |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 148 | // The sensor readings for the hood. The units and sign are defined the |
| 149 | // same as what's in the Goal message. |
Austin Schuh | 6a90cd9 | 2017-02-19 20:55:33 -0800 | [diff] [blame] | 150 | .frc971.IndexPosition hood; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 151 | |
| 152 | // Shooter wheel angle in radians. |
| 153 | double theta_shooter; |
| 154 | }; |
| 155 | |
| 156 | message Output { |
| 157 | // Voltages for some of the subsystems. |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 158 | double voltage_intake; |
Brian Silverman | 052e69d | 2017-02-12 16:19:55 -0800 | [diff] [blame] | 159 | double voltage_indexer; |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 160 | double voltage_shooter; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 161 | |
| 162 | // Rollers on the intake. |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 163 | double voltage_intake_rollers; |
Brian Silverman | 052e69d | 2017-02-12 16:19:55 -0800 | [diff] [blame] | 164 | // Roller on the indexer |
| 165 | double voltage_indexer_rollers; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 166 | |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 167 | double voltage_turret; |
| 168 | double voltage_hood; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 169 | }; |
| 170 | |
| 171 | queue Goal goal; |
| 172 | queue Position position; |
| 173 | queue Output output; |
| 174 | queue Status status; |
| 175 | }; |
| 176 | |
| 177 | queue_group SuperstructureQueue superstructure_queue; |