blob: 82f66b41e2bd2889ae0ea4f491b9891ba95c5c8c [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
43struct IntakeElasticEncoders {
Sabina Davisfdd7a112018-02-04 16:16:23 -080044 // Position of the motor end of the series elastic in radians.
Neil Balchd5206fe2018-01-24 20:25:12 -080045 .frc971.IndexPosition motor_encoder;
46
Sabina Davisfdd7a112018-02-04 16:16:23 -080047 // Displacement of the spring in radians.
48 double spring_angle;
Neil Balchd5206fe2018-01-24 20:25:12 -080049};
50
51struct IntakePosition {
52 // False if the beam breaker isn't triggered, true if the beam breaker is
53 // triggered.
54 bool left_beam_breaker;
55
56 // False if the beam breaker isn't triggered, true if the beam breaker is
57 // triggered.
58 bool right_beam_breaker;
59
60 // Values of the series elastic encoders on the left side of the robot from
61 // the rear perspective in radians.
62 IntakeElasticEncoders left;
63
64 // Values of the series elastic encoders on the right side of the robot from
65 // the rear perspective in radians.
66 IntakeElasticEncoders right;
67};
68
Sabina Davisfdd7a112018-02-04 16:16:23 -080069struct ArmStatus {
70 // TODO(austin): Fill in more state once we know what it is.
71 // State of the estimators.
72 .frc971.AbsoluteEstimatorState proximal_estimator_state;
73 .frc971.AbsoluteEstimatorState distal_estimator_state;
74};
75
Neil Balchd5206fe2018-01-24 20:25:12 -080076struct ArmPosition {
77 // Values of the encoder and potentiometer at the base of the proximal
78 // (connected to drivebase) arm in radians.
Sabina Davisfdd7a112018-02-04 16:16:23 -080079 .frc971.PotAndAbsolutePosition proximal;
Neil Balchd5206fe2018-01-24 20:25:12 -080080
81 // Values of the encoder and potentiometer at the base of the distal
82 // (connected to proximal) arm in radians.
Sabina Davisfdd7a112018-02-04 16:16:23 -080083 .frc971.PotAndAbsolutePosition distal;
Neil Balchd5206fe2018-01-24 20:25:12 -080084};
85
86struct IntakeVoltage {
87 // Voltage of the motors on the series elastic on one side (left or right) of
88 // the intake.
89 double voltage_elastic;
90
91 // Voltage of the rollers on one side (left or right) of the intake.
92 double voltage_rollers;
93};
94
95struct IntakeOutput {
96 // Voltage sent to the parts on the left side of the intake.
97 IntakeVoltage left;
98
99 // Voltage sent to the parts on the right side of the intake.
100 IntakeVoltage right;
101};
102
103
104queue_group SuperstructureQueue {
105 implements aos.control_loops.ControlLoop;
106
107 message Goal {
108 IntakeGoal intake;
Sabina Davisfdd7a112018-02-04 16:16:23 -0800109
110 // Used to identiy a position in the planned set of positions on the arm.
111 int32_t arm_goal_position;
Neil Balchd5206fe2018-01-24 20:25:12 -0800112
113 bool open_claw;
114
115 bool deploy_fork;
116 };
117
118 message Status {
119 // Are all the subsystems zeroed?
120 bool zeroed;
121
122 // If true, any of the subsystems have aborted.
123 bool estopped;
124
Sabina Davisfdd7a112018-02-04 16:16:23 -0800125 // Status of both intake sides.
126 IntakeSideStatus left_intake;
127 IntakeSideStatus right_intake;
Neil Balchd5206fe2018-01-24 20:25:12 -0800128
Sabina Davisfdd7a112018-02-04 16:16:23 -0800129 ArmStatus arm;
Neil Balchd5206fe2018-01-24 20:25:12 -0800130 };
131
132 message Position {
133 IntakePosition intake;
134 ArmPosition arm;
Sabina Davisfdd7a112018-02-04 16:16:23 -0800135
136 // Value of the beam breaker sensor. This value is true if the beam is
137 // broken, false if the beam isn't broken.
138 bool claw_beambreak_triggered;
Neil Balchd5206fe2018-01-24 20:25:12 -0800139 };
140
141 message Output {
142 IntakeOutput intake;
143
Neil Balchd5206fe2018-01-24 20:25:12 -0800144 // Voltage sent to the motors on the proximal joint of the arm.
145 double voltage_proximal;
146
147 // Voltage sent to the motors on the distal joint of the arm.
148 double voltage_distal;
149
150 // Clamped (when true) or unclamped (when false) status sent to the
151 // pneumatic claw on the arm.
152 bool claw_output;
153 };
154
155 queue Goal goal;
156 queue Output output;
157 queue Status status;
158 queue Position position;
159};
160
161queue_group SuperstructureQueue superstructure_queue;