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