diff --git a/2019robot/src/main/java/org/usfirst/frc4388/robot/OI.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/OI.java index 82c5212..82c7cfd 100644 --- a/2019robot/src/main/java/org/usfirst/frc4388/robot/OI.java +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/OI.java @@ -49,8 +49,8 @@ public class OI CarriageEject.whenPressed(new IntakeSetSpeed(Carriage.CUBE_INTAKE_SPEED)); CarriageEject.whenReleased(new IntakeSetSpeed(0.0)); */ - JoystickButton climbUp = new JoystickButton(m_operatorXbox.getJoyStick(), XboxController.RIGHT_TRIGGER_AXIS); - int speed = XboxController.RIGHT_TRIGGER_AXIS; + JoystickButton climbUp = new XBoxTriggerButton(m_operatorXbox, XboxController.RIGHT_TRIGGER); + float speed = XboxController.RIGHT_TRIGGER_AXIS; climbUp.whenPressed(new InitiateClimber(true, speed)); climbUp.whenReleased(new InitiateClimber(false, speed)); @@ -69,10 +69,14 @@ public class OI openIntake.whenPressed(new IntakePosition(true)); JoystickButton CloseIntake = new JoystickButton(m_operatorXbox.getJoyStick(), XboxController.RIGHT_BUMPER_BUTTON); - CloseIntake.whenPressed(new IntakePosition(false)); + CloseIntake.whenPressed(new IntakePosition(false)); + */ + JoystickButton safteySwitch = new JoystickButton(m_operatorXbox.getJoyStick(), XboxController.START_BUTTON); + safteySwitch.whenPressed(new startSaftey(true)); + safteySwitch.whenReleased(new startSaftey(false)); SmartDashboard.putData("PRE GAME!!!!", new PreGame()); - */ + } catch (Exception e) { System.err.println("An error occurred in the OI constructor"); } diff --git a/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/InitiateClimber.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/InitiateClimber.java index 507d6d1..f899d0d 100644 --- a/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/InitiateClimber.java +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/InitiateClimber.java @@ -8,6 +8,7 @@ import edu.wpi.first.wpilibj.command.Command; public class InitiateClimber extends Command { boolean climb; + boolean saftey; float speed; public InitiateClimber(boolean Climb, int speed) { @@ -16,16 +17,25 @@ public class InitiateClimber extends Command this.speed = speed; } + public startSaftey(boolean saftey){ + requires(Robot.climber); + this.saftey = saftey; + } + @Override protected void initialize() { } @Override protected void execute() { - Robot.climber.setClimbSpeed(climb, speed); - } - - // Make this return true when this Command no longer needs to run execute() + if(climb && saftey){ //If climb and saftey button are pressed + Robot.climber.setClimbSpeed(climb, speed); + } + else{ + Robot.climber.setClimbSpeed(false, 0); + } + } + // Make this return true when this Command no longer needs to run execute() protected boolean isFinished() { return true; } diff --git a/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/Climber.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/Climber.java index 0837773..533692d 100644 --- a/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/Climber.java +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/Climber.java @@ -79,23 +79,26 @@ public class Climber extends Subsystem{ } public void setClimbSpeed(boolean Climb, float speed) { - if (Climb && safteySwitch) { - if(isPressed.isFwdLimitSwitchClosed()) //If back at max height - { + if (Climb) { + if(isPressed.isFwdLimitSwitchClosed()){ //If back at max height climberBack.set(0); climberFront.set(FRONT_FREQ * speed); } - else if (isPressed.isFwdLimitSwitchClosed() == false) //If back not at max height - { + else if (isPressed.isFwdLimitSwitchClosed() == false){ //If back not at max height climberBack.set(BACK_FREQ * speed); climberFront.set(FRONT_FREQ * speed); - } + } } if (Climb == false) { climberBack.set(0); climberFront.set(0); } } + + + public flipRatchet(){ + //Code to flip out the front arms of the climber WIP + } } /*TODO * add command code for flipping front out (including button press)