blob: 3eaeb7ea1105fe1f891c2707f8576cb129029049 [file] [log] [blame]
Neil Balchd5206fe2018-01-24 20:25:12 -08001package y2018.control_loops;
2
3import "aos/common/controls/control_loops.q";
4import "frc971/control_loops/control_loops.q";
5
Sabina Davisfdd7a112018-02-04 16:16:23 -08006struct IntakeSideStatus {
Neil Balchd5206fe2018-01-24 20:25:12 -08007 // Is the subsystem zeroed?
8 bool zeroed;
9
Sabina Davisfdd7a112018-02-04 16:16:23 -080010 // The state of the subsystem, if applicable.
Neil Balchd5206fe2018-01-24 20:25:12 -080011 int32_t state;
12
13 // If true, we have aborted.
14 bool estopped;
15
Sabina Davis8d20ca82018-02-19 13:17:45 -080016 // Estimated position of the spring.
17 float spring_position;
18 // Estimated velocity of the spring in units/second.
19 float spring_velocity;
20
Sabina Davisfdd7a112018-02-04 16:16:23 -080021 // Estimated position of the joint.
Sabina Davis8d20ca82018-02-19 13:17:45 -080022 float motor_position;
Sabina Davisfdd7a112018-02-04 16:16:23 -080023 // Estimated velocity of the joint in units/second.
Sabina Davis8d20ca82018-02-19 13:17:45 -080024 float motor_velocity;
Neil Balchd5206fe2018-01-24 20:25:12 -080025
Sabina Davisfdd7a112018-02-04 16:16:23 -080026 // Goal position of the joint.
27 float goal_position;
28 // Goal velocity of the joint in units/second.
29 float goal_velocity;
Neil Balchd5206fe2018-01-24 20:25:12 -080030
31 // The calculated velocity with delta x/delta t
32 float calculated_velocity;
33
Sabina Davis8d20ca82018-02-19 13:17:45 -080034 // The voltage given last cycle;
35 float delayed_voltage;
36
Neil Balchd5206fe2018-01-24 20:25:12 -080037 // State of the estimator.
38 .frc971.AbsoluteEstimatorState estimator_state;
39};
40
41struct IntakeGoal {
Sabina Davis8d20ca82018-02-19 13:17:45 -080042 double roller_voltage;
Neil Balchd5206fe2018-01-24 20:25:12 -080043
44 // Goal angle in radians of the intake.
45 // Zero radians is where the intake is pointing straight out, with positive
46 // radians inward towards the cube.
Sabina Davisfdd7a112018-02-04 16:16:23 -080047 double left_intake_angle;
48 double right_intake_angle;
Neil Balchd5206fe2018-01-24 20:25:12 -080049};
50
Austin Schuh2a3e0632018-02-19 16:24:49 -080051struct IntakeElasticSensors {
Sabina Davisfdd7a112018-02-04 16:16:23 -080052 // Position of the motor end of the series elastic in radians.
Austin Schuh2a3e0632018-02-19 16:24:49 -080053 .frc971.PotAndAbsolutePosition motor_position;
Neil Balchd5206fe2018-01-24 20:25:12 -080054
Sabina Davisfdd7a112018-02-04 16:16:23 -080055 // Displacement of the spring in radians.
56 double spring_angle;
Austin Schuh2a3e0632018-02-19 16:24:49 -080057
58 // False if the beam break sensor isn't triggered, true if the beam breaker is
59 // triggered.
60 bool beam_break;
Neil Balchd5206fe2018-01-24 20:25:12 -080061};
62
63struct IntakePosition {
Neil Balchd5206fe2018-01-24 20:25:12 -080064 // Values of the series elastic encoders on the left side of the robot from
65 // the rear perspective in radians.
Austin Schuh2a3e0632018-02-19 16:24:49 -080066 IntakeElasticSensors left;
Neil Balchd5206fe2018-01-24 20:25:12 -080067
68 // Values of the series elastic encoders on the right side of the robot from
69 // the rear perspective in radians.
Austin Schuh2a3e0632018-02-19 16:24:49 -080070 IntakeElasticSensors right;
Neil Balchd5206fe2018-01-24 20:25:12 -080071};
72
Sabina Davisfdd7a112018-02-04 16:16:23 -080073struct ArmStatus {
74 // TODO(austin): Fill in more state once we know what it is.
75 // State of the estimators.
76 .frc971.AbsoluteEstimatorState proximal_estimator_state;
77 .frc971.AbsoluteEstimatorState distal_estimator_state;
78};
79
Neil Balchd5206fe2018-01-24 20:25:12 -080080struct ArmPosition {
81 // Values of the encoder and potentiometer at the base of the proximal
82 // (connected to drivebase) arm in radians.
Sabina Davisfdd7a112018-02-04 16:16:23 -080083 .frc971.PotAndAbsolutePosition proximal;
Neil Balchd5206fe2018-01-24 20:25:12 -080084
85 // Values of the encoder and potentiometer at the base of the distal
86 // (connected to proximal) arm in radians.
Sabina Davisfdd7a112018-02-04 16:16:23 -080087 .frc971.PotAndAbsolutePosition distal;
Neil Balchd5206fe2018-01-24 20:25:12 -080088};
89
90struct IntakeVoltage {
91 // Voltage of the motors on the series elastic on one side (left or right) of
92 // the intake.
93 double voltage_elastic;
94
95 // Voltage of the rollers on one side (left or right) of the intake.
96 double voltage_rollers;
97};
98
99struct IntakeOutput {
100 // Voltage sent to the parts on the left side of the intake.
101 IntakeVoltage left;
102
103 // Voltage sent to the parts on the right side of the intake.
104 IntakeVoltage right;
105};
106
107
108queue_group SuperstructureQueue {
109 implements aos.control_loops.ControlLoop;
110
111 message Goal {
112 IntakeGoal intake;
Sabina Davisfdd7a112018-02-04 16:16:23 -0800113
114 // Used to identiy a position in the planned set of positions on the arm.
115 int32_t arm_goal_position;
Neil Balchd5206fe2018-01-24 20:25:12 -0800116
117 bool open_claw;
118
119 bool deploy_fork;
120 };
121
122 message Status {
123 // Are all the subsystems zeroed?
124 bool zeroed;
125
126 // If true, any of the subsystems have aborted.
127 bool estopped;
128
Sabina Davisfdd7a112018-02-04 16:16:23 -0800129 // Status of both intake sides.
130 IntakeSideStatus left_intake;
131 IntakeSideStatus right_intake;
Neil Balchd5206fe2018-01-24 20:25:12 -0800132
Sabina Davisfdd7a112018-02-04 16:16:23 -0800133 ArmStatus arm;
Neil Balchd5206fe2018-01-24 20:25:12 -0800134 };
135
136 message Position {
137 IntakePosition intake;
138 ArmPosition arm;
Sabina Davisfdd7a112018-02-04 16:16:23 -0800139
140 // Value of the beam breaker sensor. This value is true if the beam is
141 // broken, false if the beam isn't broken.
142 bool claw_beambreak_triggered;
Neil Balchd5206fe2018-01-24 20:25:12 -0800143 };
144
145 message Output {
146 IntakeOutput intake;
147
Neil Balchd5206fe2018-01-24 20:25:12 -0800148 // Voltage sent to the motors on the proximal joint of the arm.
149 double voltage_proximal;
150
151 // Voltage sent to the motors on the distal joint of the arm.
152 double voltage_distal;
153
154 // Clamped (when true) or unclamped (when false) status sent to the
155 // pneumatic claw on the arm.
Austin Schuh2a3e0632018-02-19 16:24:49 -0800156 bool claw_grabbed;
157
158 // If true, release the arm brakes.
159 bool release_arm_brake;
160 // If true, release the hook
161 bool hook_release;
162 // If true, release the forks
163 bool forks_release;
Neil Balchd5206fe2018-01-24 20:25:12 -0800164 };
165
166 queue Goal goal;
167 queue Output output;
168 queue Status status;
169 queue Position position;
170};
171
172queue_group SuperstructureQueue superstructure_queue;