blob: be54ee7a76a8282ffccd73c634938fde2347c1df [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
Brian Silverman0a7f6062015-01-24 17:41:33 -050018 // 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 Petti663fef02015-01-22 21:43:00 -080022
Brian Silverman0a7f6062015-01-24 17:41:33 -050023 // 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 Petti663fef02015-01-22 21:43:00 -080025
26 message Goal {
Brian Silverman0a7f6062015-01-24 17:41:33 -050027 // Angle of the arm.
Daniel Petti663fef02015-01-22 21:43:00 -080028 double angle;
Brian Silverman0a7f6062015-01-24 17:41:33 -050029 // Height of the elevator.
Daniel Petti663fef02015-01-22 21:43:00 -080030 double height;
31
Austin Schuh703b8d42015-02-01 14:56:34 -080032 // 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 Silverman0a7f6062015-01-24 17:41:33 -050039 GrabberPistons grabbers;
Daniel Petti663fef02015-01-22 21:43:00 -080040 };
41
42 message Position {
Brian Silverman0a7f6062015-01-24 17:41:33 -050043 PotAndIndexPair arm;
44 PotAndIndexPair elevator;
Daniel Petti663fef02015-01-22 21:43:00 -080045 };
46
47 message Status {
48 // Are both the arm and elevator zeroed?
49 bool zeroed;
Ben Fredrickson6b5ba792015-01-25 17:14:40 -080050
51 // Angle of the arm.
52 double angle;
53 // Height of the elevator.
54 double height;
55 // state of the grabber pistons
56 GrabberPistons grabbers;
Austin Schuh703b8d42015-02-01 14:56:34 -080057
Austin Schuh5e872c82015-02-17 22:59:08 -080058 // Goal angle of the arm.
59 double goal_angle;
60 // Goal height of the elevator.
61 double goal_height;
62
Austin Schuh5ae4efd2015-02-15 23:34:22 -080063 // If true, we have aborted.
Austin Schuh703b8d42015-02-01 14:56:34 -080064 bool estopped;
Austin Schuh482a4e12015-02-14 22:43:43 -080065
66 // The internal state of the state machine.
67 int32_t state;
Austin Schuh9e37c322015-02-16 15:47:49 -080068
69 EstimatorState left_elevator_state;
70 EstimatorState right_elevator_state;
71 EstimatorState left_arm_state;
72 EstimatorState right_arm_state;
Daniel Petti663fef02015-01-22 21:43:00 -080073 };
74
75 message Output {
Brian Silverman0a7f6062015-01-24 17:41:33 -050076 double left_arm;
77 double right_arm;
78 double left_elevator;
79 double right_elevator;
Daniel Petti663fef02015-01-22 21:43:00 -080080
Brian Silverman0a7f6062015-01-24 17:41:33 -050081 GrabberPistons grabbers;
Daniel Petti663fef02015-01-22 21:43:00 -080082 };
83
84 queue Goal goal;
85 queue Position position;
86 queue Output output;
87 queue Status status;
88};
Daniel Petti8bb86eb2015-01-26 17:09:58 -080089
Ben Fredrickson6b5ba792015-01-25 17:14:40 -080090queue_group FridgeQueue fridge_queue;