Comran Morshed | 25f81a0 | 2016-01-23 13:40:10 +0000 | [diff] [blame] | 1 | package y2016.control_loops; |
| 2 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 3 | import "aos/controls/control_loops.q"; |
Comran Morshed | 25f81a0 | 2016-01-23 13:40:10 +0000 | [diff] [blame] | 4 | import "frc971/control_loops/control_loops.q"; |
| 5 | |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 6 | struct JointState { |
| 7 | // Angle of the joint in radians. |
Austin Schuh | 39fd610 | 2016-02-13 22:59:48 -0800 | [diff] [blame] | 8 | float angle; |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 9 | // Angular velocity of the joint in radians/second. |
| 10 | float angular_velocity; |
| 11 | // Profiled goal angle of the joint in radians. |
Austin Schuh | 39fd610 | 2016-02-13 22:59:48 -0800 | [diff] [blame] | 12 | float goal_angle; |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 13 | // Profiled goal angular velocity of the joint in radians/second. |
Austin Schuh | 39fd610 | 2016-02-13 22:59:48 -0800 | [diff] [blame] | 14 | float goal_angular_velocity; |
| 15 | // Unprofiled goal angle of the joint in radians. |
| 16 | float unprofiled_goal_angle; |
| 17 | // Unprofiled goal angular velocity of the joint in radians/second. |
| 18 | float unprofiled_goal_angular_velocity; |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 19 | |
Austin Schuh | be04115 | 2016-02-28 22:01:52 -0800 | [diff] [blame] | 20 | // The estimated voltage error. |
| 21 | float voltage_error; |
| 22 | |
| 23 | // The calculated velocity with delta x/delta t |
| 24 | float calculated_velocity; |
| 25 | |
| 26 | // Components of the control loop output |
| 27 | float position_power; |
| 28 | float velocity_power; |
| 29 | float feedforwards_power; |
| 30 | |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 31 | // State of the estimator. |
| 32 | .frc971.EstimatorState estimator_state; |
| 33 | }; |
| 34 | |
Austin Schuh | 9481d0d | 2019-06-29 21:56:17 -0700 | [diff] [blame] | 35 | // Published on ".y2016.control_loops.superstructure_queue" |
Comran Morshed | 25f81a0 | 2016-01-23 13:40:10 +0000 | [diff] [blame] | 36 | queue_group SuperstructureQueue { |
| 37 | implements aos.control_loops.ControlLoop; |
| 38 | |
| 39 | message Goal { |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 40 | // Zero on the intake is when the horizontal tube stock members are level |
Austin Schuh | 009b93e | 2017-02-05 23:22:19 -0800 | [diff] [blame] | 41 | // with the top frame rails of the robot. This will be essentially when we |
| 42 | // are in the intaking position. Positive is up. The angle is measured |
| 43 | // relative to the top |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 44 | // of the robot frame. |
Austin Schuh | 009b93e | 2017-02-05 23:22:19 -0800 | [diff] [blame] | 45 | // Zero on the shoulder is when the shoulder is down against the hard stop |
| 46 | // blocks. Positive is up. The angle is measured relative to the top of |
| 47 | // the robot frame. |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 48 | // Zero on the wrist is horizontal and landed in the bellypan. Positive is |
Austin Schuh | 5551b07 | 2016-02-15 14:06:36 -0800 | [diff] [blame] | 49 | // the same direction as the shoulder. The angle is measured relative to |
Austin Schuh | 009b93e | 2017-02-05 23:22:19 -0800 | [diff] [blame] | 50 | // the top of the robot frame. For calibration, 0 is measured as parallel |
| 51 | // to the big frame supporting the shooter. |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 52 | |
| 53 | // Goal angles and angular velocities of the superstructure subsystems. |
| 54 | double angle_intake; |
| 55 | double angle_shoulder; |
| 56 | // In relation to the ground plane. |
| 57 | double angle_wrist; |
| 58 | |
| 59 | // Caps on velocity/acceleration for profiling. 0 for the default. |
| 60 | float max_angular_velocity_intake; |
| 61 | float max_angular_velocity_shoulder; |
| 62 | float max_angular_velocity_wrist; |
| 63 | |
| 64 | float max_angular_acceleration_intake; |
| 65 | float max_angular_acceleration_shoulder; |
| 66 | float max_angular_acceleration_wrist; |
Comran Morshed | f4cd764 | 2016-02-15 20:40:49 +0000 | [diff] [blame] | 67 | |
| 68 | // Voltage to send to the rollers. Positive is sucking in. |
Campbell Crowley | d4fd655 | 2016-02-21 17:53:46 -0800 | [diff] [blame] | 69 | float voltage_top_rollers; |
| 70 | float voltage_bottom_rollers; |
Austin Schuh | 843412b | 2016-03-20 16:48:46 -0700 | [diff] [blame] | 71 | |
Comran Morshed | 71466fe | 2016-04-21 20:21:14 -0700 | [diff] [blame] | 72 | // Voltage to sent to the climber. Positive is pulling the robot up. |
| 73 | float voltage_climber; |
| 74 | // If true, unlatch the climber and allow it to unfold. |
| 75 | bool unfold_climber; |
| 76 | |
Austin Schuh | 1defd26 | 2016-04-03 16:13:32 -0700 | [diff] [blame] | 77 | bool force_intake; |
| 78 | |
Austin Schuh | 843412b | 2016-03-20 16:48:46 -0700 | [diff] [blame] | 79 | // If true, release the latch which holds the traverse mechanism in the |
| 80 | // middle. |
| 81 | bool traverse_unlatched; |
| 82 | // If true, fire the traverse mechanism down. |
| 83 | bool traverse_down; |
Comran Morshed | 25f81a0 | 2016-01-23 13:40:10 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | message Status { |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 87 | // Are the superstructure subsystems zeroed? |
| 88 | bool zeroed; |
| 89 | |
| 90 | // If true, we have aborted. |
| 91 | bool estopped; |
| 92 | |
| 93 | // The internal state of the state machine. |
| 94 | int32_t state; |
| 95 | |
| 96 | |
| 97 | // Estimated angles and angular velocities of the superstructure subsystems. |
| 98 | JointState intake; |
| 99 | JointState shoulder; |
| 100 | JointState wrist; |
Austin Schuh | f59b6bc | 2016-03-11 21:26:19 -0800 | [diff] [blame] | 101 | |
| 102 | int32_t shoulder_controller_index; |
Austin Schuh | 5b1a4cd | 2016-03-11 21:28:38 -0800 | [diff] [blame] | 103 | |
| 104 | // Is the superstructure collided? |
| 105 | bool is_collided; |
Comran Morshed | 25f81a0 | 2016-01-23 13:40:10 +0000 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | message Position { |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 109 | // Zero for the intake potentiometer value is horizontal, and positive is |
| 110 | // up. |
| 111 | // Zero for the shoulder potentiometer value is horizontal, and positive is |
| 112 | // up. |
| 113 | // Zero for the wrist potentiometer value is parallel to the arm and with |
| 114 | // the shooter wheels pointed towards the shoulder joint. This is measured |
| 115 | // relative to the arm, not the ground, not like the world we actually |
| 116 | // present to users. |
| 117 | .frc971.PotAndIndexPosition intake; |
| 118 | .frc971.PotAndIndexPosition shoulder; |
| 119 | .frc971.PotAndIndexPosition wrist; |
| 120 | }; |
| 121 | |
| 122 | message Output { |
Austin Schuh | 39fd610 | 2016-02-13 22:59:48 -0800 | [diff] [blame] | 123 | float voltage_intake; |
| 124 | float voltage_shoulder; |
| 125 | float voltage_wrist; |
Comran Morshed | f4cd764 | 2016-02-15 20:40:49 +0000 | [diff] [blame] | 126 | |
Campbell Crowley | d4fd655 | 2016-02-21 17:53:46 -0800 | [diff] [blame] | 127 | float voltage_top_rollers; |
| 128 | float voltage_bottom_rollers; |
Austin Schuh | 843412b | 2016-03-20 16:48:46 -0700 | [diff] [blame] | 129 | |
Comran Morshed | 71466fe | 2016-04-21 20:21:14 -0700 | [diff] [blame] | 130 | // Voltage to sent to the climber. Positive is pulling the robot up. |
| 131 | float voltage_climber; |
| 132 | // If true, release the latch to trigger the climber to unfold. |
| 133 | bool unfold_climber; |
| 134 | |
Austin Schuh | 843412b | 2016-03-20 16:48:46 -0700 | [diff] [blame] | 135 | // If true, release the latch to hold the traverse mechanism in the middle. |
| 136 | bool traverse_unlatched; |
| 137 | // If true, fire the traverse mechanism down. |
| 138 | bool traverse_down; |
Comran Morshed | 25f81a0 | 2016-01-23 13:40:10 +0000 | [diff] [blame] | 139 | }; |
| 140 | |
| 141 | queue Goal goal; |
| 142 | queue Position position; |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 143 | queue Output output; |
Comran Morshed | 25f81a0 | 2016-01-23 13:40:10 +0000 | [diff] [blame] | 144 | queue Status status; |
| 145 | }; |