blob: fe471f12c753f0571114c92fe7926b4374c3802d [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
6struct JointStatus {
7 // Is the subsystem zeroed?
8 bool zeroed;
9
10 // The state of the subsystem, if applicable. -1 otherwise.
11 int32_t state;
12
13 // If true, we have aborted.
14 bool estopped;
15
16 // Position of the joint.
17 float position;
18 // Velocity of the joint in units/second.
19 float velocity;
20 // Profiled goal position of the joint.
21 float goal_position;
22 // Profiled goal velocity of the joint in units/second.
23 float goal_velocity;
24 // Unprofiled goal position from absoulte zero of the joint.
25 float unprofiled_goal_position;
26 // Unprofiled goal velocity of the joint in units/second.
27 float unprofiled_goal_velocity;
28
29 // The estimated disturbance torque.
30 float disturbance_torque;
31
32 // The calculated velocity with delta x/delta t
33 float calculated_velocity;
34
35 // Components of the control loop output
36 float position_power;
37 float velocity_power;
38 float feedforwards_power;
39
40 // State of the estimator.
41 .frc971.AbsoluteEstimatorState estimator_state;
42};
43
44struct IntakeGoal {
45 float roller_voltage;
46
47 // Goal angle in radians of the intake.
48 // Zero radians is where the intake is pointing straight out, with positive
49 // radians inward towards the cube.
50 double intake_angle;
51};
52
53struct ArmGoal {
54 // Target X distance (paralell to the ground) of the arm endpoint from the
55 // base of the proximal arm (connected to the drivetrain) in meters with
56 // positive meters towards the front of the robot.
57 double proximal_position;
58
59 // Target Y distance (perpendicular to the ground) of the arm endpoint from
60 // the base of the distal arm (connected to the proximal arm) in meters with
61 // positive meters towards the front of the robot.
62 double distal_position;
63};
64
65struct IntakeElasticEncoders {
66 // Values of the encoder connected to the motor end of the series elastic in
67 // radians.
68 .frc971.IndexPosition motor_encoder;
69
70 // Values of the encoder connected to the load end of the series elastic in
71 // radians.
72 .frc971.IndexPosition spring_encoder;
73};
74
75struct IntakePosition {
76 // False if the beam breaker isn't triggered, true if the beam breaker is
77 // triggered.
78 bool left_beam_breaker;
79
80 // False if the beam breaker isn't triggered, true if the beam breaker is
81 // triggered.
82 bool right_beam_breaker;
83
84 // Values of the series elastic encoders on the left side of the robot from
85 // the rear perspective in radians.
86 IntakeElasticEncoders left;
87
88 // Values of the series elastic encoders on the right side of the robot from
89 // the rear perspective in radians.
90 IntakeElasticEncoders right;
91};
92
93struct ArmPosition {
94 // Values of the encoder and potentiometer at the base of the proximal
95 // (connected to drivebase) arm in radians.
96 .frc971.PotAndIndexPosition proximal;
97
98 // Values of the encoder and potentiometer at the base of the distal
99 // (connected to proximal) arm in radians.
100 .frc971.PotAndIndexPosition distal;
101};
102
103struct ClawPosition {
104 // Value of the beam breaker sensor. This value is true if the beam is broken,
105 // false if the beam isn't broken.
106 bool beam_triggered;
107};
108
109struct IntakeVoltage {
110 // Voltage of the motors on the series elastic on one side (left or right) of
111 // the intake.
112 double voltage_elastic;
113
114 // Voltage of the rollers on one side (left or right) of the intake.
115 double voltage_rollers;
116};
117
118struct IntakeOutput {
119 // Voltage sent to the parts on the left side of the intake.
120 IntakeVoltage left;
121
122 // Voltage sent to the parts on the right side of the intake.
123 IntakeVoltage right;
124};
125
126
127queue_group SuperstructureQueue {
128 implements aos.control_loops.ControlLoop;
129
130 message Goal {
131 IntakeGoal intake;
132 ArmGoal arm;
133
134 bool open_claw;
135
136 bool deploy_fork;
137 };
138
139 message Status {
140 // Are all the subsystems zeroed?
141 bool zeroed;
142
143 // If true, any of the subsystems have aborted.
144 bool estopped;
145
146 // Estimated angles and angular velocities of the superstructure subsystems.
147 JointStatus arm;
148
149 JointStatus intake;
150
151 bool claw_open;
152 };
153
154 message Position {
155 IntakePosition intake;
156 ArmPosition arm;
157 ClawPosition claw;
158 };
159
160 message Output {
161 IntakeOutput intake;
162
163 // Placehodler for when we figure out how we are extending and retracting
164 // the fork tines.
165 bool tines_output;
166
167 // Placeholder for when we figure out how we are deploying and retracting
168 // the fork.
169 bool fork_output;
170
171 // Voltage sent to the motors on the proximal joint of the arm.
172 double voltage_proximal;
173
174 // Voltage sent to the motors on the distal joint of the arm.
175 double voltage_distal;
176
177 // Clamped (when true) or unclamped (when false) status sent to the
178 // pneumatic claw on the arm.
179 bool claw_output;
180 };
181
182 queue Goal goal;
183 queue Output output;
184 queue Status status;
185 queue Position position;
186};
187
188queue_group SuperstructureQueue superstructure_queue;