blob: 49f93e5f19951baa3542e02ff610387c254aa962 [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;
26};
27
28struct TurretGoal {
Campbell Crowley065a0812017-02-04 22:27:17 -080029 // An angle of zero means the turrent faces toward the front of the
Campbell Crowley75026292017-02-04 21:46:19 -080030 // robot where the intake is located. The angle increases when the turret
Campbell Crowley065a0812017-02-04 22:27:17 -080031 // turns clockwise (towards right from the front), and decreases when
32 // the turrent turns counter-clockwise (towards left from the front).
Campbell Crowley75026292017-02-04 21:46:19 -080033 // These are from a top view above the robot.
Campbell Crowley065a0812017-02-04 22:27:17 -080034 double angle;
Campbell Crowley75026292017-02-04 21:46:19 -080035
36 // Caps on velocity/acceleration for profiling. 0 for the default.
37 .frc971.ProfileParameters profile_params;
38};
39
40struct HoodGoal {
Brian Silverman052e69d2017-02-12 16:19:55 -080041 // Angle the hood is currently at. An angle of zero is at the lower hard
42 // stop, angle increases as hood rises.
Austin Schuh0991edb2017-02-05 17:16:44 -080043 double angle;
Campbell Crowley75026292017-02-04 21:46:19 -080044
45 // Caps on velocity/acceleration for profiling. 0 for the default.
46 .frc971.ProfileParameters profile_params;
47};
48
49struct ShooterGoal {
Brian Silverman052e69d2017-02-12 16:19:55 -080050 // Angular velocity goals in radians/second. Positive is shooting out of the
51 // robot.
Campbell Crowley75026292017-02-04 21:46:19 -080052 double angular_velocity;
53};
54
Brian Silverman052e69d2017-02-12 16:19:55 -080055struct 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 Crowley75026292017-02-04 21:46:19 -080058 double avg_angular_velocity;
59
60 // The current instantaneous filtered velocity in radians/second.
61 double angular_velocity;
62
Brian Silverman052e69d2017-02-12 16:19:55 -080063 // True if the indexer is ready. It is better to compare the velocities
Campbell Crowley75026292017-02-04 21:46:19 -080064 // directly so there isn't confusion on if the goal is up to date.
65 bool ready;
66
Austin Schuhcd3237a2017-02-18 14:19:26 -080067 // True if the indexer is stuck.
68 bool stuck;
69 float stuck_ratio;
70
71 // The state of the indexer state machine.
72 int32_t state;
73
74 // The estimated voltage error from the kalman filter in volts.
75 double voltage_error;
76 // The estimated voltage error from the stuck indexer kalman filter.
77 double stuck_voltage_error;
78
79 // The current velocity measured as delta x / delta t in radians/sec.
80 double instantaneous_velocity;
81
82 // The error between our measurement and expected measurement in radians.
83 double position_error;
Campbell Crowley75026292017-02-04 21:46:19 -080084};
85
Campbell Crowley75026292017-02-04 21:46:19 -080086struct ShooterStatus {
87 // The current average velocity in radians/second.
88 double avg_angular_velocity;
89
90 // The current instantaneous filtered velocity in radians/second.
91 double angular_velocity;
92
93 // True if the shooter is ready. It is better to compare the velocities
94 // directly so there isn't confusion on if the goal is up to date.
95 bool ready;
96
Tyler Chatow2737d2a2017-02-08 21:20:51 -080097 // The estimated voltage error from the kalman filter in volts.
98 double voltage_error;
99
100 // The current velocity measured as delta x / delta t in radians/sec.
101 double instantaneous_velocity;
102
103 // The error between our measurement and expected measurement in radians.
104 double position_error;
Campbell Crowley75026292017-02-04 21:46:19 -0800105};
106
107queue_group SuperstructureQueue {
108 implements aos.control_loops.ControlLoop;
109
110 message Goal {
111 IntakeGoal intake;
Brian Silverman052e69d2017-02-12 16:19:55 -0800112 IndexerGoal indexer;
Campbell Crowley75026292017-02-04 21:46:19 -0800113 TurretGoal turret;
114 HoodGoal hood;
115 ShooterGoal shooter;
116 };
117
118 message Status {
119 // Are all the subsystems zeroed?
120 bool zeroed;
121
122 // If true, we have aborted. This is the or of all subsystem estops.
123 bool estopped;
124
125 // Each subsystems status.
Adam Snaider79900c22017-02-08 20:23:15 -0800126 .frc971.control_loops.AbsoluteProfiledJointStatus intake;
127 .frc971.control_loops.AbsoluteProfiledJointStatus turret;
Austin Schuh3634ed32017-02-05 16:28:49 -0800128 .frc971.control_loops.ProfiledJointStatus hood;
Brian Silverman052e69d2017-02-12 16:19:55 -0800129 IndexerStatus indexer;
Campbell Crowley75026292017-02-04 21:46:19 -0800130 ShooterStatus shooter;
131 };
132
133 message Position {
Austin Schuh0991edb2017-02-05 17:16:44 -0800134 // TODO(austin): The turret and intake really should be absolute. Switch
135 // them over when that class is ready.
136
Campbell Crowley75026292017-02-04 21:46:19 -0800137 // Position of the intake, zero when the intake is in, positive when it is
138 // out.
Adam Snaider79900c22017-02-08 20:23:15 -0800139 .frc971.PotAndAbsolutePosition intake;
Campbell Crowley75026292017-02-04 21:46:19 -0800140
Brian Silverman052e69d2017-02-12 16:19:55 -0800141 // Indexer angle in radians.
142 double theta_indexer;
Campbell Crowley75026292017-02-04 21:46:19 -0800143
Campbell Crowley065a0812017-02-04 22:27:17 -0800144 // The sensor readings for the turret. The units and sign are defined the
Campbell Crowley75026292017-02-04 21:46:19 -0800145 // same as what's in the Goal message.
Adam Snaider79900c22017-02-08 20:23:15 -0800146 .frc971.PotAndAbsolutePosition turret;
Campbell Crowley75026292017-02-04 21:46:19 -0800147
Austin Schuh0991edb2017-02-05 17:16:44 -0800148 // The sensor readings for the hood. The units and sign are defined the
149 // same as what's in the Goal message.
150 .frc971.PotAndIndexPosition hood;
Campbell Crowley75026292017-02-04 21:46:19 -0800151
152 // Shooter wheel angle in radians.
153 double theta_shooter;
154 };
155
156 message Output {
157 // Voltages for some of the subsystems.
Austin Schuh0991edb2017-02-05 17:16:44 -0800158 double voltage_intake;
Brian Silverman052e69d2017-02-12 16:19:55 -0800159 double voltage_indexer;
Austin Schuh0991edb2017-02-05 17:16:44 -0800160 double voltage_shooter;
Campbell Crowley75026292017-02-04 21:46:19 -0800161
162 // Rollers on the intake.
Austin Schuh0991edb2017-02-05 17:16:44 -0800163 double voltage_intake_rollers;
Brian Silverman052e69d2017-02-12 16:19:55 -0800164 // Roller on the indexer
165 double voltage_indexer_rollers;
Campbell Crowley75026292017-02-04 21:46:19 -0800166
Austin Schuh0991edb2017-02-05 17:16:44 -0800167 double voltage_turret;
168 double voltage_hood;
Campbell Crowley75026292017-02-04 21:46:19 -0800169 };
170
171 queue Goal goal;
172 queue Position position;
173 queue Output output;
174 queue Status status;
175};
176
177queue_group SuperstructureQueue superstructure_queue;