Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 1 | package frc971.control_loops; |
| 2 | |
| 3 | import "aos/common/controls/control_loops.q"; |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 4 | import "frc971/control_loops/control_loops.q"; |
| 5 | |
| 6 | // Represents states for all of the box-grabbing pistons. |
| 7 | // true is grabbed and false is retracted for all of them. |
| 8 | struct GrabberPistons { |
| 9 | bool top_front; |
| 10 | bool top_back; |
| 11 | bool bottom_front; |
| 12 | bool bottom_back; |
| 13 | }; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 14 | |
Ben Fredrickson | 6b5ba79 | 2015-01-25 17:14:40 -0800 | [diff] [blame] | 15 | queue_group FridgeQueue { |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 16 | implements aos.control_loops.ControlLoop; |
| 17 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 18 | // All angles are in radians with 0 sticking straight out horizontally over |
| 19 | // the intake (the front). Rotating up and into the robot (towards the back |
| 20 | // where boxes are placed) is positive. Positive output voltage moves all |
| 21 | // mechanisms in the direction with positive sensor values. |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 22 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 23 | // Elevator heights are the vertical distance (in meters) from the top of the |
| 24 | // frame (at the front and back) to the axis of the bottom pivot of the arm. |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 25 | |
| 26 | message Goal { |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 27 | // Angle of the arm. |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 28 | double angle; |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 29 | // Height of the elevator. |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 30 | double height; |
| 31 | |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 32 | // Angular velocity of the arm. |
| 33 | double angular_velocity; |
| 34 | // Linear velocity of the elevator. |
| 35 | double velocity; |
| 36 | |
| 37 | // TODO(austin): Do I need acceleration here too? |
| 38 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 39 | GrabberPistons grabbers; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | message Position { |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 43 | PotAndIndexPair arm; |
| 44 | PotAndIndexPair elevator; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | message Status { |
| 48 | // Are both the arm and elevator zeroed? |
| 49 | bool zeroed; |
| 50 | // Are we zeroed and have reached our goal position on both the arm and |
| 51 | // elevator? |
| 52 | bool done; |
Ben Fredrickson | 6b5ba79 | 2015-01-25 17:14:40 -0800 | [diff] [blame] | 53 | |
| 54 | // Angle of the arm. |
| 55 | double angle; |
| 56 | // Height of the elevator. |
| 57 | double height; |
| 58 | // state of the grabber pistons |
| 59 | GrabberPistons grabbers; |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 60 | |
| 61 | // TODO(austin): Internal state. |
| 62 | bool estopped; |
Austin Schuh | 482a4e1 | 2015-02-14 22:43:43 -0800 | [diff] [blame] | 63 | |
| 64 | // The internal state of the state machine. |
| 65 | int32_t state; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | message Output { |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 69 | double left_arm; |
| 70 | double right_arm; |
| 71 | double left_elevator; |
| 72 | double right_elevator; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 73 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 74 | GrabberPistons grabbers; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | queue Goal goal; |
| 78 | queue Position position; |
| 79 | queue Output output; |
| 80 | queue Status status; |
| 81 | }; |
Daniel Petti | 8bb86eb | 2015-01-26 17:09:58 -0800 | [diff] [blame] | 82 | |
Ben Fredrickson | 6b5ba79 | 2015-01-25 17:14:40 -0800 | [diff] [blame] | 83 | queue_group FridgeQueue fridge_queue; |