blob: 9df30e337af93e665f32bbec734382b359d87654 [file] [log] [blame]
Austin Schuh88af0852016-12-04 20:31:32 -08001package y2015.control_loops.fridge;
Daniel Petti663fef02015-01-22 21:43:00 -08002
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
Philipp Schrader085bf012015-03-15 01:43:11 +000027 // X/Y positions are distances (in meters) the fridge is away from its origin
28 // position. Origin is considered at a height of zero and an angle of zero.
29 // Positive X positions are towards the front of the robot and negative X is
30 // towards the back of the robot (which is where we score).
31 // Y is positive going up and negative when it goes below the origin.
32
Daniel Petti663fef02015-01-22 21:43:00 -080033 message Goal {
Philipp Schrader085bf012015-03-15 01:43:11 +000034 // Profile type.
35 // Set to 0 for angle/height profiling.
36 // Set to 1 for x/y profiling.
37 int32_t profiling_type;
38
Brian Silverman0a7f6062015-01-24 17:41:33 -050039 // Angle of the arm.
Daniel Petti663fef02015-01-22 21:43:00 -080040 double angle;
Brian Silverman0a7f6062015-01-24 17:41:33 -050041 // Height of the elevator.
Daniel Petti663fef02015-01-22 21:43:00 -080042 double height;
43
Austin Schuh703b8d42015-02-01 14:56:34 -080044 // Angular velocity of the arm.
Brian Silvermanbb799712015-03-29 16:14:01 -040045 float angular_velocity;
Austin Schuh703b8d42015-02-01 14:56:34 -080046 // Linear velocity of the elevator.
Brian Silvermanbb799712015-03-29 16:14:01 -040047 float velocity;
Austin Schuh703b8d42015-02-01 14:56:34 -080048
Philipp Schrader3e281412015-03-01 23:48:23 +000049 // Maximum arm profile angular velocity or 0 for the default.
Brian Silvermanbb799712015-03-29 16:14:01 -040050 float max_angular_velocity;
Philipp Schrader3e281412015-03-01 23:48:23 +000051 // Maximum elevator profile velocity or 0 for the default.
Brian Silvermanbb799712015-03-29 16:14:01 -040052 float max_velocity;
Philipp Schrader3e281412015-03-01 23:48:23 +000053
54 // Maximum arm profile acceleration or 0 for the default.
Brian Silvermanbb799712015-03-29 16:14:01 -040055 float max_angular_acceleration;
Philipp Schrader3e281412015-03-01 23:48:23 +000056 // Maximum elevator profile acceleration or 0 for the default.
Brian Silvermanbb799712015-03-29 16:14:01 -040057 float max_acceleration;
Philipp Schrader3e281412015-03-01 23:48:23 +000058
Philipp Schrader085bf012015-03-15 01:43:11 +000059 // X position of the fridge.
60 double x;
61 // Y position of the fridge.
62 double y;
63
64 // Velocity of the x position of the fridge.
Brian Silvermanbb799712015-03-29 16:14:01 -040065 float x_velocity;
Philipp Schrader085bf012015-03-15 01:43:11 +000066 // Velocity of the y position of the fridge.
Brian Silvermanbb799712015-03-29 16:14:01 -040067 float y_velocity;
Philipp Schrader085bf012015-03-15 01:43:11 +000068
69 // Maximum x profile velocity or 0 for the default.
Brian Silvermanbb799712015-03-29 16:14:01 -040070 float max_x_velocity;
Philipp Schrader085bf012015-03-15 01:43:11 +000071 // Maximum y profile velocity or 0 for the default.
Brian Silvermanbb799712015-03-29 16:14:01 -040072 float max_y_velocity;
Philipp Schrader085bf012015-03-15 01:43:11 +000073
74 // Maximum x profile acceleration or 0 for the default.
Brian Silvermanbb799712015-03-29 16:14:01 -040075 float max_x_acceleration;
Philipp Schrader085bf012015-03-15 01:43:11 +000076 // Maximum y profile acceleration or 0 for the default.
Brian Silvermanbb799712015-03-29 16:14:01 -040077 float max_y_acceleration;
Philipp Schrader085bf012015-03-15 01:43:11 +000078
Austin Schuh703b8d42015-02-01 14:56:34 -080079 // TODO(austin): Do I need acceleration here too?
80
Brian Silverman0a7f6062015-01-24 17:41:33 -050081 GrabberPistons grabbers;
Daniel Petti663fef02015-01-22 21:43:00 -080082 };
83
84 message Position {
Austin Schuh88af0852016-12-04 20:31:32 -080085 .frc971.PotAndIndexPair arm;
86 .frc971.PotAndIndexPair elevator;
Daniel Petti663fef02015-01-22 21:43:00 -080087 };
88
89 message Status {
90 // Are both the arm and elevator zeroed?
91 bool zeroed;
Daniel Petti4248d2e2015-02-21 10:37:04 -080092
Philipp Schrader3e281412015-03-01 23:48:23 +000093 // Estimated angle of the arm.
Ben Fredrickson6b5ba792015-01-25 17:14:40 -080094 double angle;
Philipp Schrader3e281412015-03-01 23:48:23 +000095 // Estimated angular velocity of the arm.
Brian Silvermanbb799712015-03-29 16:14:01 -040096 float angular_velocity;
Philipp Schrader3e281412015-03-01 23:48:23 +000097 // Estimated height of the elevator.
Ben Fredrickson6b5ba792015-01-25 17:14:40 -080098 double height;
Philipp Schrader3e281412015-03-01 23:48:23 +000099 // Estimated velocity of the elvator.
Brian Silvermanbb799712015-03-29 16:14:01 -0400100 float velocity;
Ben Fredrickson6b5ba792015-01-25 17:14:40 -0800101 // state of the grabber pistons
102 GrabberPistons grabbers;
Austin Schuh703b8d42015-02-01 14:56:34 -0800103
Austin Schuh813b9af2015-03-08 18:46:58 -0700104 // Goal angle and velocity of the arm.
Austin Schuh5e872c82015-02-17 22:59:08 -0800105 double goal_angle;
Brian Silvermanbb799712015-03-29 16:14:01 -0400106 float goal_angular_velocity;
Austin Schuh813b9af2015-03-08 18:46:58 -0700107 // Goal height and velocity of the elevator.
Austin Schuh5e872c82015-02-17 22:59:08 -0800108 double goal_height;
Brian Silvermanbb799712015-03-29 16:14:01 -0400109 float goal_velocity;
Austin Schuh5e872c82015-02-17 22:59:08 -0800110
Philipp Schrader2a25b612015-03-28 23:49:06 +0000111 // Estimated X/Y position of the fridge.
112 // These are translated directly from the height/angle statuses.
113 double x;
114 double y;
Brian Silvermanbb799712015-03-29 16:14:01 -0400115 float x_velocity;
116 float y_velocity;
Philipp Schrader2a25b612015-03-28 23:49:06 +0000117
118 // X/Y goals of the fridge.
119 // These are translated directly from the height/angle goals.
120 double goal_x;
121 double goal_y;
Brian Silvermanbb799712015-03-29 16:14:01 -0400122 float goal_x_velocity;
123 float goal_y_velocity;
Philipp Schrader2a25b612015-03-28 23:49:06 +0000124
Austin Schuh5ae4efd2015-02-15 23:34:22 -0800125 // If true, we have aborted.
Austin Schuh703b8d42015-02-01 14:56:34 -0800126 bool estopped;
Austin Schuh482a4e12015-02-14 22:43:43 -0800127
128 // The internal state of the state machine.
129 int32_t state;
Austin Schuh9e37c322015-02-16 15:47:49 -0800130
Austin Schuh88af0852016-12-04 20:31:32 -0800131 .frc971.EstimatorState left_elevator_state;
132 .frc971.EstimatorState right_elevator_state;
133 .frc971.EstimatorState left_arm_state;
134 .frc971.EstimatorState right_arm_state;
Daniel Petti663fef02015-01-22 21:43:00 -0800135 };
136
137 message Output {
Brian Silverman0a7f6062015-01-24 17:41:33 -0500138 double left_arm;
139 double right_arm;
140 double left_elevator;
141 double right_elevator;
Daniel Petti663fef02015-01-22 21:43:00 -0800142
Brian Silverman0a7f6062015-01-24 17:41:33 -0500143 GrabberPistons grabbers;
Daniel Petti663fef02015-01-22 21:43:00 -0800144 };
145
146 queue Goal goal;
147 queue Position position;
148 queue Output output;
149 queue Status status;
150};
Daniel Petti8bb86eb2015-01-26 17:09:58 -0800151
Ben Fredrickson6b5ba792015-01-25 17:14:40 -0800152queue_group FridgeQueue fridge_queue;