blob: 4f854b715ddf21324fd8ecd6051c5a18356b7e8d [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 {
10 // Zero on the intake is when the intake is retracted inside the robot,
11 // unable to intake. Positive is out.
12
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
23struct SerializerGoal {
24 // Serializer angular velocity goals in radians/second.
25 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 {
41 // Angle the hood is currently at
Austin Schuh0991edb2017-02-05 17:16:44 -080042 double angle;
Campbell Crowley75026292017-02-04 21:46:19 -080043
44 // Caps on velocity/acceleration for profiling. 0 for the default.
45 .frc971.ProfileParameters profile_params;
46};
47
48struct ShooterGoal {
49 // Angular velocity goals in radians/second.
50 double angular_velocity;
51};
52
Campbell Crowley75026292017-02-04 21:46:19 -080053struct SerializerStatus {
54 // The current average velocity in radians/second.
55 double avg_angular_velocity;
56
57 // The current instantaneous filtered velocity in radians/second.
58 double angular_velocity;
59
60 // True if the serializer is ready. It is better to compare the velocities
61 // directly so there isn't confusion on if the goal is up to date.
62 bool ready;
63
64 // If true, we have aborted.
65 bool estopped;
66};
67
Campbell Crowley75026292017-02-04 21:46:19 -080068struct ShooterStatus {
69 // The current average velocity in radians/second.
70 double avg_angular_velocity;
71
72 // The current instantaneous filtered velocity in radians/second.
73 double angular_velocity;
74
75 // True if the shooter is ready. It is better to compare the velocities
76 // directly so there isn't confusion on if the goal is up to date.
77 bool ready;
78
79 // If true, we have aborted.
80 bool estopped;
81};
82
83queue_group SuperstructureQueue {
84 implements aos.control_loops.ControlLoop;
85
86 message Goal {
87 IntakeGoal intake;
88 SerializerGoal serializer;
89 TurretGoal turret;
90 HoodGoal hood;
91 ShooterGoal shooter;
92 };
93
94 message Status {
95 // Are all the subsystems zeroed?
96 bool zeroed;
97
98 // If true, we have aborted. This is the or of all subsystem estops.
99 bool estopped;
100
101 // Each subsystems status.
Austin Schuh3634ed32017-02-05 16:28:49 -0800102 .frc971.control_loops.ProfiledJointStatus intake;
103 .frc971.control_loops.ProfiledJointStatus turret;
104 .frc971.control_loops.ProfiledJointStatus hood;
Campbell Crowley75026292017-02-04 21:46:19 -0800105 SerializerStatus serializer;
Campbell Crowley75026292017-02-04 21:46:19 -0800106 ShooterStatus shooter;
107 };
108
109 message Position {
Austin Schuh0991edb2017-02-05 17:16:44 -0800110 // TODO(austin): The turret and intake really should be absolute. Switch
111 // them over when that class is ready.
112
Campbell Crowley75026292017-02-04 21:46:19 -0800113 // Position of the intake, zero when the intake is in, positive when it is
114 // out.
Austin Schuh0991edb2017-02-05 17:16:44 -0800115 .frc971.PotAndIndexPosition intake;
Campbell Crowley75026292017-02-04 21:46:19 -0800116
117 // Serializer angle in radians.
118 double theta_serializer;
119
Campbell Crowley065a0812017-02-04 22:27:17 -0800120 // The sensor readings for the turret. The units and sign are defined the
Campbell Crowley75026292017-02-04 21:46:19 -0800121 // same as what's in the Goal message.
Austin Schuh0991edb2017-02-05 17:16:44 -0800122 .frc971.PotAndIndexPosition turret;
Campbell Crowley75026292017-02-04 21:46:19 -0800123
Austin Schuh0991edb2017-02-05 17:16:44 -0800124 // The sensor readings for the hood. The units and sign are defined the
125 // same as what's in the Goal message.
126 .frc971.PotAndIndexPosition hood;
Campbell Crowley75026292017-02-04 21:46:19 -0800127
128 // Shooter wheel angle in radians.
129 double theta_shooter;
130 };
131
132 message Output {
133 // Voltages for some of the subsystems.
Austin Schuh0991edb2017-02-05 17:16:44 -0800134 double voltage_intake;
135 double voltage_serializer;
136 double voltage_shooter;
Campbell Crowley75026292017-02-04 21:46:19 -0800137
138 // Rollers on the intake.
Austin Schuh0991edb2017-02-05 17:16:44 -0800139 double voltage_intake_rollers;
Campbell Crowley75026292017-02-04 21:46:19 -0800140 // Roller on the serializer
Austin Schuh0991edb2017-02-05 17:16:44 -0800141 double voltage_serializer_rollers;
Campbell Crowley75026292017-02-04 21:46:19 -0800142
Austin Schuh0991edb2017-02-05 17:16:44 -0800143 double voltage_turret;
144 double voltage_hood;
Campbell Crowley75026292017-02-04 21:46:19 -0800145 };
146
147 queue Goal goal;
148 queue Position position;
149 queue Output output;
150 queue Status status;
151};
152
153queue_group SuperstructureQueue superstructure_queue;