From 500faccd3dd1864e493e5c35796bbfaed5c25285 Mon Sep 17 00:00:00 2001 From: "Keenan D. Buckley" Date: Sat, 16 Feb 2019 16:26:06 -0700 Subject: [PATCH] Fix rachetFlip --- .../main/java/org/usfirst/frc4388/robot/OI.java | 8 ++++---- .../frc4388/robot/commands/InitiateClimber.java | 8 ++++---- .../frc4388/robot/commands/ratchetFlip.java | 16 +++++----------- .../frc4388/robot/subsystems/Climber.java | 4 ++-- 4 files changed, 15 insertions(+), 21 deletions(-) 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 7973c8b..aaff4f1 100644 --- a/2019robot/src/main/java/org/usfirst/frc4388/robot/OI.java +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/OI.java @@ -61,14 +61,14 @@ public class OI liftBallIntake.whenPressed(new LiftBallDropHatch()); - JoystickButton climbUp = new JoystickButton(m_operatorXbox.getJoyStick(), XboxController.RIGHT_TRIGGER_AXIS); + JoystickButton climbUp = new JoystickButton(m_driverXbox.getJoyStick(), XboxController.RIGHT_TRIGGER_AXIS); double speed = m_driverXbox.getRightTriggerAxis(); climbUp.whenPressed(new InitiateClimber(true, speed)); climbUp.whenReleased(new InitiateClimber(false, speed)); - JoystickButton ratchetFlip = new JoystickButton(m_operatorXbox.getJoyStick(), XboxController.RIGHT_TRIGGER_AXIS); - ratchetFlip.whenPressed(new ratchetFlip(true, speed)); - ratchetFlip.whenReleased(new ratchetFlip(false, speed)); + JoystickButton ratchetFlip = new JoystickButton(m_driverXbox.getJoyStick(), XboxController.Y_BUTTON); + ratchetFlip.whenPressed(new ratchetFlip(0.5)); + ratchetFlip.whenReleased(new ratchetFlip(0)); JoystickButton shiftUp = new JoystickButton(m_driverXbox.getJoyStick(), XboxController.RIGHT_BUMPER_BUTTON); shiftUp.whenPressed(new DriveSpeedShift(true)); 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 619fc50..42682ea 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 @@ -7,12 +7,12 @@ import edu.wpi.first.wpilibj.command.Command; public class InitiateClimber extends Command { - boolean climb; + static boolean CLIMB; double speed; public InitiateClimber(boolean climb, double speed) { requires(Robot.climber); - this.climb = climb; + this.CLIMB = climb; this.speed = speed; } @@ -23,8 +23,8 @@ public class InitiateClimber extends Command @Override protected void execute() { - if(climb){ //If climb button is pressed - Robot.climber.setClimbSpeed(climb, speed); + if(CLIMB){ //If climb button is pressed + Robot.climber.setClimbSpeed(CLIMB, speed); } else{ Robot.climber.setClimbSpeed(false, 0); diff --git a/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/ratchetFlip.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/ratchetFlip.java index 8b6dfb9..37e5f64 100644 --- a/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/ratchetFlip.java +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/ratchetFlip.java @@ -6,34 +6,28 @@ import org.usfirst.frc4388.robot.Constants; import edu.wpi.first.wpilibj.command.Command; public class ratchetFlip extends Command { - boolean flip; - double speed; - public ratchetFlip(boolean flip, double speed) { + private double speed; + public ratchetFlip(double speed) { requires(Robot.climber); - this.flip = flip; this.speed = speed; } // Called just before this Command runs the first time @Override protected void initialize() { + Robot.climber.flipRatchet(speed); } // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if(flip){ - Robot.climber.flipRatchet(true, speed); - } - else{ - Robot.climber.flipRatchet(false, speed); - } + } // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - return false; + return true; } // Called once after isFinished returns 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 2b1eda0..7adcb4c 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 @@ -107,7 +107,7 @@ public class Climber extends Subsystem{ this.safetySwitch = safetySwitch; } - public void flipRatchet(boolean flip, double speed){ - climberFront.set(FRONT_FREQ * speed); + public void flipRatchet(double speed){ + climberFront.set(speed); } }