blob: a3b271546d61933265e4a4f5b3f6fa8d081b30b4 [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 {
55 // An azimuth angle of zero means the turrent faces toward the front of the
56 // robot where the intake is located. The angle increases when the turret
57 // turns clockwise, and decreases when the turrent turns counter-clockwise.
58 // These are from a top view above the robot.
59 double angle_azimuth;
60
61 // Caps on velocity/acceleration for profiling. 0 for the default.
62 .frc971.ProfileParameters profile_params;
63};
64
65struct HoodGoal {
66 // Angle the hood is currently at
67 double angle_hood;
68
69 // Caps on velocity/acceleration for profiling. 0 for the default.
70 .frc971.ProfileParameters profile_params;
71};
72
73struct ShooterGoal {
74 // Angular velocity goals in radians/second.
75 double angular_velocity;
76};
77
78struct IntakeStatus {
79 // Is it zeroed?
80 bool zeroed;
81
82 // Estimated position and velocities.
83 JointState joint_state;
84
85 // If true, we have aborted.
86 bool estopped;
87};
88
89struct SerializerStatus {
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 serializer 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
100 // If true, we have aborted.
101 bool estopped;
102};
103
104struct TurretStatus {
105 // Is the turret zeroed?
106 bool zeroed;
107
108 // If true, we have aborted.
109 bool estopped;
110
111 // Estimate angles and angular velocities.
112 JointState azimuth;
113};
114
115struct HoodStatus {
116 // Is the turret zeroed?
117 bool zeroed;
118
119 // If true, we have aborted.
120 bool estopped;
121
122 // Estimate angles and angular velocities.
123 JointState hood;
124};
125
126struct ShooterStatus {
127 // The current average velocity in radians/second.
128 double avg_angular_velocity;
129
130 // The current instantaneous filtered velocity in radians/second.
131 double angular_velocity;
132
133 // True if the shooter is ready. It is better to compare the velocities
134 // directly so there isn't confusion on if the goal is up to date.
135 bool ready;
136
137 // If true, we have aborted.
138 bool estopped;
139};
140
141queue_group SuperstructureQueue {
142 implements aos.control_loops.ControlLoop;
143
144 message Goal {
145 IntakeGoal intake;
146 SerializerGoal serializer;
147 TurretGoal turret;
148 HoodGoal hood;
149 ShooterGoal shooter;
150 };
151
152 message Status {
153 // Are all the subsystems zeroed?
154 bool zeroed;
155
156 // If true, we have aborted. This is the or of all subsystem estops.
157 bool estopped;
158
159 // Each subsystems status.
160 IntakeStatus intake;
161 SerializerStatus serializer;
162 TurretStatus turret;
163 HoodStatus hood;
164 ShooterStatus shooter;
165 };
166
167 message Position {
168 // Position of the intake, zero when the intake is in, positive when it is
169 // out.
170 .frc971.PotAndAbsolutePosition intake;
171
172 // Serializer angle in radians.
173 double theta_serializer;
174
175 // The sensor readings for the azimuth. The units and sign are defined the
176 // same as what's in the Goal message.
177 .frc971.PotAndAbsolutePosition azimuth_turret;
178
179 // Position of the hood in radians
180 double theta_hood;
181
182 // Shooter wheel angle in radians.
183 double theta_shooter;
184 };
185
186 message Output {
187 // Voltages for some of the subsystems.
188 float voltage_intake;
189 float voltage_serializer;
190 float voltage_shooter;
191
192 // Rollers on the intake.
193 float voltage_intake_rollers;
194 // Roller on the serializer
195 float voltage_serializer_rollers;
196
197 float voltage_azimuth_turret;
198 float voltage_hood;
199 };
200
201 queue Goal goal;
202 queue Position position;
203 queue Output output;
204 queue Status status;
205};
206
207queue_group SuperstructureQueue superstructure_queue;