blob: 23379212a695ebdcd9dbd82ab81ec99e894bd253 [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
Philipp Schrader3e281412015-03-01 23:48:23 +000038 // 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 Schuh703b8d42015-02-01 14:56:34 -080048 // TODO(austin): Do I need acceleration here too?
49
Brian Silverman0a7f6062015-01-24 17:41:33 -050050 GrabberPistons grabbers;
Daniel Petti663fef02015-01-22 21:43:00 -080051 };
52
53 message Position {
Brian Silverman0a7f6062015-01-24 17:41:33 -050054 PotAndIndexPair arm;
55 PotAndIndexPair elevator;
Daniel Petti663fef02015-01-22 21:43:00 -080056 };
57
58 message Status {
59 // Are both the arm and elevator zeroed?
60 bool zeroed;
Daniel Petti4248d2e2015-02-21 10:37:04 -080061
Philipp Schrader3e281412015-03-01 23:48:23 +000062 // Estimated angle of the arm.
Ben Fredrickson6b5ba792015-01-25 17:14:40 -080063 double angle;
Philipp Schrader3e281412015-03-01 23:48:23 +000064 // Estimated angular velocity of the arm.
65 double angular_velocity;
66 // Estimated height of the elevator.
Ben Fredrickson6b5ba792015-01-25 17:14:40 -080067 double height;
Philipp Schrader3e281412015-03-01 23:48:23 +000068 // Estimated velocity of the elvator.
69 double velocity;
Ben Fredrickson6b5ba792015-01-25 17:14:40 -080070 // state of the grabber pistons
71 GrabberPistons grabbers;
Austin Schuh703b8d42015-02-01 14:56:34 -080072
Austin Schuh813b9af2015-03-08 18:46:58 -070073 // Goal angle and velocity of the arm.
Austin Schuh5e872c82015-02-17 22:59:08 -080074 double goal_angle;
Philipp Schrader3e281412015-03-01 23:48:23 +000075 double goal_angular_velocity;
Austin Schuh813b9af2015-03-08 18:46:58 -070076 // Goal height and velocity of the elevator.
Austin Schuh5e872c82015-02-17 22:59:08 -080077 double goal_height;
Philipp Schrader3e281412015-03-01 23:48:23 +000078 double goal_velocity;
Austin Schuh5e872c82015-02-17 22:59:08 -080079
Austin Schuh5ae4efd2015-02-15 23:34:22 -080080 // If true, we have aborted.
Austin Schuh703b8d42015-02-01 14:56:34 -080081 bool estopped;
Austin Schuh482a4e12015-02-14 22:43:43 -080082
83 // The internal state of the state machine.
84 int32_t state;
Austin Schuh9e37c322015-02-16 15:47:49 -080085
86 EstimatorState left_elevator_state;
87 EstimatorState right_elevator_state;
88 EstimatorState left_arm_state;
89 EstimatorState right_arm_state;
Daniel Petti663fef02015-01-22 21:43:00 -080090 };
91
92 message Output {
Brian Silverman0a7f6062015-01-24 17:41:33 -050093 double left_arm;
94 double right_arm;
95 double left_elevator;
96 double right_elevator;
Daniel Petti663fef02015-01-22 21:43:00 -080097
Brian Silverman0a7f6062015-01-24 17:41:33 -050098 GrabberPistons grabbers;
Daniel Petti663fef02015-01-22 21:43:00 -080099 };
100
101 queue Goal goal;
102 queue Position position;
103 queue Output output;
104 queue Status status;
105};
Daniel Petti8bb86eb2015-01-26 17:09:58 -0800106
Ben Fredrickson6b5ba792015-01-25 17:14:40 -0800107queue_group FridgeQueue fridge_queue;