Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 1 | package y2018.control_loops; |
| 2 | |
| 3 | import "aos/common/controls/control_loops.q"; |
| 4 | import "frc971/control_loops/control_loops.q"; |
| 5 | |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 6 | struct IntakeSideStatus { |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 7 | // Is the subsystem zeroed? |
| 8 | bool zeroed; |
| 9 | |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 10 | // The state of the subsystem, if applicable. |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 11 | int32_t state; |
| 12 | |
| 13 | // If true, we have aborted. |
| 14 | bool estopped; |
| 15 | |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 16 | // Estimated position of the joint. |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 17 | float position; |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 18 | // Estimated velocity of the joint in units/second. |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 19 | float velocity; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 20 | |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 21 | // Goal position of the joint. |
| 22 | float goal_position; |
| 23 | // Goal velocity of the joint in units/second. |
| 24 | float goal_velocity; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 25 | |
| 26 | // The calculated velocity with delta x/delta t |
| 27 | float calculated_velocity; |
| 28 | |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 29 | // State of the estimator. |
| 30 | .frc971.AbsoluteEstimatorState estimator_state; |
| 31 | }; |
| 32 | |
| 33 | struct 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 Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 39 | double left_intake_angle; |
| 40 | double right_intake_angle; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | struct IntakeElasticEncoders { |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 44 | // Position of the motor end of the series elastic in radians. |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 45 | .frc971.IndexPosition motor_encoder; |
| 46 | |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 47 | // Displacement of the spring in radians. |
| 48 | double spring_angle; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | struct 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 Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 69 | struct 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 Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 76 | struct ArmPosition { |
| 77 | // Values of the encoder and potentiometer at the base of the proximal |
| 78 | // (connected to drivebase) arm in radians. |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 79 | .frc971.PotAndAbsolutePosition proximal; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 80 | |
| 81 | // Values of the encoder and potentiometer at the base of the distal |
| 82 | // (connected to proximal) arm in radians. |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 83 | .frc971.PotAndAbsolutePosition distal; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | struct 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 | |
| 95 | struct 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 | |
| 104 | queue_group SuperstructureQueue { |
| 105 | implements aos.control_loops.ControlLoop; |
| 106 | |
| 107 | message Goal { |
| 108 | IntakeGoal intake; |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 109 | |
| 110 | // Used to identiy a position in the planned set of positions on the arm. |
| 111 | int32_t arm_goal_position; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 112 | |
| 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 Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 125 | // Status of both intake sides. |
| 126 | IntakeSideStatus left_intake; |
| 127 | IntakeSideStatus right_intake; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 128 | |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 129 | ArmStatus arm; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | message Position { |
| 133 | IntakePosition intake; |
| 134 | ArmPosition arm; |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 135 | |
| 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 Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 139 | }; |
| 140 | |
| 141 | message Output { |
| 142 | IntakeOutput intake; |
| 143 | |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 144 | // 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 | |
| 161 | queue_group SuperstructureQueue superstructure_queue; |