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 | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 4 | |
Ben Fredrickson | 9590d50 | 2014-02-16 06:19:12 +0000 | [diff] [blame^] | 5 | queue_group ShooterGroup { |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 6 | implements aos.control_loops.ControlLoop; |
| 7 | |
joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 8 | message Output { |
joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 9 | double voltage; |
Ben Fredrickson | 1f633ef | 2014-02-16 05:35:45 +0000 | [diff] [blame] | 10 | // true: latch engaged, false: latch open |
| 11 | bool latch_piston; |
| 12 | // true: brake engaged false: brake released |
| 13 | bool brake_piston; |
joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 14 | }; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 15 | message Goal { |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 16 | // encoder ticks of shot energy. |
| 17 | double shot_power; |
Brian Silverman | 8c30bc1 | 2014-01-18 12:49:38 -0800 | [diff] [blame] | 18 | // Shoots as soon as this is true. |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 19 | bool shot_requested; |
| 20 | bool unload_requested; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 21 | }; |
| 22 | message Position { |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 23 | // back on the plunger |
| 24 | bool plunger_back_hall_effect; |
| 25 | // truely back on the pusher |
| 26 | bool pusher_distal_hall_effect; |
| 27 | // warning that we are back on the pusher |
| 28 | bool pusher_proximal_hall_effect; |
| 29 | // the latch is closed |
| 30 | bool latch_hall_effect; |
| 31 | |
| 32 | // count of positive edges |
| 33 | int64_t plunger_back_hall_effect_posedge_count; |
| 34 | // count of negative edges |
| 35 | int64_t plunger_back_hall_effect_negedge_count; |
| 36 | // count of positive edges |
| 37 | int64_t pusher_distal_hall_effect_posedge_count; |
| 38 | // count of negative edges |
| 39 | int64_t pusher_distal_hall_effect_negedge_count; |
| 40 | // count of positive edges |
| 41 | int64_t pusher_proximal_hall_effect_posedge_count; |
| 42 | // count of negative edges |
| 43 | int64_t pusher_proximal_hall_effect_negedge_count; |
| 44 | // count of positive edges |
| 45 | int64_t latch_hall_effect_posedge_count; |
| 46 | // count of negative edges |
| 47 | int64_t latch_hall_effect_negedge_count; |
| 48 | |
Brian Silverman | 8c30bc1 | 2014-01-18 12:49:38 -0800 | [diff] [blame] | 49 | // In meters, out is positive. |
| 50 | double position; |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 51 | |
| 52 | // last positive edge |
| 53 | double posedge_value; |
| 54 | // last negative edge |
| 55 | double negedge_value; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 56 | }; |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 57 | // I don't think this is needed, but it is here |
| 58 | // so I won't delete it yet. |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 59 | message Status { |
Brian Silverman | 8c30bc1 | 2014-01-18 12:49:38 -0800 | [diff] [blame] | 60 | // Whether it's ready to shoot right now. |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 61 | bool ready; |
Brian Silverman | 8c30bc1 | 2014-01-18 12:49:38 -0800 | [diff] [blame] | 62 | // Whether the plunger is in and out of the way of grabbing a ball. |
| 63 | bool cocked; |
| 64 | // How many times we've shot. |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 65 | int32_t shots; |
joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 66 | bool done; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | queue Goal goal; |
| 70 | queue Position position; |
joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 71 | queue Output output; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 72 | queue Status status; |
| 73 | }; |
| 74 | |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 75 | queue_group ShooterGroup shooter_queue_group; |