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