blob: e8105d60a56c40a5581e10dcb8d5361dc048a8fc [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 Schuh5ae4efd2015-02-15 23:34:22 -080058 // If true, we have aborted.
Austin Schuh703b8d42015-02-01 14:56:34 -080059 bool estopped;
Austin Schuh482a4e12015-02-14 22:43:43 -080060
61 // The internal state of the state machine.
62 int32_t state;
Daniel Petti663fef02015-01-22 21:43:00 -080063 };
64
65 message Output {
Brian Silverman0a7f6062015-01-24 17:41:33 -050066 double left_arm;
67 double right_arm;
68 double left_elevator;
69 double right_elevator;
Daniel Petti663fef02015-01-22 21:43:00 -080070
Brian Silverman0a7f6062015-01-24 17:41:33 -050071 GrabberPistons grabbers;
Daniel Petti663fef02015-01-22 21:43:00 -080072 };
73
74 queue Goal goal;
75 queue Position position;
76 queue Output output;
77 queue Status status;
78};
Daniel Petti8bb86eb2015-01-26 17:09:58 -080079
Ben Fredrickson6b5ba792015-01-25 17:14:40 -080080queue_group FridgeQueue fridge_queue;