blob: 0f707dce903d5af0d363fe11450c81524f148434 [file] [log] [blame]
Campbell Crowley75026292017-02-04 21:46:19 -08001package y2017.control_loops;
2
3import "aos/common/controls/control_loops.q";
Austin Schuh3634ed32017-02-05 16:28:49 -08004import "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 Crowley75026292017-02-04 21:46:19 -08008
9struct IntakeGoal {
Brian Silverman052e69d2017-02-12 16:19:55 -080010 // Zero for the intake is when the front tube is tangent with the front of the
11 // frame. Positive is out.
Campbell Crowley75026292017-02-04 21:46:19 -080012
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 Schuh0991edb2017-02-05 17:16:44 -080020 double voltage_rollers;
Campbell Crowley75026292017-02-04 21:46:19 -080021};
22
Brian Silverman052e69d2017-02-12 16:19:55 -080023struct IndexerGoal {
24 // Indexer angular velocity goals in radians/second.
Campbell Crowley75026292017-02-04 21:46:19 -080025 double angular_velocity;
Campbell Crowley651c4b42017-02-17 22:30:50 -080026
27 // Roller voltage. Positive is sucking in.
28 double voltage_rollers;
Campbell Crowley75026292017-02-04 21:46:19 -080029};
30
31struct TurretGoal {
Campbell Crowley065a0812017-02-04 22:27:17 -080032 // An angle of zero means the turrent faces toward the front of the
Campbell Crowley75026292017-02-04 21:46:19 -080033 // robot where the intake is located. The angle increases when the turret
Campbell Crowley065a0812017-02-04 22:27:17 -080034 // turns clockwise (towards right from the front), and decreases when
35 // the turrent turns counter-clockwise (towards left from the front).
Campbell Crowley75026292017-02-04 21:46:19 -080036 // These are from a top view above the robot.
Campbell Crowley065a0812017-02-04 22:27:17 -080037 double angle;
Campbell Crowley75026292017-02-04 21:46:19 -080038
39 // Caps on velocity/acceleration for profiling. 0 for the default.
40 .frc971.ProfileParameters profile_params;
41};
42
43struct HoodGoal {
Brian Silverman052e69d2017-02-12 16:19:55 -080044 // Angle the hood is currently at. An angle of zero is at the lower hard
45 // stop, angle increases as hood rises.
Austin Schuh0991edb2017-02-05 17:16:44 -080046 double angle;
Campbell Crowley75026292017-02-04 21:46:19 -080047
48 // Caps on velocity/acceleration for profiling. 0 for the default.
49 .frc971.ProfileParameters profile_params;
50};
51
52struct ShooterGoal {
Brian Silverman052e69d2017-02-12 16:19:55 -080053 // Angular velocity goals in radians/second. Positive is shooting out of the
54 // robot.
Campbell Crowley75026292017-02-04 21:46:19 -080055 double angular_velocity;
56};
57
Brian Silverman052e69d2017-02-12 16:19:55 -080058struct 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 Crowley75026292017-02-04 21:46:19 -080061 double avg_angular_velocity;
62
63 // The current instantaneous filtered velocity in radians/second.
64 double angular_velocity;
65
Brian Silverman052e69d2017-02-12 16:19:55 -080066 // True if the indexer is ready. It is better to compare the velocities
Campbell Crowley75026292017-02-04 21:46:19 -080067 // directly so there isn't confusion on if the goal is up to date.
68 bool ready;
69
Austin Schuhcd3237a2017-02-18 14:19:26 -080070 // True if the indexer is stuck.
71 bool stuck;
Austin Schuha4dd26d2017-02-24 19:14:39 -080072 float stuck_voltage;
Austin Schuhcd3237a2017-02-18 14:19:26 -080073
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 Crowley75026292017-02-04 21:46:19 -080087};
88
Campbell Crowley75026292017-02-04 21:46:19 -080089struct 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 Chatow2737d2a2017-02-08 21:20:51 -0800100 // 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;
Austin Schuh932a5ce2017-03-05 01:04:18 -0800105 double fixed_instantaneous_velocity;
Tyler Chatow2737d2a2017-02-08 21:20:51 -0800106
107 // The error between our measurement and expected measurement in radians.
108 double position_error;
Campbell Crowley75026292017-02-04 21:46:19 -0800109};
110
Austin Schuhea56e212017-03-04 22:33:12 -0800111struct ColumnPosition {
112 // Indexer angle in radians relative to the base. Positive is according to
113 // the right hand rule around +z.
114 .frc971.HallEffectAndPosition indexer;
115 // Turret angle in radians relative to the indexer. Positive is the same as
116 // the indexer.
117 .frc971.HallEffectAndPosition turret;
118};
119
Campbell Crowley75026292017-02-04 21:46:19 -0800120queue_group SuperstructureQueue {
121 implements aos.control_loops.ControlLoop;
122
123 message Goal {
124 IntakeGoal intake;
Brian Silverman052e69d2017-02-12 16:19:55 -0800125 IndexerGoal indexer;
Campbell Crowley75026292017-02-04 21:46:19 -0800126 TurretGoal turret;
127 HoodGoal hood;
128 ShooterGoal shooter;
129 };
130
131 message Status {
132 // Are all the subsystems zeroed?
133 bool zeroed;
134
135 // If true, we have aborted. This is the or of all subsystem estops.
136 bool estopped;
137
138 // Each subsystems status.
Adam Snaider79900c22017-02-08 20:23:15 -0800139 .frc971.control_loops.AbsoluteProfiledJointStatus intake;
140 .frc971.control_loops.AbsoluteProfiledJointStatus turret;
Austin Schuh6a90cd92017-02-19 20:55:33 -0800141 .frc971.control_loops.IndexProfiledJointStatus hood;
Brian Silverman052e69d2017-02-12 16:19:55 -0800142 IndexerStatus indexer;
Campbell Crowley75026292017-02-04 21:46:19 -0800143 ShooterStatus shooter;
144 };
145
146 message Position {
147 // Position of the intake, zero when the intake is in, positive when it is
148 // out.
Adam Snaider79900c22017-02-08 20:23:15 -0800149 .frc971.PotAndAbsolutePosition intake;
Campbell Crowley75026292017-02-04 21:46:19 -0800150
Austin Schuhea56e212017-03-04 22:33:12 -0800151 // The position of the column.
152 ColumnPosition column;
Campbell Crowley75026292017-02-04 21:46:19 -0800153
Austin Schuh0991edb2017-02-05 17:16:44 -0800154 // The sensor readings for the hood. The units and sign are defined the
155 // same as what's in the Goal message.
Austin Schuh6a90cd92017-02-19 20:55:33 -0800156 .frc971.IndexPosition hood;
Campbell Crowley75026292017-02-04 21:46:19 -0800157
158 // Shooter wheel angle in radians.
159 double theta_shooter;
160 };
161
162 message Output {
163 // Voltages for some of the subsystems.
Austin Schuh0991edb2017-02-05 17:16:44 -0800164 double voltage_intake;
Brian Silverman052e69d2017-02-12 16:19:55 -0800165 double voltage_indexer;
Austin Schuh0991edb2017-02-05 17:16:44 -0800166 double voltage_shooter;
Campbell Crowley75026292017-02-04 21:46:19 -0800167
168 // Rollers on the intake.
Austin Schuh0991edb2017-02-05 17:16:44 -0800169 double voltage_intake_rollers;
Brian Silverman052e69d2017-02-12 16:19:55 -0800170 // Roller on the indexer
171 double voltage_indexer_rollers;
Campbell Crowley75026292017-02-04 21:46:19 -0800172
Austin Schuh0991edb2017-02-05 17:16:44 -0800173 double voltage_turret;
174 double voltage_hood;
Campbell Crowley75026292017-02-04 21:46:19 -0800175 };
176
177 queue Goal goal;
178 queue Position position;
179 queue Output output;
180 queue Status status;
181};
182
183queue_group SuperstructureQueue superstructure_queue;