diff --git a/src/org/usfirst/frc/team2059/robot/OI.java b/src/org/usfirst/frc/team2059/robot/OI.java index 71f9942..02b2b0c 100644 --- a/src/org/usfirst/frc/team2059/robot/OI.java +++ b/src/org/usfirst/frc/team2059/robot/OI.java @@ -35,9 +35,9 @@ public class OI { // Print log when button 1 pressed //joystickButtons[0][0].whenPressed(new LogEncoder()); joystickButtons[0][0].whileHeld(new SetShooterState(true)); - joystickButtons[0][2].whileHeld(new SpinRollers(-0.5,false)); - joystickButtons[0][3].whileHeld(new SpinRollers(1,false)); - joystickButtons[0][6].whileHeld(new SpinRollers(1,true)); + joystickButtons[0][2].whileHeld(new SpinRollers(-0.5, false)); + joystickButtons[0][3].whileHeld(new SpinRollers(1, false)); + joystickButtons[0][6].whileHeld(new SpinRollers(1, true)); // joystickButtons[0][2].whileHeld(new PIDDrive(400)); joystickButtons[1][0].whileHeld(new MoveArm(1)); joystickButtons[1][1].whileHeld(new MoveArm(-1)); diff --git a/src/org/usfirst/frc/team2059/robot/Robot.java b/src/org/usfirst/frc/team2059/robot/Robot.java index 8244317..384a515 100644 --- a/src/org/usfirst/frc/team2059/robot/Robot.java +++ b/src/org/usfirst/frc/team2059/robot/Robot.java @@ -31,7 +31,7 @@ public class Robot extends IterativeRobot { SmartDashboard.putData("MainArm", CommandBase.mainArm.getPIDController()); SmartDashboard.putData("LeftEncoderController", CommandBase.driveBase.getLeftController()); SmartDashboard.putData("gyroPID", CommandBase.driveBase.getGyroController()); - SmartDashboard.putNumber("GyroCorrection",0.13); + SmartDashboard.putNumber("GyroCorrection", 0.13); SmartDashboard.putBoolean("CompressorEnabled", true); //Automatically determine if rolling in or rolling out SmartDashboard.putBoolean("SmartRollers", false); @@ -67,7 +67,7 @@ public class Robot extends IterativeRobot { SmartDashboard.putNumber("ArmAngleRaw", CommandBase.mainArm.getRaw()); SmartDashboard.putNumber("ArmAngleDegrees", CommandBase.mainArm.getDegrees()); SmartDashboard.putNumber("tmpRotations", CommandBase.driveBase.getLeftRotations()); - if (Robot.oi.getJoysticks()[1].getRawButton(3)){ + if (Robot.oi.getJoysticks()[1].getRawButton(3)) { CommandBase.pneumatics.setArmStopState(true); } else { CommandBase.pneumatics.setArmStopState(false); diff --git a/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoDrive.java b/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoDrive.java index 708abcb..f650915 100644 --- a/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoDrive.java +++ b/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoDrive.java @@ -22,7 +22,7 @@ public class AutoDrive extends CommandBase { } protected void execute() { if (startDriving) { - driveBase.pidDrive(distance,SmartDashboard.getNumber("GyroCorrection")); + driveBase.pidDrive(distance, SmartDashboard.getNumber("GyroCorrection")); } startDriving = false; } diff --git a/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoDriveStraightDistance.java b/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoDriveStraightDistance.java index 71dfc33..342569f 100644 --- a/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoDriveStraightDistance.java +++ b/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoDriveStraightDistance.java @@ -7,14 +7,14 @@ public class AutoDriveStraightDistance extends CommandBase { public AutoDriveStraightDistance(double distance, double timeout) { requires(driveBase); setTimeout(timeout); - this.distance=distance; + this.distance = distance; } protected void initialize() { - driveBase.resetGyro(); - driveBase.getLeftEncoder().reset(); + driveBase.resetGyro(); + driveBase.getLeftEncoder().reset(); } protected void execute() { - driveBase.pidDrive(distance,SmartDashboard.getNumber("GyroCorrection")); + driveBase.pidDrive(distance, SmartDashboard.getNumber("GyroCorrection")); } protected void end() { driveBase.getLeftController().disable(); @@ -24,7 +24,7 @@ public class AutoDriveStraightDistance extends CommandBase { end(); } protected boolean isFinished() { - return isTimedOut() || Math.abs(distance-driveBase.getLeftRotations()) <= 3; + return isTimedOut() || Math.abs(distance - driveBase.getLeftRotations()) <= 3; } } // vim: sw=2:ts=2:sts=2 diff --git a/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoDriveStraightTime.java b/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoDriveStraightTime.java index 502f9cf..48172fe 100644 --- a/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoDriveStraightTime.java +++ b/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoDriveStraightTime.java @@ -7,13 +7,13 @@ public class AutoDriveStraightTime extends CommandBase { public AutoDriveStraightTime(double speed, double time) { requires(driveBase); setTimeout(time); - this.speed=speed; + this.speed = speed; } protected void initialize() { - driveBase.resetGyro(); + driveBase.resetGyro(); } protected void execute() { - driveBase.driveStraight(-speed,SmartDashboard.getNumber("GyroCorrection")); + driveBase.driveStraight(-speed, SmartDashboard.getNumber("GyroCorrection")); } protected void end() { driveBase.stopDriving(); diff --git a/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoResetLower.java b/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoResetLower.java index 5d47777..c2b1ed5 100644 --- a/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoResetLower.java +++ b/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoResetLower.java @@ -22,7 +22,7 @@ public class AutoResetLower extends CommandBase { // Make this return true when this Command no longer needs to run execute() protected boolean isFinished() { // Stop when bottom limit switch is hit - return mainArm.getBottomPressed(); + return mainArm.getBottomPressed(); } // Called once after isFinished returns true protected void end() { diff --git a/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoRotate.java b/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoRotate.java index e46e469..87d7b23 100644 --- a/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoRotate.java +++ b/src/org/usfirst/frc/team2059/robot/commands/autonomous/AutoRotate.java @@ -6,7 +6,7 @@ public class AutoRotate extends CommandBase { double degrees; public AutoRotate(double degrees) { requires(driveBase); - this.degrees=degrees; + this.degrees = degrees; setTimeout(2.5); } protected void initialize() { diff --git a/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineDriveStraightDistance.java b/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineDriveStraightDistance.java index f61f480..94d1eaf 100644 --- a/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineDriveStraightDistance.java +++ b/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineDriveStraightDistance.java @@ -6,6 +6,6 @@ public class RoutineDriveStraightDistance extends CommandGroup { public RoutineDriveStraightDistance() { addSequential(new AutoSetArmStopState(true)); addSequential(new AutoResetLower(-1)); - addSequential(new AutoDriveStraightDistance(200,5)); + addSequential(new AutoDriveStraightDistance(200, 5)); } } diff --git a/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineDriveStraightTime.java b/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineDriveStraightTime.java index 3a07f94..4ff218c 100644 --- a/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineDriveStraightTime.java +++ b/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineDriveStraightTime.java @@ -6,6 +6,6 @@ public class RoutineDriveStraightTime extends CommandGroup { public RoutineDriveStraightTime() { addSequential(new AutoSetArmStopState(true)); addSequential(new AutoResetLower(-1)); - addSequential(new AutoDriveStraightTime(0.5,1)); + addSequential(new AutoDriveStraightTime(0.5, 1)); } } diff --git a/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineRaiseArmFire.java b/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineRaiseArmFire.java index e189c56..870f517 100644 --- a/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineRaiseArmFire.java +++ b/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineRaiseArmFire.java @@ -6,8 +6,10 @@ public class RoutineRaiseArmFire extends CommandGroup { public RoutineRaiseArmFire() { addSequential(new AutoSetArmPosition(90)); //Raise the arm a little before spinning rollers - try{ wait(2); }catch(Exception e){ } - addParallel(new AutoSpinRollers(0.5,5)); + try { + wait(2); + } catch (Exception e) { } + addParallel(new AutoSpinRollers(0.5, 5)); addSequential(new AutoSetShooterState(true)); } } diff --git a/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineShoot.java b/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineShoot.java index 63e54f7..8c46fc6 100644 --- a/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineShoot.java +++ b/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineShoot.java @@ -6,11 +6,11 @@ public class RoutineShoot extends CommandGroup { public RoutineShoot() { addSequential(new AutoSetArmStopState(true)); addSequential(new AutoResetLower(-1)); - addSequential(new AutoDriveStraightTime(0.5,1)); + addSequential(new AutoDriveStraightTime(0.5, 1)); addParallel(new AutoSetArmPosition(90)); addSequential(new AutoRotate(45)); - addSequential(new AutoDriveStraightTime(0.4,1.5)); - addSequential(new AutoSpinRollers(1,2)); + addSequential(new AutoDriveStraightTime(0.4, 1.5)); + addSequential(new AutoSpinRollers(1, 2)); addSequential(new AutoSetShooterState(true)); addSequential(new AutoSetArmStopState(false)); addParallel(new AutoSetArmPosition(10)); diff --git a/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineTwoBallDropOff.java b/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineTwoBallDropOff.java index 7292970..a7c375f 100644 --- a/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineTwoBallDropOff.java +++ b/src/org/usfirst/frc/team2059/robot/commands/autonomous/RoutineTwoBallDropOff.java @@ -6,19 +6,19 @@ public class RoutineTwoBallDropOff extends CommandGroup { public RoutineTwoBallDropOff() { addSequential(new AutoSetArmStopState(true)); addSequential(new AutoResetLower(-1)); - addSequential(new AutoDriveStraightTime(0.5,2)); - addSequential(new AutoMoveArm(0.5,1)); - addSequential(new AutoSpinRollers(1,2)); + addSequential(new AutoDriveStraightTime(0.5, 2)); + addSequential(new AutoMoveArm(0.5, 1)); + addSequential(new AutoSpinRollers(1, 2)); addSequential(new AutoSetShooterState(true)); addSequential(new AutoResetLower(-1)); addSequential(new AutoRotate(180)); addSequential(new AutoSetShooterState(false)); - addParallel(new AutoSpinRollers(-0.5,3)); - addSequential(new AutoDriveStraightTime(0.5,2)); + addParallel(new AutoSpinRollers(-0.5, 3)); + addSequential(new AutoDriveStraightTime(0.5, 2)); addSequential(new AutoRotate(180)); - addSequential(new AutoDriveStraightTime(0.5,2)); - addSequential(new AutoMoveArm(0.5,1)); - addSequential(new AutoSpinRollers(1,2)); + addSequential(new AutoDriveStraightTime(0.5, 2)); + addSequential(new AutoMoveArm(0.5, 1)); + addSequential(new AutoSpinRollers(1, 2)); addSequential(new AutoSetShooterState(true)); addSequential(new AutoRotate(180)); addSequential(new AutoSetShooterState(false)); diff --git a/src/org/usfirst/frc/team2059/robot/commands/drivetrain/PIDDrive.java b/src/org/usfirst/frc/team2059/robot/commands/drivetrain/PIDDrive.java index 4340c42..9d4c177 100644 --- a/src/org/usfirst/frc/team2059/robot/commands/drivetrain/PIDDrive.java +++ b/src/org/usfirst/frc/team2059/robot/commands/drivetrain/PIDDrive.java @@ -16,7 +16,7 @@ public class PIDDrive extends CommandBase { } // Called repeatedly when this Command is scheduled to run protected void execute() { - driveBase.pidDrive(count,SmartDashboard.getNumber("GyroCorrection")); + driveBase.pidDrive(count, SmartDashboard.getNumber("GyroCorrection")); } // Make this return true when this Command no longer needs to run execute() protected boolean isFinished() { diff --git a/src/org/usfirst/frc/team2059/robot/subsystems/DriveBase.java b/src/org/usfirst/frc/team2059/robot/subsystems/DriveBase.java index 3fd6907..2fef2b5 100644 --- a/src/org/usfirst/frc/team2059/robot/subsystems/DriveBase.java +++ b/src/org/usfirst/frc/team2059/robot/subsystems/DriveBase.java @@ -17,9 +17,9 @@ public class DriveBase extends Subsystem { CANTalon rightMotorTwo = new CANTalon(RobotMap.driveRightMotorTwo); Encoder leftEncoder = new Encoder(RobotMap.driveLeftEncoderA, RobotMap.driveLeftEncoderB, false, Encoder.EncodingType.k4X); AnalogGyro gyro = new AnalogGyro(RobotMap.gyro); - PIDController gyroController = new PIDController(0.07,0.002,0.08, new GyroPIDSource(), new MotorsPIDOutputReversed()); + PIDController gyroController = new PIDController(0.07, 0.002, 0.08, new GyroPIDSource(), new MotorsPIDOutputReversed()); PIDController leftEncoderController = new PIDController(0.02, 0.002, 0.017, leftEncoder, new MotorsPIDOutput()); - double encoderGyroCorrection=1; + double encoderGyroCorrection = 1; public void initDefaultCommand() { setDefaultCommand(new Drive()); } @@ -35,40 +35,40 @@ public class DriveBase extends Subsystem { rightMotorOne.set((y + (x + z)) * sensitivity); rightMotorTwo.set((y + (x + z)) * sensitivity); } - public void driveStraight(double y, double correction){ - SmartDashboard.putNumber("GyroAngle",gyro.getAngle()); - leftMotorOne.set((-y + -gyro.getAngle()*correction)); - leftMotorTwo.set((-y + -gyro.getAngle()*correction)); - rightMotorOne.set((y + -gyro.getAngle()*correction)); - rightMotorTwo.set((y + -gyro.getAngle()*correction)); + public void driveStraight(double y, double correction) { + SmartDashboard.putNumber("GyroAngle", gyro.getAngle()); + leftMotorOne.set((-y + -gyro.getAngle() * correction)); + leftMotorTwo.set((-y + -gyro.getAngle() * correction)); + rightMotorOne.set((y + -gyro.getAngle() * correction)); + rightMotorTwo.set((y + -gyro.getAngle() * correction)); } public void pidDrive(double setpoint, double correction) { leftEncoder.reset(); leftEncoderController.enable(); leftEncoderController.setSetpoint(setpoint); - encoderGyroCorrection=-gyro.getAngle()*correction; + encoderGyroCorrection = -gyro.getAngle() * correction; } - public void rotateAngle(double angle){ - SmartDashboard.putNumber("GyroAngle",gyro.getAngle()); + public void rotateAngle(double angle) { + SmartDashboard.putNumber("GyroAngle", gyro.getAngle()); gyroController.enable(); gyroController.setSetpoint(angle); } public PIDController getLeftController() { return leftEncoderController; } - public PIDController getGyroController(){ + public PIDController getGyroController() { return gyroController; } public double getLeftRotations() { return leftEncoder.get(); } - public void resetGyro(){ + public void resetGyro() { gyro.reset(); } - public Encoder getLeftEncoder(){ + public Encoder getLeftEncoder() { return leftEncoder; } - public AnalogGyro getGyro(){ + public AnalogGyro getGyro() { return gyro; } public class MotorsPIDOutput implements PIDOutput { @@ -89,14 +89,14 @@ public class DriveBase extends Subsystem { rightMotorTwo.pidWrite(output); } } - public class GyroPIDSource implements PIDSource{ - public double pidGet(){ + public class GyroPIDSource implements PIDSource { + public double pidGet() { return gyro.getAngle(); } - public PIDSourceType getPIDSourceType(){ + public PIDSourceType getPIDSourceType() { return PIDSourceType.kDisplacement; } - public void setPIDSourceType(PIDSourceType type){ + public void setPIDSourceType(PIDSourceType type) { } } }