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 | |
Austin Schuh | 2a3e063 | 2018-02-19 16:24:49 -0800 | [diff] [blame^] | 43 | struct IntakeElasticSensors { |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 44 | // Position of the motor end of the series elastic in radians. |
Austin Schuh | 2a3e063 | 2018-02-19 16:24:49 -0800 | [diff] [blame^] | 45 | .frc971.PotAndAbsolutePosition motor_position; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 46 | |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 47 | // Displacement of the spring in radians. |
| 48 | double spring_angle; |
Austin Schuh | 2a3e063 | 2018-02-19 16:24:49 -0800 | [diff] [blame^] | 49 | |
| 50 | // False if the beam break sensor isn't triggered, true if the beam breaker is |
| 51 | // triggered. |
| 52 | bool beam_break; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | struct IntakePosition { |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 56 | // Values of the series elastic encoders on the left side of the robot from |
| 57 | // the rear perspective in radians. |
Austin Schuh | 2a3e063 | 2018-02-19 16:24:49 -0800 | [diff] [blame^] | 58 | IntakeElasticSensors left; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 59 | |
| 60 | // Values of the series elastic encoders on the right side of the robot from |
| 61 | // the rear perspective in radians. |
Austin Schuh | 2a3e063 | 2018-02-19 16:24:49 -0800 | [diff] [blame^] | 62 | IntakeElasticSensors right; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 63 | }; |
| 64 | |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 65 | struct 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 Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 72 | struct ArmPosition { |
| 73 | // Values of the encoder and potentiometer at the base of the proximal |
| 74 | // (connected to drivebase) arm in radians. |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 75 | .frc971.PotAndAbsolutePosition proximal; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 76 | |
| 77 | // Values of the encoder and potentiometer at the base of the distal |
| 78 | // (connected to proximal) arm in radians. |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 79 | .frc971.PotAndAbsolutePosition distal; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | struct 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 | |
| 91 | struct 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 | |
| 100 | queue_group SuperstructureQueue { |
| 101 | implements aos.control_loops.ControlLoop; |
| 102 | |
| 103 | message Goal { |
| 104 | IntakeGoal intake; |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 105 | |
| 106 | // Used to identiy a position in the planned set of positions on the arm. |
| 107 | int32_t arm_goal_position; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 108 | |
| 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 Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 121 | // Status of both intake sides. |
| 122 | IntakeSideStatus left_intake; |
| 123 | IntakeSideStatus right_intake; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 124 | |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 125 | ArmStatus arm; |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | message Position { |
| 129 | IntakePosition intake; |
| 130 | ArmPosition arm; |
Sabina Davis | fdd7a11 | 2018-02-04 16:16:23 -0800 | [diff] [blame] | 131 | |
| 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 Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | message Output { |
| 138 | IntakeOutput intake; |
| 139 | |
Neil Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 140 | // 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 Schuh | 2a3e063 | 2018-02-19 16:24:49 -0800 | [diff] [blame^] | 148 | 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 Balch | d5206fe | 2018-01-24 20:25:12 -0800 | [diff] [blame] | 156 | }; |
| 157 | |
| 158 | queue Goal goal; |
| 159 | queue Output output; |
| 160 | queue Status status; |
| 161 | queue Position position; |
| 162 | }; |
| 163 | |
| 164 | queue_group SuperstructureQueue superstructure_queue; |