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