blob: ab8f590a9a0ca32c795955376e11e93ca59fd124 [file] [log] [blame]
Brian Silvermanb601d892015-12-20 18:24:38 -05001package y2014.control_loops;
Brian Silverman17f503e2015-08-02 18:17:18 -07002
3import "aos/common/controls/control_loops.q";
4import "frc971/control_loops/control_loops.q";
5
Brian Silvermanbe5ded62015-05-14 00:23:49 -04006queue_group ShooterQueue {
Brian Silverman17f503e2015-08-02 18:17:18 -07007 implements aos.control_loops.ControlLoop;
8
9 message Output {
10 double voltage;
11 // true: latch engaged, false: latch open
12 bool latch_piston;
13 // true: brake engaged false: brake released
14 bool brake_piston;
15 };
16 message Goal {
17 // Shot power in joules.
18 double shot_power;
19 // Shoots as soon as this is true.
20 bool shot_requested;
21 bool unload_requested;
22 bool load_requested;
23 };
24
25 // Back is when the springs are all the way stretched.
26 message Position {
27 // In meters, out is positive.
28 double position;
29
30 // 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;
33 // Gets triggered when the pusher is all the way back.
Brian Silvermanb601d892015-12-20 18:24:38 -050034 .frc971.PosedgeOnlyCountedHallEffectStruct pusher_distal;
Brian Silverman17f503e2015-08-02 18:17:18 -070035 // Triggers just before pusher_distal.
Brian Silvermanb601d892015-12-20 18:24:38 -050036 .frc971.PosedgeOnlyCountedHallEffectStruct pusher_proximal;
Brian Silverman17f503e2015-08-02 18:17:18 -070037 // Triggers when the latch engages.
38 bool latch;
39 };
40 message Status {
41 // Whether it's ready to shoot right now.
42 bool ready;
43 // Whether the plunger is in and out of the way of grabbing a ball.
44 // TODO(ben): Populate these!
45 bool cocked;
46 // How many times we've shot.
47 int32_t shots;
48 bool done;
49 // What we think the current position of the hard stop on the shooter is, in
50 // shot power (Joules).
51 double hard_stop_power;
Austin Schuhadf2cde2015-11-08 20:35:16 -080052
53 double absolute_position;
54 double absolute_velocity;
55 uint32_t state;
Brian Silverman17f503e2015-08-02 18:17:18 -070056 };
57
58 queue Goal goal;
59 queue Position position;
60 queue Output output;
61 queue Status status;
62};
63
Brian Silvermanbe5ded62015-05-14 00:23:49 -040064queue_group ShooterQueue shooter_queue;
Brian Silverman17f503e2015-08-02 18:17:18 -070065
66struct ShooterStateToLog {
67 double absolute_position;
68 double absolute_velocity;
69 uint32_t state;
70 bool latch_sensor;
71 bool proximal;
72 bool distal;
73 bool plunger;
74 bool brake;
75 bool latch_piston;
76};
77
78struct ShooterVoltageToLog {
79 double X_hat;
80 double applied;
81};
82
83struct ShooterMovingGoal {
84 double dx;
85};
86
87struct ShooterChangeCalibration {
88 double encoder;
89 double real_position;
90 double old_position;
91 double new_position;
92 double old_offset;
93 double new_offset;
94};
95
96struct ShooterStatusToLog {
97 double goal;
98 double position;
99};
100
101struct PowerAdjustment {
102 double requested_power;
103 double actual_power;
104};