From f675bae4f34fbfafac79bb38cced9ca96d025be8 Mon Sep 17 00:00:00 2001 From: Harel Dor Date: Tue, 22 Mar 2016 16:16:14 -0700 Subject: [PATCH] Minor fixes after merging --- .../usfirst/frc/team3501/robot/Constants.java | 7 +----- src/org/usfirst/frc/team3501/robot/Robot.java | 15 ++++-------- .../robot/commands/driving/TimeDrive.java | 2 +- .../robot/commands/intakearm/Photogate.java | 19 +++++++-------- .../team3501/robot/subsystems/DriveTrain.java | 24 ++----------------- 5 files changed, 17 insertions(+), 50 deletions(-) diff --git a/src/org/usfirst/frc/team3501/robot/Constants.java b/src/org/usfirst/frc/team3501/robot/Constants.java index 14714a72..d63f88d3 100644 --- a/src/org/usfirst/frc/team3501/robot/Constants.java +++ b/src/org/usfirst/frc/team3501/robot/Constants.java @@ -37,10 +37,6 @@ public class Constants { } public static class DriveTrain { - public static final int TANK = 0; - public static final int ARCADE = 1; - public static final int DRIVE_TYPE = TANK; - // Limits changes in speed during joystick driving public static final double kADJUST = 8; @@ -64,8 +60,7 @@ public class Constants { public final static int ENCODER_RIGHT_A = 3; public final static int ENCODER_RIGHT_B = 4; - public static final double INCHES_PER_PULSE = ((3.66 / 5.14) * 6 * Math.PI) - / 256; + public static final double INCHES_PER_PULSE = ((3.66 / 5.14) * 6 * Math.PI) / 256; public static double kp = 0.013, ki = 0.000015, kd = -0.002; public static double encoderTolerance = 8.0; diff --git a/src/org/usfirst/frc/team3501/robot/Robot.java b/src/org/usfirst/frc/team3501/robot/Robot.java index 1fe6b763..ee2e03da 100644 --- a/src/org/usfirst/frc/team3501/robot/Robot.java +++ b/src/org/usfirst/frc/team3501/robot/Robot.java @@ -1,6 +1,5 @@ package org.usfirst.frc.team3501.robot; -import org.usfirst.frc.team3501.robot.Constants.Auton; import org.usfirst.frc.team3501.robot.Constants.Defense; import org.usfirst.frc.team3501.robot.commands.auton.ChooseStrategy; import org.usfirst.frc.team3501.robot.commands.driving.SetLowGear; @@ -31,9 +30,9 @@ public class Robot extends IterativeRobot { driveTrain = new DriveTrain(); shooter = new Shooter(); intakeArm = new IntakeArm(); + photogate = new Photogate(); oi = new OI(); - photogate = new Photogate(); defenseChooser = new SendableChooser(); addDefenseOptions(defenseChooser); @@ -52,16 +51,12 @@ public class Robot extends IterativeRobot { private void addDefenseOptions(SendableChooser chooser) { chooser.addDefault("Portcullis", Defense.PORTCULLIS); chooser.addObject("Sally Port", Defense.SALLY_PORT); - chooser.addObject("Rough Terrain" + Auton.ROUGH_TERRAIN_SPEED + " " - + Auton.ROUGH_TERRAIN_TIME, Defense.ROUGH_TERRAIN); - chooser.addObject("Low Bar" + " Will probably work...", Defense.LOW_BAR); + chooser.addObject("Rough Terrain", Defense.ROUGH_TERRAIN); + chooser.addObject("Low Bar", Defense.LOW_BAR); chooser.addObject("Chival De Frise", Defense.CHIVAL_DE_FRISE); chooser.addObject("Drawbridge", Defense.DRAWBRIDGE); - chooser.addObject("Moat" + Auton.MOAT_SPEED + " " + Auton.MOAT_TIME, - Defense.MOAT); - chooser.addObject( - "Rock Wall" + Auton.ROCK_WALL_SPEED + " " + Auton.ROCK_WALL_TIME, - Defense.ROCK_WALL); + chooser.addObject("Moat", Defense.MOAT); + chooser.addObject("Rock Wall", Defense.ROCK_WALL); chooser.addObject("No Auton", Defense.NONE); } diff --git a/src/org/usfirst/frc/team3501/robot/commands/driving/TimeDrive.java b/src/org/usfirst/frc/team3501/robot/commands/driving/TimeDrive.java index e4c1d75b..89cac8bc 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/driving/TimeDrive.java +++ b/src/org/usfirst/frc/team3501/robot/commands/driving/TimeDrive.java @@ -38,7 +38,7 @@ public class TimeDrive extends Command { @Override protected boolean isFinished() { - return time >= time; + return timer.get() >= time; } @Override diff --git a/src/org/usfirst/frc/team3501/robot/commands/intakearm/Photogate.java b/src/org/usfirst/frc/team3501/robot/commands/intakearm/Photogate.java index aff5fc2d..bf0c7b07 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/intakearm/Photogate.java +++ b/src/org/usfirst/frc/team3501/robot/commands/intakearm/Photogate.java @@ -7,7 +7,7 @@ import edu.wpi.first.wpilibj.AnalogInput; * reflective method to sense the presence of the boulder within the robot's * shooting chamber. This class specifically checks for the ball's presence * using a threshold of voltages outputted from the phototransistor. - * + * * @author niyatisriram */ public class Photogate extends AnalogInput { @@ -17,22 +17,19 @@ public class Photogate extends AnalogInput { /*** * The constructor inputs the channel of the transistor and the threshold - * value. - * The threshold is a specific value, representing the outputted voltage of - * the phototransistor. This value will be somewhere within the range [0, - * 4095] Find the value by testing and finding an average value for which the - * ball is present when the output is greater, and absent when the output is - * less. + * value. The threshold is a specific value, representing the outputted + * voltage of the phototransistor. This value will be somewhere within the + * range [0, 4095] Find the value by testing and finding an average value for + * which the ball is present when the output is greater, and absent when the + * output is less. */ public Photogate() { super(0); - this.threshold = threshold; - } /*** - * @return whether the ball is present or not - * USE TO DECIDE WHEN OUTTAKE NEEDS TO HAPPEN FOR BALL TO BE SECURE + * @return whether the ball is present or not USE TO DECIDE WHEN OUTTAKE NEEDS + * TO HAPPEN FOR BALL TO BE SECURE */ public boolean isBallPresent() { if (this.getVoltage() > threshold) { diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java b/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java index 1a4e6e5b..a0134a43 100644 --- a/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java @@ -194,35 +194,15 @@ public class DriveTrain extends PIDSubsystem { } public void joystickDrive(double left, double right) { - int type = Constants.DriveTrain.DRIVE_TYPE; - // Handle flipping of the "front" of the robot double k = (isFlipped() ? -1 : 1); - robotDrive.tankDrive(-left, -right); - - // if (type == Constants.DriveTrain.TANK) { - // // TODO Test this for negation and for voltage vs. [-1,1] outputs - // double leftSpeed = (-frontLeft.get() + -rearLeft.get()) / 2; - // double rightSpeed = (-frontRight.get() + -rearRight.get()) / 2; - // left = ((Constants.DriveTrain.kADJUST - 1) * leftSpeed + left) - // / Constants.DriveTrain.kADJUST; - // right = ((Constants.DriveTrain.kADJUST - 1) * rightSpeed + right) - // / Constants.DriveTrain.kADJUST; - // robotDrive.tankDrive(-left * k, -right * k); - // } else if (type == Constants.DriveTrain.ARCADE) { - // double speed = (-frontLeft.get() + -rearLeft.get() + -frontRight.get() + - // -rearRight - // .get()) / 2; - // left = ((Constants.DriveTrain.kADJUST - 1) * speed + left) - // / Constants.DriveTrain.kADJUST; - // robotDrive.arcadeDrive(left * k, right); - // } + robotDrive.tankDrive(-left * k, -right * k); } public void setMotorSpeeds(double left, double right) { double k = (isFlipped() ? -1 : 1); - robotDrive.tankDrive(-left, -right); + robotDrive.tankDrive(-left * k, -right * k); } /** -- 2.30.2