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; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 22 | }; |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame^] | 23 | |
| 24 | // Back is when the springs are all the way stretched. |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 25 | message Position { |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame^] | 26 | // If the latch piston is fired and this hall effect has been triggered, the |
| 27 | // plunger is all the way back and latched. |
| 28 | bool plunger; |
Brian Silverman | aae236a | 2014-02-17 01:49:39 -0800 | [diff] [blame] | 29 | // Gets triggered when the pusher is all the way back. |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame^] | 30 | PosedgeOnlyCountedHallEffectStruct pusher_distal; |
Brian Silverman | aae236a | 2014-02-17 01:49:39 -0800 | [diff] [blame] | 31 | // Triggers just before pusher_distal. |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame^] | 32 | PosedgeOnlyCountedHallEffectStruct pusher_proximal; |
Brian Silverman | aae236a | 2014-02-17 01:49:39 -0800 | [diff] [blame] | 33 | // Triggers when the latch engages. |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame^] | 34 | bool latch; |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 35 | |
Brian Silverman | 8c30bc1 | 2014-01-18 12:49:38 -0800 | [diff] [blame] | 36 | // In meters, out is positive. |
| 37 | double position; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 38 | }; |
| 39 | message Status { |
Brian Silverman | 8c30bc1 | 2014-01-18 12:49:38 -0800 | [diff] [blame] | 40 | // Whether it's ready to shoot right now. |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 41 | bool ready; |
Brian Silverman | 8c30bc1 | 2014-01-18 12:49:38 -0800 | [diff] [blame] | 42 | // Whether the plunger is in and out of the way of grabbing a ball. |
| 43 | bool cocked; |
| 44 | // How many times we've shot. |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 45 | int32_t shots; |
joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 46 | bool done; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | queue Goal goal; |
| 50 | queue Position position; |
joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 51 | queue Output output; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 52 | queue Status status; |
| 53 | }; |
| 54 | |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 55 | queue_group ShooterGroup shooter_queue_group; |