File tree Expand file tree Collapse file tree
Robot2019/src/main/java/frc/robot Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414import frc .robot .commands .ActuateClimberRails ;
1515import frc .robot .commands .Climb ;
1616import frc .robot .commands .EjectCargo ;
17- import frc .robot .commands .EjectHatch ;
17+ import frc .robot .commands .ToggleHatchEject ;
1818import frc .robot .commands .IntakeCargo ;
19- import frc .robot .commands .IntakeHatch ;
19+ import frc .robot .commands .ToggleHatchIntake ;
2020import frc .robot .commands .ManualClimb ;
2121import frc .robot .commands .NormalDrive ;
2222import frc .robot .commands .ResetWobble ;
@@ -70,9 +70,9 @@ public class OI {
7070 normDriveBtn .whileHeld (new NormalDrive ());
7171
7272 hatchIntakeBtn = new JoystickButton (manipulator , Manip .X );
73- hatchIntakeBtn .whenPressed (new IntakeHatch (hp ));
73+ hatchIntakeBtn .whenPressed (new ToggleHatchIntake (hp ));
7474 hatchEjectBtn = new JoystickButton (manipulator , Manip .Y );
75- hatchEjectBtn .whenPressed (new EjectHatch (hp ));
75+ hatchEjectBtn .whenPressed (new ToggleHatchEject (hp ));
7676
7777 cargoIntakeBtn = new JoystickButton (manipulator , Manip .A ); // TODO: set ports to correct values
7878 cargoIntakeBtn .whenPressed (new IntakeCargo (cargo ));
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ /*----------------------------------------------------------------------------*/
2+ /* Copyright (c) 2018 FIRST. All Rights Reserved. */
3+ /* Open Source Software - may be modified and shared by FRC teams. The code */
4+ /* must be accompanied by the FIRST BSD license file in the root directory of */
5+ /* the project. */
6+ /*----------------------------------------------------------------------------*/
7+
8+ package frc .robot .commands ;
9+
10+ import edu .wpi .first .wpilibj .command .InstantCommand ;
11+ import frc .robot .subsystems .HatchPanel ;
12+
13+ public class ToggleHatchEject extends InstantCommand {
14+ private HatchPanel hp ;
15+
16+ /**
17+ * Toggles the eject pistons of the hatch panel mechanism, also closes the
18+ * grabbing piston when ejecting
19+ */
20+ public ToggleHatchEject (HatchPanel hp ) {
21+ requires (hp );
22+ this .hp = hp ;
23+ }
24+
25+ @ Override
26+ protected void initialize () {
27+ // If the pistons are currently extend them, retract them back, otherwise
28+ // release and then eject
29+ if (hp .state == HatchPanel .State .EJECTING ) {
30+ hp .reset ();
31+ } else {
32+ hp .reset ();
33+ hp .eject ();
34+ }
35+ }
36+ }
Original file line number Diff line number Diff line change 1010import edu .wpi .first .wpilibj .command .InstantCommand ;
1111import frc .robot .subsystems .HatchPanel ;
1212
13- public class IntakeHatch extends InstantCommand {
13+ public class ToggleHatchIntake extends InstantCommand {
1414 private HatchPanel hp ;
1515
1616 /**
1717 * Toggles the grabbing piston of the hatch mechanism
1818 */
19- public IntakeHatch (HatchPanel hp ) {
19+ public ToggleHatchIntake (HatchPanel hp ) {
2020 requires (hp );
2121 this .hp = hp ;
2222 }
Original file line number Diff line number Diff line change @@ -34,18 +34,21 @@ public void reset() {
3434 grabPiston .set (DoubleSolenoid .Value .kReverse );
3535 ejectPistons .set (DoubleSolenoid .Value .kReverse );
3636 state = State .DEFAULT ;
37+ SmartDashboard .putString ("Hatch Piston State" , state .name ());
3738 }
3839
3940 public void grab () {
4041 grabPiston .set (DoubleSolenoid .Value .kForward );
4142 ejectPistons .set (DoubleSolenoid .Value .kReverse );
4243 state = State .GRABBING ;
44+ SmartDashboard .putString ("Hatch Piston State" , state .name ());
4345 }
4446
4547 public void eject () {
4648 grabPiston .set (DoubleSolenoid .Value .kReverse );
4749 ejectPistons .set (DoubleSolenoid .Value .kForward );
4850 state = State .EJECTING ;
51+ SmartDashboard .putString ("Hatch Piston State" , state .name ());
4952 }
5053
5154 @ Override
You can’t perform that action at this time.
0 commit comments