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