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