blob: f8fa16e6397b8f2da4a3d59b6f92dc07828af815 [file] [log] [blame]
Daniel Petti663fef02015-01-22 21:43:00 -08001package frc971.control_loops;
2
3import "aos/common/controls/control_loops.q";
Brian Silverman0a7f6062015-01-24 17:41:33 -05004import "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.
8struct GrabberPistons {
9 bool top_front;
10 bool top_back;
11 bool bottom_front;
12 bool bottom_back;
13};
Daniel Petti663fef02015-01-22 21:43:00 -080014
Ben Fredrickson6b5ba792015-01-25 17:14:40 -080015queue_group FridgeQueue {
Daniel Petti663fef02015-01-22 21:43:00 -080016 implements aos.control_loops.ControlLoop;
17
Daniel Petti4248d2e2015-02-21 10:37:04 -080018 // All angles are in radians with 0 sticking straight up.
19 // Rotating up and into the robot (towards the back
Brian Silverman0a7f6062015-01-24 17:41:33 -050020 // where boxes are placed) is positive. Positive output voltage moves all
21 // mechanisms in the direction with positive sensor values.
Daniel Petti663fef02015-01-22 21:43:00 -080022
Daniel Petti4248d2e2015-02-21 10:37:04 -080023 // 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 Petti663fef02015-01-22 21:43:00 -080026
27 message Goal {
Brian Silverman0a7f6062015-01-24 17:41:33 -050028 // Angle of the arm.
Daniel Petti663fef02015-01-22 21:43:00 -080029 double angle;
Brian Silverman0a7f6062015-01-24 17:41:33 -050030 // Height of the elevator.
Daniel Petti663fef02015-01-22 21:43:00 -080031 double height;
32
Austin Schuh703b8d42015-02-01 14:56:34 -080033 // Angular velocity of the arm.
34 double angular_velocity;
35 // Linear velocity of the elevator.
36 double velocity;
37
38 // TODO(austin): Do I need acceleration here too?
39
Brian Silverman0a7f6062015-01-24 17:41:33 -050040 GrabberPistons grabbers;
Daniel Petti663fef02015-01-22 21:43:00 -080041 };
42
43 message Position {
Brian Silverman0a7f6062015-01-24 17:41:33 -050044 PotAndIndexPair arm;
45 PotAndIndexPair elevator;
Daniel Petti663fef02015-01-22 21:43:00 -080046 };
47
48 message Status {
49 // Are both the arm and elevator zeroed?
50 bool zeroed;
Daniel Petti4248d2e2015-02-21 10:37:04 -080051
Ben Fredrickson6b5ba792015-01-25 17:14:40 -080052 // Angle of the arm.
53 double angle;
54 // Height of the elevator.
55 double height;
56 // state of the grabber pistons
57 GrabberPistons grabbers;
Austin Schuh703b8d42015-02-01 14:56:34 -080058
Austin Schuh5e872c82015-02-17 22:59:08 -080059 // Goal angle of the arm.
60 double goal_angle;
61 // Goal height of the elevator.
62 double goal_height;
63
Austin Schuh5ae4efd2015-02-15 23:34:22 -080064 // If true, we have aborted.
Austin Schuh703b8d42015-02-01 14:56:34 -080065 bool estopped;
Austin Schuh482a4e12015-02-14 22:43:43 -080066
67 // The internal state of the state machine.
68 int32_t state;
Austin Schuh9e37c322015-02-16 15:47:49 -080069
70 EstimatorState left_elevator_state;
71 EstimatorState right_elevator_state;
72 EstimatorState left_arm_state;
73 EstimatorState right_arm_state;
Daniel Petti663fef02015-01-22 21:43:00 -080074 };
75
76 message Output {
Brian Silverman0a7f6062015-01-24 17:41:33 -050077 double left_arm;
78 double right_arm;
79 double left_elevator;
80 double right_elevator;
Daniel Petti663fef02015-01-22 21:43:00 -080081
Brian Silverman0a7f6062015-01-24 17:41:33 -050082 GrabberPistons grabbers;
Daniel Petti663fef02015-01-22 21:43:00 -080083 };
84
85 queue Goal goal;
86 queue Position position;
87 queue Output output;
88 queue Status status;
89};
Daniel Petti8bb86eb2015-01-26 17:09:58 -080090
Ben Fredrickson6b5ba792015-01-25 17:14:40 -080091queue_group FridgeQueue fridge_queue;