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 { |
| 10 | // Zero on the intake is when the intake is retracted inside the robot, |
| 11 | // unable to intake. Positive is out. |
| 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 | |
| 23 | struct SerializerGoal { |
| 24 | // Serializer angular velocity goals in radians/second. |
| 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 { |
Ed Jordan | 8683f43 | 2017-02-12 00:13:26 +0000 | [diff] [blame] | 41 | // Angle the hood is currently at. An angle of zero hood is at the lower soft stop, angle |
| 42 | // 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 { |
| 50 | // Angular velocity goals in radians/second. |
| 51 | double angular_velocity; |
| 52 | }; |
| 53 | |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 54 | struct SerializerStatus { |
| 55 | // The current average velocity in radians/second. |
| 56 | double avg_angular_velocity; |
| 57 | |
| 58 | // The current instantaneous filtered velocity in radians/second. |
| 59 | double angular_velocity; |
| 60 | |
| 61 | // True if the serializer is ready. It is better to compare the velocities |
| 62 | // directly so there isn't confusion on if the goal is up to date. |
| 63 | bool ready; |
| 64 | |
| 65 | // If true, we have aborted. |
| 66 | bool estopped; |
| 67 | }; |
| 68 | |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 69 | struct ShooterStatus { |
| 70 | // The current average velocity in radians/second. |
| 71 | double avg_angular_velocity; |
| 72 | |
| 73 | // The current instantaneous filtered velocity in radians/second. |
| 74 | double angular_velocity; |
| 75 | |
| 76 | // True if the shooter is ready. It is better to compare the velocities |
| 77 | // directly so there isn't confusion on if the goal is up to date. |
| 78 | bool ready; |
| 79 | |
| 80 | // If true, we have aborted. |
| 81 | bool estopped; |
| 82 | }; |
| 83 | |
| 84 | queue_group SuperstructureQueue { |
| 85 | implements aos.control_loops.ControlLoop; |
| 86 | |
| 87 | message Goal { |
| 88 | IntakeGoal intake; |
| 89 | SerializerGoal serializer; |
| 90 | TurretGoal turret; |
| 91 | HoodGoal hood; |
| 92 | ShooterGoal shooter; |
| 93 | }; |
| 94 | |
| 95 | message Status { |
| 96 | // Are all the subsystems zeroed? |
| 97 | bool zeroed; |
| 98 | |
| 99 | // If true, we have aborted. This is the or of all subsystem estops. |
| 100 | bool estopped; |
| 101 | |
| 102 | // Each subsystems status. |
Austin Schuh | 3634ed3 | 2017-02-05 16:28:49 -0800 | [diff] [blame] | 103 | .frc971.control_loops.ProfiledJointStatus intake; |
| 104 | .frc971.control_loops.ProfiledJointStatus turret; |
| 105 | .frc971.control_loops.ProfiledJointStatus hood; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 106 | SerializerStatus serializer; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 107 | ShooterStatus shooter; |
| 108 | }; |
| 109 | |
| 110 | message Position { |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 111 | // TODO(austin): The turret and intake really should be absolute. Switch |
| 112 | // them over when that class is ready. |
| 113 | |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 114 | // Position of the intake, zero when the intake is in, positive when it is |
| 115 | // out. |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 116 | .frc971.PotAndIndexPosition intake; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 117 | |
| 118 | // Serializer angle in radians. |
| 119 | double theta_serializer; |
| 120 | |
Campbell Crowley | 065a081 | 2017-02-04 22:27:17 -0800 | [diff] [blame] | 121 | // 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] | 122 | // same as what's in the Goal message. |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 123 | .frc971.PotAndIndexPosition turret; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 124 | |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 125 | // The sensor readings for the hood. The units and sign are defined the |
| 126 | // same as what's in the Goal message. |
| 127 | .frc971.PotAndIndexPosition hood; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 128 | |
| 129 | // Shooter wheel angle in radians. |
| 130 | double theta_shooter; |
| 131 | }; |
| 132 | |
| 133 | message Output { |
| 134 | // Voltages for some of the subsystems. |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 135 | double voltage_intake; |
| 136 | double voltage_serializer; |
| 137 | double voltage_shooter; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 138 | |
| 139 | // Rollers on the intake. |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 140 | double voltage_intake_rollers; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 141 | // Roller on the serializer |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 142 | double voltage_serializer_rollers; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 143 | |
Austin Schuh | 0991edb | 2017-02-05 17:16:44 -0800 | [diff] [blame] | 144 | double voltage_turret; |
| 145 | double voltage_hood; |
Campbell Crowley | 7502629 | 2017-02-04 21:46:19 -0800 | [diff] [blame] | 146 | }; |
| 147 | |
| 148 | queue Goal goal; |
| 149 | queue Position position; |
| 150 | queue Output output; |
| 151 | queue Status status; |
| 152 | }; |
| 153 | |
| 154 | queue_group SuperstructureQueue superstructure_queue; |