Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 1 | package frc971.control_loops; |
| 2 | |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 3 | import "aos/common/control_loop/control_loops.q"; |
Brian Silverman | aae236a | 2014-02-17 01:49:39 -0800 | [diff] [blame] | 4 | import "frc971/control_loops/control_loops.q"; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 5 | |
Ben Fredrickson | 9590d50 | 2014-02-16 06:19:12 +0000 | [diff] [blame] | 6 | queue_group ShooterGroup { |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 7 | implements aos.control_loops.ControlLoop; |
| 8 | |
joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 9 | message Output { |
joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 10 | double voltage; |
Ben Fredrickson | 1f633ef | 2014-02-16 05:35:45 +0000 | [diff] [blame] | 11 | // true: latch engaged, false: latch open |
| 12 | bool latch_piston; |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame] | 13 | // true: brake engaged false: brake released |
Ben Fredrickson | 1f633ef | 2014-02-16 05:35:45 +0000 | [diff] [blame] | 14 | bool brake_piston; |
joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 15 | }; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 16 | message Goal { |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame] | 17 | // Shot power in joules. |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 18 | double shot_power; |
Brian Silverman | 8c30bc1 | 2014-01-18 12:49:38 -0800 | [diff] [blame] | 19 | // Shoots as soon as this is true. |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 20 | bool shot_requested; |
| 21 | bool unload_requested; |
Austin Schuh | 3053788 | 2014-02-18 01:07:23 -0800 | [diff] [blame] | 22 | bool load_requested; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 23 | }; |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame] | 24 | |
| 25 | // Back is when the springs are all the way stretched. |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 26 | message Position { |
Austin Schuh | 3053788 | 2014-02-18 01:07:23 -0800 | [diff] [blame] | 27 | // In meters, out is positive. |
| 28 | double position; |
| 29 | |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame] | 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; |
Brian Silverman | aae236a | 2014-02-17 01:49:39 -0800 | [diff] [blame] | 33 | // Gets triggered when the pusher is all the way back. |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame] | 34 | PosedgeOnlyCountedHallEffectStruct pusher_distal; |
Brian Silverman | aae236a | 2014-02-17 01:49:39 -0800 | [diff] [blame] | 35 | // Triggers just before pusher_distal. |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame] | 36 | PosedgeOnlyCountedHallEffectStruct pusher_proximal; |
Brian Silverman | aae236a | 2014-02-17 01:49:39 -0800 | [diff] [blame] | 37 | // Triggers when the latch engages. |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame] | 38 | bool latch; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 39 | }; |
| 40 | message Status { |
Brian Silverman | 8c30bc1 | 2014-01-18 12:49:38 -0800 | [diff] [blame] | 41 | // Whether it's ready to shoot right now. |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 42 | bool ready; |
Brian Silverman | 8c30bc1 | 2014-01-18 12:49:38 -0800 | [diff] [blame] | 43 | // Whether the plunger is in and out of the way of grabbing a ball. |
James Kuszmaul | 4abaf48 | 2014-02-26 21:16:35 -0800 | [diff] [blame] | 44 | // TODO(ben): Populate these! |
Brian Silverman | 8c30bc1 | 2014-01-18 12:49:38 -0800 | [diff] [blame] | 45 | bool cocked; |
| 46 | // How many times we've shot. |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 47 | int32_t shots; |
joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 48 | bool done; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | queue Goal goal; |
| 52 | queue Position position; |
joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 53 | queue Output output; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 54 | queue Status status; |
| 55 | }; |
| 56 | |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 57 | queue_group ShooterGroup shooter_queue_group; |