blob: 75900faca6479fdf23cecdd98a542b33906d96c4 [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 Davisfdd7a112018-02-04 16:16:23 -080016 // Estimated position of the joint.
Neil Balchd5206fe2018-01-24 20:25:12 -080017 float position;
Sabina Davisfdd7a112018-02-04 16:16:23 -080018 // Estimated velocity of the joint in units/second.
Neil Balchd5206fe2018-01-24 20:25:12 -080019 float velocity;
Neil Balchd5206fe2018-01-24 20:25:12 -080020
Sabina Davisfdd7a112018-02-04 16:16:23 -080021 // Goal position of the joint.
22 float goal_position;
23 // Goal velocity of the joint in units/second.
24 float goal_velocity;
Neil Balchd5206fe2018-01-24 20:25:12 -080025
26 // The calculated velocity with delta x/delta t
27 float calculated_velocity;
28
Neil Balchd5206fe2018-01-24 20:25:12 -080029 // State of the estimator.
30 .frc971.AbsoluteEstimatorState estimator_state;
31};
32
33struct IntakeGoal {
34 float roller_voltage;
35
36 // Goal angle in radians of the intake.
37 // Zero radians is where the intake is pointing straight out, with positive
38 // radians inward towards the cube.
Sabina Davisfdd7a112018-02-04 16:16:23 -080039 double left_intake_angle;
40 double right_intake_angle;
Neil Balchd5206fe2018-01-24 20:25:12 -080041};
42
Austin Schuh2a3e0632018-02-19 16:24:49 -080043struct IntakeElasticSensors {
Sabina Davisfdd7a112018-02-04 16:16:23 -080044 // Position of the motor end of the series elastic in radians.
Austin Schuh2a3e0632018-02-19 16:24:49 -080045 .frc971.PotAndAbsolutePosition motor_position;
Neil Balchd5206fe2018-01-24 20:25:12 -080046
Sabina Davisfdd7a112018-02-04 16:16:23 -080047 // Displacement of the spring in radians.
48 double spring_angle;
Austin Schuh2a3e0632018-02-19 16:24:49 -080049
50 // False if the beam break sensor isn't triggered, true if the beam breaker is
51 // triggered.
52 bool beam_break;
Neil Balchd5206fe2018-01-24 20:25:12 -080053};
54
55struct IntakePosition {
Neil Balchd5206fe2018-01-24 20:25:12 -080056 // Values of the series elastic encoders on the left side of the robot from
57 // the rear perspective in radians.
Austin Schuh2a3e0632018-02-19 16:24:49 -080058 IntakeElasticSensors left;
Neil Balchd5206fe2018-01-24 20:25:12 -080059
60 // Values of the series elastic encoders on the right side of the robot from
61 // the rear perspective in radians.
Austin Schuh2a3e0632018-02-19 16:24:49 -080062 IntakeElasticSensors right;
Neil Balchd5206fe2018-01-24 20:25:12 -080063};
64
Sabina Davisfdd7a112018-02-04 16:16:23 -080065struct ArmStatus {
66 // TODO(austin): Fill in more state once we know what it is.
67 // State of the estimators.
68 .frc971.AbsoluteEstimatorState proximal_estimator_state;
69 .frc971.AbsoluteEstimatorState distal_estimator_state;
70};
71
Neil Balchd5206fe2018-01-24 20:25:12 -080072struct ArmPosition {
73 // Values of the encoder and potentiometer at the base of the proximal
74 // (connected to drivebase) arm in radians.
Sabina Davisfdd7a112018-02-04 16:16:23 -080075 .frc971.PotAndAbsolutePosition proximal;
Neil Balchd5206fe2018-01-24 20:25:12 -080076
77 // Values of the encoder and potentiometer at the base of the distal
78 // (connected to proximal) arm in radians.
Sabina Davisfdd7a112018-02-04 16:16:23 -080079 .frc971.PotAndAbsolutePosition distal;
Neil Balchd5206fe2018-01-24 20:25:12 -080080};
81
82struct IntakeVoltage {
83 // Voltage of the motors on the series elastic on one side (left or right) of
84 // the intake.
85 double voltage_elastic;
86
87 // Voltage of the rollers on one side (left or right) of the intake.
88 double voltage_rollers;
89};
90
91struct IntakeOutput {
92 // Voltage sent to the parts on the left side of the intake.
93 IntakeVoltage left;
94
95 // Voltage sent to the parts on the right side of the intake.
96 IntakeVoltage right;
97};
98
99
100queue_group SuperstructureQueue {
101 implements aos.control_loops.ControlLoop;
102
103 message Goal {
104 IntakeGoal intake;
Sabina Davisfdd7a112018-02-04 16:16:23 -0800105
106 // Used to identiy a position in the planned set of positions on the arm.
107 int32_t arm_goal_position;
Neil Balchd5206fe2018-01-24 20:25:12 -0800108
109 bool open_claw;
110
111 bool deploy_fork;
112 };
113
114 message Status {
115 // Are all the subsystems zeroed?
116 bool zeroed;
117
118 // If true, any of the subsystems have aborted.
119 bool estopped;
120
Sabina Davisfdd7a112018-02-04 16:16:23 -0800121 // Status of both intake sides.
122 IntakeSideStatus left_intake;
123 IntakeSideStatus right_intake;
Neil Balchd5206fe2018-01-24 20:25:12 -0800124
Sabina Davisfdd7a112018-02-04 16:16:23 -0800125 ArmStatus arm;
Neil Balchd5206fe2018-01-24 20:25:12 -0800126 };
127
128 message Position {
129 IntakePosition intake;
130 ArmPosition arm;
Sabina Davisfdd7a112018-02-04 16:16:23 -0800131
132 // Value of the beam breaker sensor. This value is true if the beam is
133 // broken, false if the beam isn't broken.
134 bool claw_beambreak_triggered;
Neil Balchd5206fe2018-01-24 20:25:12 -0800135 };
136
137 message Output {
138 IntakeOutput intake;
139
Neil Balchd5206fe2018-01-24 20:25:12 -0800140 // Voltage sent to the motors on the proximal joint of the arm.
141 double voltage_proximal;
142
143 // Voltage sent to the motors on the distal joint of the arm.
144 double voltage_distal;
145
146 // Clamped (when true) or unclamped (when false) status sent to the
147 // pneumatic claw on the arm.
Austin Schuh2a3e0632018-02-19 16:24:49 -0800148 bool claw_grabbed;
149
150 // If true, release the arm brakes.
151 bool release_arm_brake;
152 // If true, release the hook
153 bool hook_release;
154 // If true, release the forks
155 bool forks_release;
Neil Balchd5206fe2018-01-24 20:25:12 -0800156 };
157
158 queue Goal goal;
159 queue Output output;
160 queue Status status;
161 queue Position position;
162};
163
164queue_group SuperstructureQueue superstructure_queue;