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