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 | |
Daniel Petti | 4248d2e | 2015-02-21 10:37:04 -0800 | [diff] [blame] | 18 | // All angles are in radians with 0 sticking straight up. |
| 19 | // Rotating up and into the robot (towards the back |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 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 | |
Daniel Petti | 4248d2e | 2015-02-21 10:37:04 -0800 | [diff] [blame] | 23 | // Elevator heights are the vertical distance (in meters) from a defined zero. |
| 24 | // In this case, zero is where the portion of the carriage that Spencer |
| 25 | // removed lines up with the bolt. |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 26 | |
| 27 | message Goal { |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 28 | // Angle of the arm. |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 29 | double angle; |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 30 | // Height of the elevator. |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 31 | double height; |
| 32 | |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 33 | // Angular velocity of the arm. |
| 34 | double angular_velocity; |
| 35 | // Linear velocity of the elevator. |
| 36 | double velocity; |
| 37 | |
Philipp Schrader | 3e28141 | 2015-03-01 23:48:23 +0000 | [diff] [blame] | 38 | // Maximum arm profile angular velocity or 0 for the default. |
| 39 | double max_angular_velocity; |
| 40 | // Maximum elevator profile velocity or 0 for the default. |
| 41 | double max_velocity; |
| 42 | |
| 43 | // Maximum arm profile acceleration or 0 for the default. |
| 44 | double max_angular_acceleration; |
| 45 | // Maximum elevator profile acceleration or 0 for the default. |
| 46 | double max_acceleration; |
| 47 | |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 48 | // TODO(austin): Do I need acceleration here too? |
| 49 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 50 | GrabberPistons grabbers; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | message Position { |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 54 | PotAndIndexPair arm; |
| 55 | PotAndIndexPair elevator; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | message Status { |
| 59 | // Are both the arm and elevator zeroed? |
| 60 | bool zeroed; |
Daniel Petti | 4248d2e | 2015-02-21 10:37:04 -0800 | [diff] [blame] | 61 | |
Philipp Schrader | 3e28141 | 2015-03-01 23:48:23 +0000 | [diff] [blame] | 62 | // Estimated angle of the arm. |
Ben Fredrickson | 6b5ba79 | 2015-01-25 17:14:40 -0800 | [diff] [blame] | 63 | double angle; |
Philipp Schrader | 3e28141 | 2015-03-01 23:48:23 +0000 | [diff] [blame] | 64 | // Estimated angular velocity of the arm. |
| 65 | double angular_velocity; |
| 66 | // Estimated height of the elevator. |
Ben Fredrickson | 6b5ba79 | 2015-01-25 17:14:40 -0800 | [diff] [blame] | 67 | double height; |
Philipp Schrader | 3e28141 | 2015-03-01 23:48:23 +0000 | [diff] [blame] | 68 | // Estimated velocity of the elvator. |
| 69 | double velocity; |
Ben Fredrickson | 6b5ba79 | 2015-01-25 17:14:40 -0800 | [diff] [blame] | 70 | // state of the grabber pistons |
| 71 | GrabberPistons grabbers; |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 72 | |
Austin Schuh | 813b9af | 2015-03-08 18:46:58 -0700 | [diff] [blame^] | 73 | // Goal angle and velocity of the arm. |
Austin Schuh | 5e872c8 | 2015-02-17 22:59:08 -0800 | [diff] [blame] | 74 | double goal_angle; |
Philipp Schrader | 3e28141 | 2015-03-01 23:48:23 +0000 | [diff] [blame] | 75 | double goal_angular_velocity; |
Austin Schuh | 813b9af | 2015-03-08 18:46:58 -0700 | [diff] [blame^] | 76 | // Goal height and velocity of the elevator. |
Austin Schuh | 5e872c8 | 2015-02-17 22:59:08 -0800 | [diff] [blame] | 77 | double goal_height; |
Philipp Schrader | 3e28141 | 2015-03-01 23:48:23 +0000 | [diff] [blame] | 78 | double goal_velocity; |
Austin Schuh | 5e872c8 | 2015-02-17 22:59:08 -0800 | [diff] [blame] | 79 | |
Austin Schuh | 5ae4efd | 2015-02-15 23:34:22 -0800 | [diff] [blame] | 80 | // If true, we have aborted. |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 81 | bool estopped; |
Austin Schuh | 482a4e1 | 2015-02-14 22:43:43 -0800 | [diff] [blame] | 82 | |
| 83 | // The internal state of the state machine. |
| 84 | int32_t state; |
Austin Schuh | 9e37c32 | 2015-02-16 15:47:49 -0800 | [diff] [blame] | 85 | |
| 86 | EstimatorState left_elevator_state; |
| 87 | EstimatorState right_elevator_state; |
| 88 | EstimatorState left_arm_state; |
| 89 | EstimatorState right_arm_state; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | message Output { |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 93 | double left_arm; |
| 94 | double right_arm; |
| 95 | double left_elevator; |
| 96 | double right_elevator; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 97 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 98 | GrabberPistons grabbers; |
Daniel Petti | 663fef0 | 2015-01-22 21:43:00 -0800 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | queue Goal goal; |
| 102 | queue Position position; |
| 103 | queue Output output; |
| 104 | queue Status status; |
| 105 | }; |
Daniel Petti | 8bb86eb | 2015-01-26 17:09:58 -0800 | [diff] [blame] | 106 | |
Ben Fredrickson | 6b5ba79 | 2015-01-25 17:14:40 -0800 | [diff] [blame] | 107 | queue_group FridgeQueue fridge_queue; |