From 2781cca0354e26f8c5a6150d6b5179d300d479e1 Mon Sep 17 00:00:00 2001 From: Meryem Esa Date: Sat, 5 Mar 2016 11:54:49 -0800 Subject: [PATCH] make extend and retract intake arm piston methods and a command --- .../usfirst/frc/team3501/robot/Constants.java | 3 ++ src/org/usfirst/frc/team3501/robot/OI.java | 43 ++++++------------- .../commands/intakearm/MoveIntakeArm.java | 43 +++++++++++++++++++ .../team3501/robot/subsystems/IntakeArm.java | 10 +++++ 4 files changed, 68 insertions(+), 31 deletions(-) create mode 100755 src/org/usfirst/frc/team3501/robot/commands/intakearm/MoveIntakeArm.java diff --git a/src/org/usfirst/frc/team3501/robot/Constants.java b/src/org/usfirst/frc/team3501/robot/Constants.java index e7efadae..e57bd771 100644 --- a/src/org/usfirst/frc/team3501/robot/Constants.java +++ b/src/org/usfirst/frc/team3501/robot/Constants.java @@ -119,6 +119,9 @@ public class Constants { public static final int RIGHT_FORWARD = 2; public static final int RIGHT_REVERSE = 3; + public static final Value EXTEND = DoubleSolenoid.Value.kForward; + public static final Value RETRACT = DoubleSolenoid.Value.kReverse; + // for roller public static final double INTAKE_SPEED = 0.5; public static final double OUTPUT_SPEED = -0.5; diff --git a/src/org/usfirst/frc/team3501/robot/OI.java b/src/org/usfirst/frc/team3501/robot/OI.java index 3eb1c1f5..491b71c6 100644 --- a/src/org/usfirst/frc/team3501/robot/OI.java +++ b/src/org/usfirst/frc/team3501/robot/OI.java @@ -7,14 +7,12 @@ import org.usfirst.frc.team3501.robot.commands.auton.PassPortcullis; import org.usfirst.frc.team3501.robot.commands.auton.PassSallyPort; import org.usfirst.frc.team3501.robot.commands.driving.Turn180; import org.usfirst.frc.team3501.robot.commands.intakearm.IntakeBall; -import org.usfirst.frc.team3501.robot.commands.intakearm.MoveIntakeArmToAngle; import org.usfirst.frc.team3501.robot.commands.scaler.ExtendLift; import org.usfirst.frc.team3501.robot.commands.scaler.RetractLift; import org.usfirst.frc.team3501.robot.commands.scaler.RunWinchContinuous; import org.usfirst.frc.team3501.robot.commands.scaler.StopWinch; import org.usfirst.frc.team3501.robot.commands.scaler.ToggleScaling; import org.usfirst.frc.team3501.robot.commands.shooter.Shoot; -import org.usfirst.frc.team3501.robot.subsystems.IntakeArm; import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.Joystick; @@ -56,41 +54,24 @@ public class OI { leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT); rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT); - passPortcullis = new DigitalButton(new DigitalInput( - Constants.OI.PASS_PORTCULLIS_PORT)); + passPortcullis = new DigitalButton( + new DigitalInput(Constants.OI.PASS_PORTCULLIS_PORT)); passPortcullis.whenPressed(new PassPortcullis()); - passChevalDeFrise = new DigitalButton(new DigitalInput( - Constants.OI.PASS_CHEVAL_DE_FRISE_PORT)); + passChevalDeFrise = new DigitalButton( + new DigitalInput(Constants.OI.PASS_CHEVAL_DE_FRISE_PORT)); passChevalDeFrise.whenPressed(new PassChevalDeFrise()); - passDrawbridge = new DigitalButton(new DigitalInput( - Constants.OI.PASS_DRAWBRIDGE_PORT)); + passDrawbridge = new DigitalButton( + new DigitalInput(Constants.OI.PASS_DRAWBRIDGE_PORT)); passDrawbridge.whenPressed(new PassDrawBridge()); - passSallyPort = new DigitalButton(new DigitalInput( - Constants.OI.PASS_SALLYPORT_PORT)); + passSallyPort = new DigitalButton( + new DigitalInput(Constants.OI.PASS_SALLYPORT_PORT)); passSallyPort.whenPressed(new PassSallyPort()); - lowerChevalDeFrise = new DigitalButton(new DigitalInput( - Constants.OI.ARCADE_INTAKEARM_LEVEL_ONE_PORT)); - lowerChevalDeFrise.whenPressed(new MoveIntakeArmToAngle( - IntakeArm.potAngles[0], IntakeArm.moveIntakeArmSpeed)); - - moveToIntakeBoulder = new DigitalButton(new DigitalInput( - Constants.OI.ARCADE_INTAKEARM_LEVEL_TWO_PORT)); - moveToIntakeBoulder.whenPressed(new MoveIntakeArmToAngle( - IntakeArm.potAngles[1], IntakeArm.moveIntakeArmSpeed)); - - poiseAboveChevalDeFrise = new DigitalButton(new DigitalInput( - Constants.OI.ARCADE_INTAKEARM_LEVEL_THREE_PORT)); - poiseAboveChevalDeFrise.whenPressed(new MoveIntakeArmToAngle( - IntakeArm.potAngles[2], IntakeArm.moveIntakeArmSpeed)); - - moveIntakeArmInsideRobot = new DigitalButton(new DigitalInput( - Constants.OI.ARCADE_INTAKEARM_LEVEL_FOUR_PORT)); - moveIntakeArmInsideRobot.whenPressed(new MoveIntakeArmToAngle( - IntakeArm.potAngles[3], IntakeArm.moveIntakeArmSpeed)); + moveToIntakeBoulder = new DigitalButton( + new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_TWO_PORT)); toggleShooter = new JoystickButton(leftJoystick, Constants.OI.LEFT_JOYSTICK_TRIGGER_PORT); @@ -110,8 +91,8 @@ public class OI { shootBoulder = new JoystickButton(rightJoystick, Constants.OI.RIGHT_JOYSTICK_THUMB_PORT); - toggleScaling = new DigitalButton(new DigitalInput( - Constants.OI.TOGGLE_SCALING_PORT)); + toggleScaling = new DigitalButton( + new DigitalInput(Constants.OI.TOGGLE_SCALING_PORT)); toggleScaling.whenPressed(new ToggleScaling()); if (!Constants.Scaler.SCALING) { diff --git a/src/org/usfirst/frc/team3501/robot/commands/intakearm/MoveIntakeArm.java b/src/org/usfirst/frc/team3501/robot/commands/intakearm/MoveIntakeArm.java new file mode 100755 index 00000000..1d24648f --- /dev/null +++ b/src/org/usfirst/frc/team3501/robot/commands/intakearm/MoveIntakeArm.java @@ -0,0 +1,43 @@ +package org.usfirst.frc.team3501.robot.commands.intakearm; + +import org.usfirst.frc.team3501.robot.Constants; +import org.usfirst.frc.team3501.robot.Robot; + +import edu.wpi.first.wpilibj.DoubleSolenoid.Value; +import edu.wpi.first.wpilibj.command.Command; + +/** + * This command will expand or retract the intake arm's pistons depending on the + * specified direction the intake arm should move + */ +public class MoveIntakeArm extends Command { + + public MoveIntakeArm(Value direction) { + + if (direction == Constants.IntakeArm.EXTEND) + Robot.intakeArm.extendPistons(); + else + Robot.intakeArm.retractPistons(); + } + + @Override + protected void initialize() { + } + + @Override + protected void execute() { + } + + @Override + protected boolean isFinished() { + return false; + } + + @Override + protected void end() { + } + + @Override + protected void interrupted() { + } +} diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/IntakeArm.java b/src/org/usfirst/frc/team3501/robot/subsystems/IntakeArm.java index 1870799d..856db2bb 100755 --- a/src/org/usfirst/frc/team3501/robot/subsystems/IntakeArm.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/IntakeArm.java @@ -34,6 +34,16 @@ public class IntakeArm extends Subsystem { Constants.IntakeArm.RIGHT_REVERSE); } + public void retractPistons() { + leftIntake.set(Constants.IntakeArm.RETRACT); + rightIntake.set(Constants.IntakeArm.RETRACT); + } + + public void extendPistons() { + leftIntake.set(Constants.IntakeArm.EXTEND); + rightIntake.set(Constants.IntakeArm.EXTEND); + } + /*** * This method sets the voltage of the motor to intake the ball. The voltage * values are constants in Constants class -- 2.30.2