From fd8ab18ebb39c7fc0dea4d9da7de57307b9b3532 Mon Sep 17 00:00:00 2001 From: ryan123rudder <42309874+ryan123rudder@users.noreply.github.com> Date: Fri, 15 Feb 2019 16:47:35 -0700 Subject: [PATCH] Added ratchet systems --- .../java/org/usfirst/frc4388/robot/OI.java | 4 ++ .../frc4388/robot/commands/ratchetFlip.java | 49 +++++++++++++++++++ .../frc4388/robot/subsystems/Climber.java | 4 +- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 2019robot/src/main/java/org/usfirst/frc4388/robot/commands/ratchetFlip.java 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 94f41df..fde8e7f 100644 --- a/2019robot/src/main/java/org/usfirst/frc4388/robot/OI.java +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/OI.java @@ -54,6 +54,10 @@ public class OI 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 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/ratchetFlip.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/ratchetFlip.java new file mode 100644 index 0000000..8b6dfb9 --- /dev/null +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/commands/ratchetFlip.java @@ -0,0 +1,49 @@ +package org.usfirst.frc4388.robot.commands; + +import org.usfirst.frc4388.robot.Robot; +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) { + requires(Robot.climber); + this.flip = flip; + this.speed = speed; + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + } + + // 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; + } + + // Called once after isFinished returns true + @Override + protected void end() { + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + } +} 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 951abb3..bd37efd 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 @@ -100,8 +100,8 @@ public class Climber extends Subsystem{ this.safetySwitch = safetySwitch; } - public void flipRatchet(){ - ///TODO: Code to flip out the front arms of the climber WIP + public void flipRatchet(boolean flip, double speed){ + climberFront.set(FRONT_FREQ * speed); } } /*