blob: 4f36449db167782fc0ccbfbc6537527dcf8ad82e [file] [log] [blame]
Campbell Crowley75026292017-02-04 21:46:19 -08001package y2017.control_loops;
2
3import "aos/common/controls/control_loops.q";
4import "frc971/control_loops/control_loops.q";
5
6struct JointState {
7 // Position of the joint.
8 float position;
9 // Velocity of the joint in units/second.
10 float velocity;
11 // Profiled goal position of the joint.
12 float goal_position;
13 // Profiled goal velocity of the joint in units/second.
14 float goal_velocity;
15 // Unprofiled goal position from absoulte zero of the joint.
16 float unprofiled_goal_position;
17 // Unprofiled goal velocity of the joint in units/second.
18 float unprofiled_goal_velocity;
19
20 // The estimated voltage error.
21 float voltage_error;
22
23 // The calculated velocity with delta x/delta t
24 float calculated_velocity;
25
26 // Components of the control loop output
27 float position_power;
28 float velocity_power;
29 float feedforwards_power;
30
31 // State of the estimator.
32 .frc971.EstimatorState estimator_state;
33};
34
35struct IntakeGoal {
36 // Zero on the intake is when the intake is retracted inside the robot,
37 // unable to intake. Positive is out.
38
39 // Goal distance of the intake.
40 double distance;
41
42 // Caps on velocity/acceleration for profiling. 0 for the default.
43 .frc971.ProfileParameters profile_params;
44
45 // Voltage to send to the rollers. Positive is sucking in.
Austin Schuh0991edb2017-02-05 17:16:44 -080046 double voltage_rollers;
Campbell Crowley75026292017-02-04 21:46:19 -080047};
48
49struct SerializerGoal {
50 // Serializer angular velocity goals in radians/second.
51 double angular_velocity;
52};
53
54struct TurretGoal {
Campbell Crowley065a0812017-02-04 22:27:17 -080055 // An angle of zero means the turrent faces toward the front of the
Campbell Crowley75026292017-02-04 21:46:19 -080056 // robot where the intake is located. The angle increases when the turret
Campbell Crowley065a0812017-02-04 22:27:17 -080057 // turns clockwise (towards right from the front), and decreases when
58 // the turrent turns counter-clockwise (towards left from the front).
Campbell Crowley75026292017-02-04 21:46:19 -080059 // These are from a top view above the robot.
Campbell Crowley065a0812017-02-04 22:27:17 -080060 double angle;
Campbell Crowley75026292017-02-04 21:46:19 -080061
62 // Caps on velocity/acceleration for profiling. 0 for the default.
63 .frc971.ProfileParameters profile_params;
64};
65
66struct HoodGoal {
67 // Angle the hood is currently at
Austin Schuh0991edb2017-02-05 17:16:44 -080068 double angle;
Campbell Crowley75026292017-02-04 21:46:19 -080069
70 // Caps on velocity/acceleration for profiling. 0 for the default.
71 .frc971.ProfileParameters profile_params;
72};
73
74struct ShooterGoal {
75 // Angular velocity goals in radians/second.
76 double angular_velocity;
77};
78
79struct IntakeStatus {
80 // Is it zeroed?
81 bool zeroed;
82
83 // Estimated position and velocities.
84 JointState joint_state;
85
86 // If true, we have aborted.
87 bool estopped;
88};
89
90struct SerializerStatus {
91 // The current average velocity in radians/second.
92 double avg_angular_velocity;
93
94 // The current instantaneous filtered velocity in radians/second.
95 double angular_velocity;
96
97 // True if the serializer is ready. It is better to compare the velocities
98 // directly so there isn't confusion on if the goal is up to date.
99 bool ready;
100
101 // If true, we have aborted.
102 bool estopped;
103};
104
105struct TurretStatus {
106 // Is the turret zeroed?
107 bool zeroed;
108
109 // If true, we have aborted.
110 bool estopped;
111
112 // Estimate angles and angular velocities.
Campbell Crowley065a0812017-02-04 22:27:17 -0800113 JointState turret;
Campbell Crowley75026292017-02-04 21:46:19 -0800114};
115
116struct HoodStatus {
117 // Is the turret zeroed?
118 bool zeroed;
119
120 // If true, we have aborted.
121 bool estopped;
122
123 // Estimate angles and angular velocities.
124 JointState hood;
125};
126
127struct ShooterStatus {
128 // The current average velocity in radians/second.
129 double avg_angular_velocity;
130
131 // The current instantaneous filtered velocity in radians/second.
132 double angular_velocity;
133
134 // True if the shooter is ready. It is better to compare the velocities
135 // directly so there isn't confusion on if the goal is up to date.
136 bool ready;
137
138 // If true, we have aborted.
139 bool estopped;
140};
141
142queue_group SuperstructureQueue {
143 implements aos.control_loops.ControlLoop;
144
145 message Goal {
146 IntakeGoal intake;
147 SerializerGoal serializer;
148 TurretGoal turret;
149 HoodGoal hood;
150 ShooterGoal shooter;
151 };
152
153 message Status {
154 // Are all the subsystems zeroed?
155 bool zeroed;
156
157 // If true, we have aborted. This is the or of all subsystem estops.
158 bool estopped;
159
160 // Each subsystems status.
161 IntakeStatus intake;
162 SerializerStatus serializer;
163 TurretStatus turret;
164 HoodStatus hood;
165 ShooterStatus shooter;
166 };
167
168 message Position {
Austin Schuh0991edb2017-02-05 17:16:44 -0800169 // TODO(austin): The turret and intake really should be absolute. Switch
170 // them over when that class is ready.
171
Campbell Crowley75026292017-02-04 21:46:19 -0800172 // Position of the intake, zero when the intake is in, positive when it is
173 // out.
Austin Schuh0991edb2017-02-05 17:16:44 -0800174 .frc971.PotAndIndexPosition intake;
Campbell Crowley75026292017-02-04 21:46:19 -0800175
176 // Serializer angle in radians.
177 double theta_serializer;
178
Campbell Crowley065a0812017-02-04 22:27:17 -0800179 // The sensor readings for the turret. The units and sign are defined the
Campbell Crowley75026292017-02-04 21:46:19 -0800180 // same as what's in the Goal message.
Austin Schuh0991edb2017-02-05 17:16:44 -0800181 .frc971.PotAndIndexPosition turret;
Campbell Crowley75026292017-02-04 21:46:19 -0800182
Austin Schuh0991edb2017-02-05 17:16:44 -0800183 // The sensor readings for the hood. The units and sign are defined the
184 // same as what's in the Goal message.
185 .frc971.PotAndIndexPosition hood;
Campbell Crowley75026292017-02-04 21:46:19 -0800186
187 // Shooter wheel angle in radians.
188 double theta_shooter;
189 };
190
191 message Output {
192 // Voltages for some of the subsystems.
Austin Schuh0991edb2017-02-05 17:16:44 -0800193 double voltage_intake;
194 double voltage_serializer;
195 double voltage_shooter;
Campbell Crowley75026292017-02-04 21:46:19 -0800196
197 // Rollers on the intake.
Austin Schuh0991edb2017-02-05 17:16:44 -0800198 double voltage_intake_rollers;
Campbell Crowley75026292017-02-04 21:46:19 -0800199 // Roller on the serializer
Austin Schuh0991edb2017-02-05 17:16:44 -0800200 double voltage_serializer_rollers;
Campbell Crowley75026292017-02-04 21:46:19 -0800201
Austin Schuh0991edb2017-02-05 17:16:44 -0800202 double voltage_turret;
203 double voltage_hood;
Campbell Crowley75026292017-02-04 21:46:19 -0800204 };
205
206 queue Goal goal;
207 queue Position position;
208 queue Output output;
209 queue Status status;
210};
211
212queue_group SuperstructureQueue superstructure_queue;