Add hig/low gear changing methods and corresponding constants in master
authorKevin Zhang <icestormf1@gmail.com>
Mon, 15 Feb 2016 00:10:37 +0000 (16:10 -0800)
committerKevin Zhang <icestormf1@gmail.com>
Mon, 15 Feb 2016 00:10:37 +0000 (16:10 -0800)
src/org/usfirst/frc/team3501/robot/Constants.java
src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java

index fd77fdaebb9c8b2c66e35ccbe76d893bc9d128a4..e12b1e44373ffa84120f95b9f2eabf75ec8ebe52 100644 (file)
@@ -1,6 +1,7 @@
 package org.usfirst.frc.team3501.robot;
 
 import edu.wpi.first.wpilibj.DoubleSolenoid;
+import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
 
 /**
  * The Constants stores constant values for all subsystems. This includes the
@@ -48,6 +49,11 @@ public class Constants {
     public static final int LEFT_FORWARD = 0, LEFT_REVERSE = 1,
         RIGHT_FORWARD = 2, RIGHT_REVERSE = 3;
     public static double time = 0;
+
+    // Gearing constants
+    public static final Value HIGH_GEAR = DoubleSolenoid.Value.kForward;
+    public static final Value LOW_GEAR = DoubleSolenoid.Value.kReverse;
+
   }
 
   public static class Scaler {
index 56d8066b49d800df8924018a3f4c7844ddb5e2a5..de2626bed86e43a5e5fdddde5eca8ab2374f471b 100644 (file)
@@ -15,6 +15,8 @@ import edu.wpi.first.wpilibj.RobotDrive;
 import edu.wpi.first.wpilibj.command.PIDSubsystem;
 
 public class DriveTrain extends PIDSubsystem {
+  private static double kp = 0.013, ki = 0.000015, kd = -0.002;
+  private static double gp = 0.018, gi = 0.000015, gd = 0;
   private static double pidOutput = 0;
   private static double encoderTolerance = 8.0, gyroTolerance = 5.0;
   private int DRIVE_MODE = 1;
@@ -40,7 +42,7 @@ public class DriveTrain extends PIDSubsystem {
   // Drivetrain specific constants that relate to the PID controllers
   private final static double Kp = 1.0, Ki = 0.0,
       Kd = 0.0 * (OUTPUT_SPROCKET_DIAMETER / PULSES_PER_ROTATION)
-      / (WHEEL_SPROCKET_DIAMETER) * WHEEL_DIAMETER;
+          / (WHEEL_SPROCKET_DIAMETER) * WHEEL_DIAMETER;
 
   public DriveTrain() {
     super(kp, ki, kd);
@@ -105,14 +107,6 @@ public class DriveTrain extends PIDSubsystem {
     rightEncoder.reset();
   }
 
-  public Value getLeftGearPistonValue() {
-    return leftGearPiston.get();
-  }
-
-  public Value getRightGearPistonValue() {
-    return rightGearPiston.get();
-  }
-
   public double getRightSpeed() {
     return rightEncoder.getRate(); // in inches per second
   }
@@ -271,6 +265,24 @@ public class DriveTrain extends PIDSubsystem {
     rearRight.set(right);
   }
 
-  private static double kp = 0.013, ki = 0.000015, kd = -0.002;
-  private static double gp = 0.018, gi = 0.000015, gd = 0;
+  public Value getLeftGearPistonValue() {
+    return leftGearPiston.get();
+  }
+
+  public Value getRightGearPistonValue() {
+    return rightGearPiston.get();
+  }
+
+  public void setHighGear() {
+    changeGear(Constants.DriveTrain.HIGH_GEAR);
+  }
+
+  public void setLowGear() {
+    changeGear(Constants.DriveTrain.LOW_GEAR);
+  }
+
+  public void changeGear(DoubleSolenoid.Value gear) {
+    leftGearPiston.set(gear);
+    rightGearPiston.set(gear);
+  }
 }