Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 1 | package y2019.control_loops.superstructure; |
| 2 | |
| 3 | import "aos/controls/control_loops.q"; |
| 4 | import "frc971/control_loops/profiled_subsystem.q"; |
| 5 | |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 6 | struct SuctionGoal { |
| 7 | // True = open solenoid (apply suction) |
| 8 | // Top/bottom are when wrist is forward |
| 9 | bool top; |
| 10 | bool bottom; |
| 11 | }; |
| 12 | |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 13 | queue_group SuperstructureQueue { |
| 14 | implements aos.control_loops.ControlLoop; |
| 15 | |
| 16 | message Goal { |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 17 | // Meters, 0 = lowest position - mechanical hard stop, |
| 18 | // positive = upward |
| 19 | .frc971.control_loops.StaticZeroingSingleDOFProfiledSubsystemGoal elevator; |
| 20 | // 0 = linkage on the sprocket is pointing straight up, |
| 21 | // positive = forward |
| 22 | .frc971.control_loops.StaticZeroingSingleDOFProfiledSubsystemGoal intake; |
| 23 | // 0 = Straight up parallel to elevator |
| 24 | // Positive rotates toward intake from 0 |
| 25 | .frc971.control_loops.StaticZeroingSingleDOFProfiledSubsystemGoal wrist; |
| 26 | |
| 27 | // Distance stilts extended out of the bottom of the robot. Positive = down. |
| 28 | // 0 is the height such that the bottom of the stilts is tangent to the bottom |
| 29 | // of the middle wheels. |
| 30 | .frc971.control_loops.StaticZeroingSingleDOFProfiledSubsystemGoal stilts; |
| 31 | |
| 32 | // Positive is rollers intaking inward. |
| 33 | double roller_voltage; |
| 34 | |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 35 | SuctionGoal suction; |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | message Status { |
| 39 | // All subsystems know their location. |
| 40 | bool zeroed; |
| 41 | |
| 42 | // If true, we have aborted. This is the or of all subsystem estops. |
| 43 | bool estopped; |
| 44 | |
| 45 | // Whether suction_pressure indicates cargo is held |
| 46 | bool has_piece; |
| 47 | |
| 48 | // Status of each subsystem. |
Tyler Chatow | 9867cd7 | 2019-02-09 21:46:01 -0800 | [diff] [blame] | 49 | .frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus elevator; |
| 50 | .frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus wrist; |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 51 | .frc971.control_loops.AbsoluteEncoderProfiledJointStatus intake; |
Tyler Chatow | 9867cd7 | 2019-02-09 21:46:01 -0800 | [diff] [blame] | 52 | .frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus stilts; |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | message Position { |
| 56 | // Input from pressure sensor in psi |
| 57 | // 0 = current atmospheric pressure, negative = suction. |
| 58 | double suction_pressure; |
| 59 | |
| 60 | // Position of the elevator, 0 at lowest position, positive when up. |
| 61 | .frc971.PotAndAbsolutePosition elevator; |
| 62 | |
| 63 | // Position of wrist, 0 when up, positive is rotating toward the front, |
| 64 | // over the top. |
| 65 | .frc971.PotAndAbsolutePosition wrist; |
| 66 | |
| 67 | // Position of the intake. 0 when rollers are retracted, positive extended. |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 68 | .frc971.AbsolutePosition intake_joint; |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 69 | |
| 70 | // Position of the stilts, 0 when retracted (defualt), positive lifts robot. |
| 71 | .frc971.PotAndAbsolutePosition stilts; |
| 72 | }; |
| 73 | |
| 74 | message Output { |
| 75 | // Voltage sent to motors moving elevator up/down. Positive is up. |
| 76 | double elevator_voltage; |
| 77 | |
| 78 | // Voltage sent to wrist motors on elevator to rotate. |
| 79 | // Positive rotates over the top towards the front of the robot. |
| 80 | double wrist_voltage; |
| 81 | |
| 82 | // Voltage sent to motors on intake joint. Positive extends rollers. |
| 83 | double intake_joint_voltage; |
| 84 | |
| 85 | // Voltage sent to rollers on intake. Positive rolls inward. |
| 86 | double intake_roller_voltage; |
| 87 | |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 88 | // Voltage sent to motors to move stilts height. Positive moves robot |
| 89 | // upward. |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 90 | double stilts_voltage; |
| 91 | |
| 92 | // True opens solenoid (applies suction) |
| 93 | // Top/bottom are when wrist is toward the front of the robot |
| 94 | bool intake_suction_top; |
| 95 | bool intake_suction_bottom; |
| 96 | |
| 97 | // Voltage sent to the vacuum pump motors. |
| 98 | double pump_voltage; |
| 99 | }; |
| 100 | |
| 101 | queue Goal goal; |
| 102 | queue Output output; |
| 103 | queue Status status; |
| 104 | queue Position position; |
| 105 | }; |
| 106 | |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 107 | queue_group SuperstructureQueue superstructure_queue; |