blob: b1e63bb913690a46d6c875d1fb9edba26fa82fe2 [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 {
Ed Jordan8683f432017-02-12 00:13:26 +000041 // Angle the hood is currently at. An angle of zero hood is at the lower soft stop, angle
42 // 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 {
50 // Angular velocity goals in radians/second.
51 double angular_velocity;
52};
53
Campbell Crowley75026292017-02-04 21:46:19 -080054struct SerializerStatus {
55 // The current average velocity in radians/second.
56 double avg_angular_velocity;
57
58 // The current instantaneous filtered velocity in radians/second.
59 double angular_velocity;
60
61 // True if the serializer is ready. It is better to compare the velocities
62 // directly so there isn't confusion on if the goal is up to date.
63 bool ready;
64
65 // If true, we have aborted.
66 bool estopped;
67};
68
Campbell Crowley75026292017-02-04 21:46:19 -080069struct ShooterStatus {
70 // The current average velocity in radians/second.
71 double avg_angular_velocity;
72
73 // The current instantaneous filtered velocity in radians/second.
74 double angular_velocity;
75
76 // True if the shooter is ready. It is better to compare the velocities
77 // directly so there isn't confusion on if the goal is up to date.
78 bool ready;
79
80 // If true, we have aborted.
81 bool estopped;
82};
83
84queue_group SuperstructureQueue {
85 implements aos.control_loops.ControlLoop;
86
87 message Goal {
88 IntakeGoal intake;
89 SerializerGoal serializer;
90 TurretGoal turret;
91 HoodGoal hood;
92 ShooterGoal shooter;
93 };
94
95 message Status {
96 // Are all the subsystems zeroed?
97 bool zeroed;
98
99 // If true, we have aborted. This is the or of all subsystem estops.
100 bool estopped;
101
102 // Each subsystems status.
Austin Schuh3634ed32017-02-05 16:28:49 -0800103 .frc971.control_loops.ProfiledJointStatus intake;
104 .frc971.control_loops.ProfiledJointStatus turret;
105 .frc971.control_loops.ProfiledJointStatus hood;
Campbell Crowley75026292017-02-04 21:46:19 -0800106 SerializerStatus serializer;
Campbell Crowley75026292017-02-04 21:46:19 -0800107 ShooterStatus shooter;
108 };
109
110 message Position {
Austin Schuh0991edb2017-02-05 17:16:44 -0800111 // TODO(austin): The turret and intake really should be absolute. Switch
112 // them over when that class is ready.
113
Campbell Crowley75026292017-02-04 21:46:19 -0800114 // Position of the intake, zero when the intake is in, positive when it is
115 // out.
Austin Schuh0991edb2017-02-05 17:16:44 -0800116 .frc971.PotAndIndexPosition intake;
Campbell Crowley75026292017-02-04 21:46:19 -0800117
118 // Serializer angle in radians.
119 double theta_serializer;
120
Campbell Crowley065a0812017-02-04 22:27:17 -0800121 // The sensor readings for the turret. The units and sign are defined the
Campbell Crowley75026292017-02-04 21:46:19 -0800122 // same as what's in the Goal message.
Austin Schuh0991edb2017-02-05 17:16:44 -0800123 .frc971.PotAndIndexPosition turret;
Campbell Crowley75026292017-02-04 21:46:19 -0800124
Austin Schuh0991edb2017-02-05 17:16:44 -0800125 // The sensor readings for the hood. The units and sign are defined the
126 // same as what's in the Goal message.
127 .frc971.PotAndIndexPosition hood;
Campbell Crowley75026292017-02-04 21:46:19 -0800128
129 // Shooter wheel angle in radians.
130 double theta_shooter;
131 };
132
133 message Output {
134 // Voltages for some of the subsystems.
Austin Schuh0991edb2017-02-05 17:16:44 -0800135 double voltage_intake;
136 double voltage_serializer;
137 double voltage_shooter;
Campbell Crowley75026292017-02-04 21:46:19 -0800138
139 // Rollers on the intake.
Austin Schuh0991edb2017-02-05 17:16:44 -0800140 double voltage_intake_rollers;
Campbell Crowley75026292017-02-04 21:46:19 -0800141 // Roller on the serializer
Austin Schuh0991edb2017-02-05 17:16:44 -0800142 double voltage_serializer_rollers;
Campbell Crowley75026292017-02-04 21:46:19 -0800143
Austin Schuh0991edb2017-02-05 17:16:44 -0800144 double voltage_turret;
145 double voltage_hood;
Campbell Crowley75026292017-02-04 21:46:19 -0800146 };
147
148 queue Goal goal;
149 queue Position position;
150 queue Output output;
151 queue Status status;
152};
153
154queue_group SuperstructureQueue superstructure_queue;