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 | |
Austin Schuh | 9e37c32 | 2015-02-16 15:47:49 -0800 | [diff] [blame^] | 15 | // The internal state of the zeroing estimator. |
| 16 | struct EstimatorState { |
| 17 | // If true, there has been a fatal error for the estimator. |
| 18 | bool error; |
| 19 | // If the joint has seen an index pulse and is zeroed. |
| 20 | bool zeroed; |
| 21 | // The estimated position of the joint. |
| 22 | double position; |
| 23 | }; |
| 24 | |
Ben Fredrickson | 6b5ba79 | 2015-01-25 17:14:40 -0800 | [diff] [blame] | 25 | queue_group FridgeQueue { |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 26 | implements aos.control_loops.ControlLoop; |
| 27 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 28 | // All angles are in radians with 0 sticking straight out horizontally over |
| 29 | // the intake (the front). Rotating up and into the robot (towards the back |
| 30 | // where boxes are placed) is positive. Positive output voltage moves all |
| 31 | // mechanisms in the direction with positive sensor values. |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 32 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 33 | // Elevator heights are the vertical distance (in meters) from the top of the |
| 34 | // 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] | 35 | |
| 36 | message Goal { |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 37 | // Angle of the arm. |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 38 | double angle; |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 39 | // Height of the elevator. |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 40 | double height; |
| 41 | |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 42 | // Angular velocity of the arm. |
| 43 | double angular_velocity; |
| 44 | // Linear velocity of the elevator. |
| 45 | double velocity; |
| 46 | |
| 47 | // TODO(austin): Do I need acceleration here too? |
| 48 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 49 | GrabberPistons grabbers; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | message Position { |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 53 | PotAndIndexPair arm; |
| 54 | PotAndIndexPair elevator; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | message Status { |
| 58 | // Are both the arm and elevator zeroed? |
| 59 | bool zeroed; |
Ben Fredrickson | 6b5ba79 | 2015-01-25 17:14:40 -0800 | [diff] [blame] | 60 | |
| 61 | // Angle of the arm. |
| 62 | double angle; |
| 63 | // Height of the elevator. |
| 64 | double height; |
| 65 | // state of the grabber pistons |
| 66 | GrabberPistons grabbers; |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 67 | |
Austin Schuh | 5ae4efd | 2015-02-15 23:34:22 -0800 | [diff] [blame] | 68 | // If true, we have aborted. |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 69 | bool estopped; |
Austin Schuh | 482a4e1 | 2015-02-14 22:43:43 -0800 | [diff] [blame] | 70 | |
| 71 | // The internal state of the state machine. |
| 72 | int32_t state; |
Austin Schuh | 9e37c32 | 2015-02-16 15:47:49 -0800 | [diff] [blame^] | 73 | |
| 74 | EstimatorState left_elevator_state; |
| 75 | EstimatorState right_elevator_state; |
| 76 | EstimatorState left_arm_state; |
| 77 | EstimatorState right_arm_state; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | message Output { |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 81 | double left_arm; |
| 82 | double right_arm; |
| 83 | double left_elevator; |
| 84 | double right_elevator; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 85 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 86 | GrabberPistons grabbers; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | queue Goal goal; |
| 90 | queue Position position; |
| 91 | queue Output output; |
| 92 | queue Status status; |
| 93 | }; |
Daniel Petti | 8bb86eb | 2015-01-26 17:09:58 -0800 | [diff] [blame] | 94 | |
Ben Fredrickson | 6b5ba79 | 2015-01-25 17:14:40 -0800 | [diff] [blame] | 95 | queue_group FridgeQueue fridge_queue; |