blob: 5fe207e79ae3b2b7519efe238e7e2af36bb8ab1f [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.
46 float voltage_rollers;
47};
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
68 double angle_hood;
69
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 {
169 // Position of the intake, zero when the intake is in, positive when it is
170 // out.
171 .frc971.PotAndAbsolutePosition intake;
172
173 // Serializer angle in radians.
174 double theta_serializer;
175
Campbell Crowley065a0812017-02-04 22:27:17 -0800176 // The sensor readings for the turret. The units and sign are defined the
Campbell Crowley75026292017-02-04 21:46:19 -0800177 // same as what's in the Goal message.
Campbell Crowley065a0812017-02-04 22:27:17 -0800178 .frc971.PotAndAbsolutePosition turret;
Campbell Crowley75026292017-02-04 21:46:19 -0800179
180 // Position of the hood in radians
181 double theta_hood;
182
183 // Shooter wheel angle in radians.
184 double theta_shooter;
185 };
186
187 message Output {
188 // Voltages for some of the subsystems.
189 float voltage_intake;
190 float voltage_serializer;
191 float voltage_shooter;
192
193 // Rollers on the intake.
194 float voltage_intake_rollers;
195 // Roller on the serializer
196 float voltage_serializer_rollers;
197
Campbell Crowley065a0812017-02-04 22:27:17 -0800198 float voltage_turret;
Campbell Crowley75026292017-02-04 21:46:19 -0800199 float voltage_hood;
200 };
201
202 queue Goal goal;
203 queue Position position;
204 queue Output output;
205 queue Status status;
206};
207
208queue_group SuperstructureQueue superstructure_queue;