Austin Schuh | 09c2b0b | 2016-02-13 15:53:16 -0800 | [diff] [blame] | 1 | package y2016.control_loops.shooter; |
Comran Morshed | 2a97bc8 | 2016-01-16 17:27:01 +0000 | [diff] [blame] | 2 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 3 | import "aos/controls/control_loops.q"; |
Comran Morshed | 2a97bc8 | 2016-01-16 17:27:01 +0000 | [diff] [blame] | 4 | import "frc971/control_loops/control_loops.q"; |
| 5 | |
Austin Schuh | 09c2b0b | 2016-02-13 15:53:16 -0800 | [diff] [blame] | 6 | struct ShooterSideStatus { |
| 7 | // True if the shooter side is up to speed and stable. |
| 8 | bool ready; |
| 9 | // The current average velocity in radians/second. |
| 10 | double avg_angular_velocity; |
| 11 | // The current instantaneous filtered velocity in radians/second. |
| 12 | double angular_velocity; |
| 13 | }; |
| 14 | |
Austin Schuh | ae023fb | 2019-06-29 17:11:45 -0700 | [diff] [blame^] | 15 | // Published on ".y2016.control_loops.shooter.shooter_queue" |
Comran Morshed | 2a97bc8 | 2016-01-16 17:27:01 +0000 | [diff] [blame] | 16 | queue_group ShooterQueue { |
| 17 | implements aos.control_loops.ControlLoop; |
| 18 | |
Austin Schuh | 09c2b0b | 2016-02-13 15:53:16 -0800 | [diff] [blame] | 19 | // All angles are in radians, and angular velocities are in radians/second. |
| 20 | // For all angular velocities, positive is shooting the ball out of the robot. |
Comran Morshed | 2a97bc8 | 2016-01-16 17:27:01 +0000 | [diff] [blame] | 21 | |
Comran Morshed | cde5032 | 2016-01-18 15:10:36 +0000 | [diff] [blame] | 22 | message Goal { |
Austin Schuh | 09c2b0b | 2016-02-13 15:53:16 -0800 | [diff] [blame] | 23 | // Angular velocity goals in radians/second. |
| 24 | double angular_velocity; |
Comran Morshed | b79c424 | 2016-02-06 18:27:26 +0000 | [diff] [blame] | 25 | |
| 26 | bool clamp_open; // True to release our clamp on the ball. |
Austin Schuh | 7eecd7c | 2016-02-28 21:59:05 -0800 | [diff] [blame] | 27 | // True to push the ball into the shooter. |
| 28 | // If we are in the act of shooting with a goal velocity != 0, wait until it |
| 29 | // is up to speed, push the ball into the shooter, and then wait until it |
| 30 | // spins up and down before letting the piston be released. |
| 31 | bool push_to_shooter; |
Austin Schuh | 1d6d0d4 | 2016-03-13 15:31:48 -0700 | [diff] [blame] | 32 | |
| 33 | // Forces the lights on. |
| 34 | bool force_lights_on; |
Austin Schuh | b2c3338 | 2016-04-03 16:09:17 -0700 | [diff] [blame] | 35 | |
| 36 | // If true, the robot is shooting forwards. |
| 37 | bool shooting_forwards; |
Comran Morshed | 2a97bc8 | 2016-01-16 17:27:01 +0000 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | message Position { |
Austin Schuh | 09c2b0b | 2016-02-13 15:53:16 -0800 | [diff] [blame] | 41 | // Wheel angle in radians/second. |
Comran Morshed | cde5032 | 2016-01-18 15:10:36 +0000 | [diff] [blame] | 42 | double theta_left; |
| 43 | double theta_right; |
| 44 | }; |
| 45 | |
| 46 | message Status { |
Austin Schuh | 09c2b0b | 2016-02-13 15:53:16 -0800 | [diff] [blame] | 47 | // Left side status. |
| 48 | ShooterSideStatus left; |
| 49 | // Right side status. |
| 50 | ShooterSideStatus right; |
Comran Morshed | cde5032 | 2016-01-18 15:10:36 +0000 | [diff] [blame] | 51 | |
Austin Schuh | 09c2b0b | 2016-02-13 15:53:16 -0800 | [diff] [blame] | 52 | // True if the shooter is ready. It is better to compare the velocities |
| 53 | // directly so there isn't confusion on if the goal is up to date. |
| 54 | bool ready; |
Austin Schuh | f59b8ee | 2016-03-19 21:31:36 -0700 | [diff] [blame] | 55 | |
| 56 | // The number of shots that have been fired since the start of the shooter |
| 57 | // control loop. |
| 58 | uint32_t shots; |
Comran Morshed | cde5032 | 2016-01-18 15:10:36 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | message Output { |
Austin Schuh | 09c2b0b | 2016-02-13 15:53:16 -0800 | [diff] [blame] | 62 | // Voltage in volts of the left and right shooter motors. |
Comran Morshed | cde5032 | 2016-01-18 15:10:36 +0000 | [diff] [blame] | 63 | double voltage_left; |
| 64 | double voltage_right; |
Comran Morshed | b79c424 | 2016-02-06 18:27:26 +0000 | [diff] [blame] | 65 | |
| 66 | // See comments on the identical fields in Goal for details. |
| 67 | bool clamp_open; |
| 68 | bool push_to_shooter; |
Austin Schuh | e0729a6 | 2016-03-12 21:54:17 -0800 | [diff] [blame] | 69 | |
| 70 | // If true, the lights are on. |
| 71 | bool lights_on; |
Austin Schuh | b2c3338 | 2016-04-03 16:09:17 -0700 | [diff] [blame] | 72 | |
| 73 | bool forwards_flashlight; |
| 74 | bool backwards_flashlight; |
Comran Morshed | 2a97bc8 | 2016-01-16 17:27:01 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | queue Goal goal; |
| 78 | queue Position position; |
Comran Morshed | cde5032 | 2016-01-18 15:10:36 +0000 | [diff] [blame] | 79 | queue Output output; |
Comran Morshed | 2a97bc8 | 2016-01-16 17:27:01 +0000 | [diff] [blame] | 80 | queue Status status; |
| 81 | }; |