Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 1 | package frc971.control_loops; |
| 2 | |
Brian | a6553ed | 2014-04-02 21:26:46 -0700 | [diff] [blame] | 3 | import "aos/common/controls/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; |
James Kuszmaul | d29689f | 2014-03-02 13:06:54 -0800 | [diff] [blame] | 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; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | queue Goal goal; |
| 55 | queue Position position; |
joe | 93778a6 | 2014-02-15 13:22:14 -0800 | [diff] [blame] | 56 | queue Output output; |
Brian Silverman | d4417aa | 2014-01-18 12:45:12 -0800 | [diff] [blame] | 57 | queue Status status; |
| 58 | }; |
| 59 | |
Ben Fredrickson | 1e512ff | 2014-02-15 21:36:52 +0000 | [diff] [blame] | 60 | queue_group ShooterGroup shooter_queue_group; |
Brian Silverman | f48fab3 | 2014-03-09 14:32:24 -0700 | [diff] [blame] | 61 | |
| 62 | struct ShooterStateToLog { |
| 63 | double absolute_position; |
| 64 | double absolute_velocity; |
| 65 | uint32_t state; |
| 66 | bool latch_sensor; |
| 67 | bool proximal; |
| 68 | bool distal; |
| 69 | bool plunger; |
| 70 | bool brake; |
| 71 | bool latch_piston; |
| 72 | }; |
| 73 | |
| 74 | struct ShooterVoltageToLog { |
| 75 | double X_hat; |
| 76 | double applied; |
| 77 | }; |
| 78 | |
| 79 | struct ShooterMovingGoal { |
| 80 | double dx; |
| 81 | }; |
| 82 | |
| 83 | struct ShooterChangeCalibration { |
| 84 | double encoder; |
| 85 | double real_position; |
| 86 | double old_position; |
| 87 | double new_position; |
| 88 | double old_offset; |
| 89 | double new_offset; |
| 90 | }; |
| 91 | |
| 92 | struct ShooterStatusToLog { |
| 93 | double goal; |
| 94 | double position; |
| 95 | }; |
Brian Silverman | 0ebe944 | 2014-03-22 13:57:35 -0700 | [diff] [blame] | 96 | |
| 97 | struct PowerAdjustment { |
| 98 | double requested_power; |
| 99 | double actual_power; |
| 100 | }; |