blob: bc83ff70c22107d2f75f4edb1b96aab50d6f8b56 [file] [log] [blame]
Brian Silvermand4417aa2014-01-18 12:45:12 -08001package frc971.control_loops;
2
Briana6553ed2014-04-02 21:26:46 -07003import "aos/common/controls/control_loops.q";
Brian Silvermanaae236a2014-02-17 01:49:39 -08004import "frc971/control_loops/control_loops.q";
Brian Silvermand4417aa2014-01-18 12:45:12 -08005
Ben Fredrickson9590d502014-02-16 06:19:12 +00006queue_group ShooterGroup {
Brian Silvermand4417aa2014-01-18 12:45:12 -08007 implements aos.control_loops.ControlLoop;
8
joe93778a62014-02-15 13:22:14 -08009 message Output {
joe93778a62014-02-15 13:22:14 -080010 double voltage;
Ben Fredrickson1f633ef2014-02-16 05:35:45 +000011 // true: latch engaged, false: latch open
12 bool latch_piston;
Austin Schuh60c56662014-02-17 14:37:19 -080013 // true: brake engaged false: brake released
Ben Fredrickson1f633ef2014-02-16 05:35:45 +000014 bool brake_piston;
joe93778a62014-02-15 13:22:14 -080015 };
Brian Silvermand4417aa2014-01-18 12:45:12 -080016 message Goal {
Austin Schuh60c56662014-02-17 14:37:19 -080017 // Shot power in joules.
Ben Fredrickson1e512ff2014-02-15 21:36:52 +000018 double shot_power;
Brian Silverman8c30bc12014-01-18 12:49:38 -080019 // Shoots as soon as this is true.
Ben Fredrickson1e512ff2014-02-15 21:36:52 +000020 bool shot_requested;
21 bool unload_requested;
Austin Schuh30537882014-02-18 01:07:23 -080022 bool load_requested;
Brian Silvermand4417aa2014-01-18 12:45:12 -080023 };
Austin Schuh60c56662014-02-17 14:37:19 -080024
25 // Back is when the springs are all the way stretched.
Brian Silvermand4417aa2014-01-18 12:45:12 -080026 message Position {
Austin Schuh30537882014-02-18 01:07:23 -080027 // In meters, out is positive.
28 double position;
29
Austin Schuh60c56662014-02-17 14:37:19 -080030 // If the latch piston is fired and this hall effect has been triggered, the
31 // plunger is all the way back and latched.
32 bool plunger;
Brian Silvermanaae236a2014-02-17 01:49:39 -080033 // Gets triggered when the pusher is all the way back.
Austin Schuh60c56662014-02-17 14:37:19 -080034 PosedgeOnlyCountedHallEffectStruct pusher_distal;
Brian Silvermanaae236a2014-02-17 01:49:39 -080035 // Triggers just before pusher_distal.
Austin Schuh60c56662014-02-17 14:37:19 -080036 PosedgeOnlyCountedHallEffectStruct pusher_proximal;
Brian Silvermanaae236a2014-02-17 01:49:39 -080037 // Triggers when the latch engages.
Austin Schuh60c56662014-02-17 14:37:19 -080038 bool latch;
Brian Silvermand4417aa2014-01-18 12:45:12 -080039 };
40 message Status {
Brian Silverman8c30bc12014-01-18 12:49:38 -080041 // Whether it's ready to shoot right now.
Brian Silvermand4417aa2014-01-18 12:45:12 -080042 bool ready;
Brian Silverman8c30bc12014-01-18 12:49:38 -080043 // Whether the plunger is in and out of the way of grabbing a ball.
James Kuszmaul4abaf482014-02-26 21:16:35 -080044 // TODO(ben): Populate these!
Brian Silverman8c30bc12014-01-18 12:49:38 -080045 bool cocked;
46 // How many times we've shot.
Ben Fredrickson1e512ff2014-02-15 21:36:52 +000047 int32_t shots;
joe93778a62014-02-15 13:22:14 -080048 bool done;
James Kuszmauld29689f2014-03-02 13:06:54 -080049 // What we think the current position of the hard stop on the shooter is, in
50 // shot power (Joules).
51 double hard_stop_power;
Brian Silvermand4417aa2014-01-18 12:45:12 -080052 };
53
54 queue Goal goal;
55 queue Position position;
joe93778a62014-02-15 13:22:14 -080056 queue Output output;
Brian Silvermand4417aa2014-01-18 12:45:12 -080057 queue Status status;
58};
59
Ben Fredrickson1e512ff2014-02-15 21:36:52 +000060queue_group ShooterGroup shooter_queue_group;
Brian Silvermanf48fab32014-03-09 14:32:24 -070061
62struct ShooterStateToLog {
63 double absolute_position;
64 double absolute_velocity;
65 uint32_t state;
66 bool latch_sensor;
67 bool proximal;
68 bool distal;
69 bool plunger;
70 bool brake;
71 bool latch_piston;
72};
73
74struct ShooterVoltageToLog {
75 double X_hat;
76 double applied;
77};
78
79struct ShooterMovingGoal {
80 double dx;
81};
82
83struct ShooterChangeCalibration {
84 double encoder;
85 double real_position;
86 double old_position;
87 double new_position;
88 double old_offset;
89 double new_offset;
90};
91
92struct ShooterStatusToLog {
93 double goal;
94 double position;
95};
Brian Silverman0ebe9442014-03-22 13:57:35 -070096
97struct PowerAdjustment {
98 double requested_power;
99 double actual_power;
100};