From: Rohan Rodrigues Date: Sat, 4 Mar 2017 17:50:55 +0000 (-0800) Subject: Add ToggleIndexerPiston class X-Git-Url: http://challenge-bot.com/repos/?p=3501%2F2017steamworks;a=commitdiff_plain;h=e4082bee56fa6cbcbaa062d17ae17c280dec40c5 Add ToggleIndexerPiston class --- diff --git a/src/org/usfirst/frc/team3501/robot/OI.java b/src/org/usfirst/frc/team3501/robot/OI.java index 9000e35..07ad53c 100644 --- a/src/org/usfirst/frc/team3501/robot/OI.java +++ b/src/org/usfirst/frc/team3501/robot/OI.java @@ -1,7 +1,6 @@ package org.usfirst.frc.team3501.robot; import org.usfirst.frc.team3501.robot.commands.climber.ToggleWinch; -import org.usfirst.frc.team3501.robot.commands.driving.ToggleDrivePiston; import org.usfirst.frc.team3501.robot.commands.driving.ToggleGear; import org.usfirst.frc.team3501.robot.commands.intake.ReverseIntakeContinuous; import org.usfirst.frc.team3501.robot.commands.intake.RunIntakeContinuous; @@ -11,6 +10,7 @@ import org.usfirst.frc.team3501.robot.commands.shooter.ReverseIndexWheelContinuo import org.usfirst.frc.team3501.robot.commands.shooter.RunFlyWheelContinuous; import org.usfirst.frc.team3501.robot.commands.shooter.RunIndexWheelContinuous; import org.usfirst.frc.team3501.robot.commands.shooter.ToggleIndexerPiston; +import org.usfirst.frc.team3501.robot.utils.ChangeCameraView; import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.buttons.Button; @@ -79,11 +79,9 @@ public class OI /* implements KeyListener */ { Constants.OI.DECREASE_SHOOTER_SPEED_PORT); decreaseShooterSpeed.whenPressed(new DecreaseShootingSpeed()); - /* - * changeCam = new JoystickButton(rightJoystick, - * Constants.OI.CHANGE_CAMERA_VIEW); changeCam.toggleWhenPressed(new - * ChangeCameraView()); - */ + changeCam = new JoystickButton(rightJoystick, + Constants.OI.CHANGE_CAMERA_VIEW); + changeCam.toggleWhenPressed(new ChangeCameraView()); togglePiston = new JoystickButton(rightJoystick, Constants.Shooter.TOGGLE_INDEXER); @@ -91,7 +89,7 @@ public class OI /* implements KeyListener */ { toggleDriveTrainPiston = new JoystickButton(rightJoystick, Constants.DriveTrain.TOGGLE_DRIVE_PISTON); - toggleDriveTrainPiston.whenPressed(new ToggleDrivePiston()); + toggleDriveTrainPiston.whenPressed(new ToggleGear()); } public static OI getOI() { diff --git a/src/org/usfirst/frc/team3501/robot/Robot.java b/src/org/usfirst/frc/team3501/robot/Robot.java index e72f07e..455de4e 100644 --- a/src/org/usfirst/frc/team3501/robot/Robot.java +++ b/src/org/usfirst/frc/team3501/robot/Robot.java @@ -55,7 +55,8 @@ public class Robot extends IterativeRobot { // both set to high gear @Override public void autonomousInit() { - driveTrain.setHighGear(); + driveTrain.setHighGear(driveTrain.getRightPiston()); + driveTrain.setHighGear(driveTrain.getLeftPiston()); } @Override diff --git a/src/org/usfirst/frc/team3501/robot/commands/driving/ToggleDrivePiston.java b/src/org/usfirst/frc/team3501/robot/commands/driving/ToggleDrivePiston.java deleted file mode 100644 index ad13cc0..0000000 --- a/src/org/usfirst/frc/team3501/robot/commands/driving/ToggleDrivePiston.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.usfirst.frc.team3501.robot.commands.driving; - -import org.usfirst.frc.team3501.robot.Constants; -import org.usfirst.frc.team3501.robot.Robot; -import org.usfirst.frc.team3501.robot.subsystems.DriveTrain; -import edu.wpi.first.wpilibj.command.Command; - -public class ToggleDrivePiston extends Command { - private DriveTrain driveTrain = Robot.getDriveTrain(); - - /** - * See JavaDoc comment in class for details - * - * @param motorVal - * value range from -1 to 1 - */ - public ToggleDrivePiston() { - requires(driveTrain); - } - - // 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 (DriveTrain.getDriveTrain() - .getLeftGearPistonValue() == Constants.DriveTrain.HIGH_GEAR) { - DriveTrain.getDriveTrain().setLowGear(); - } else { - DriveTrain.getDriveTrain().setHighGear(); - } - - // check to make sure that both pistons are set to the same gear. Otherwise, - // the code must be changed - } - - // 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() { - end(); - } - - @Override - protected boolean isFinished() { - return false; - - } - -} diff --git a/src/org/usfirst/frc/team3501/robot/commands/driving/ToggleGear.java b/src/org/usfirst/frc/team3501/robot/commands/driving/ToggleGear.java index ce74890..3a17440 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/driving/ToggleGear.java +++ b/src/org/usfirst/frc/team3501/robot/commands/driving/ToggleGear.java @@ -29,10 +29,17 @@ public class ToggleGear extends Command { protected void execute() { Value leftGearPistonValue = driveTrain.getLeftGearPistonValue(); Value rightGearPistonValue = driveTrain.getRightGearPistonValue(); + if (leftGearPistonValue == Constants.DriveTrain.LOW_GEAR) { - driveTrain.setHighGear(); + driveTrain.setHighGear(driveTrain.getLeftPiston()); + } else { + driveTrain.setLowGear(driveTrain.getLeftPiston()); + } + + if (rightGearPistonValue == Constants.DriveTrain.LOW_GEAR) { + driveTrain.setHighGear(driveTrain.getRightPiston()); } else { - driveTrain.setLowGear(); + driveTrain.setLowGear(driveTrain.getRightPiston()); } } diff --git a/src/org/usfirst/frc/team3501/robot/commands/shooter/ToggleIndexerPiston.java b/src/org/usfirst/frc/team3501/robot/commands/shooter/ToggleIndexerPiston.java index 42cf3bc..a653293 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/shooter/ToggleIndexerPiston.java +++ b/src/org/usfirst/frc/team3501/robot/commands/shooter/ToggleIndexerPiston.java @@ -27,10 +27,10 @@ public class ToggleIndexerPiston extends Command { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if (Shooter.getShooter().getPistonValue() == Constants.Shooter.LOW_GEAR) { - Shooter.getShooter().setHighGear(); + if (shooter.getPistonValue() == Constants.Shooter.LOW_GEAR) { + shooter.setHighGear(); } else { - Shooter.getShooter().setLowGear(); + shooter.setLowGear(); } } diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java b/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java index 32ec7b2..328209e 100644 --- a/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java @@ -165,26 +165,33 @@ public class DriveTrain extends Subsystem { return rightGearPiston.get(); } + public DoubleSolenoid getLeftPiston() { + return this.leftGearPiston; + } + + public DoubleSolenoid getRightPiston() { + return this.rightGearPiston; + } + /* * Changes the ball shift gear assembly to high */ - public void setHighGear() { - changeGear(Constants.DriveTrain.HIGH_GEAR); + public void setHighGear(DoubleSolenoid p) { + changeGear(Constants.DriveTrain.HIGH_GEAR, p); } /* * Changes the ball shift gear assembly to low */ - public void setLowGear() { - changeGear(Constants.DriveTrain.LOW_GEAR); + public void setLowGear(DoubleSolenoid p) { + changeGear(Constants.DriveTrain.LOW_GEAR, p); } /* * Changes the gear to a DoubleSolenoid.Value */ - private void changeGear(DoubleSolenoid.Value gear) { - leftGearPiston.set(gear); - rightGearPiston.set(gear); + private void changeGear(DoubleSolenoid.Value gear, DoubleSolenoid piston) { + piston.set(gear); } @Override diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java index dac23fd..e526dac 100644 --- a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java @@ -22,7 +22,7 @@ public class Shooter extends Subsystem { private double currentShootingSpeed = DEFAULT_SHOOTING_SPEED; - private DoubleSolenoid piston; + private final DoubleSolenoid piston; private Shooter() { flyWheel1 = new CANTalon(Constants.Shooter.FLY_WHEEL1);