Wrote method to get rightGearPistonValue
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / subsystems / DriveTrain.java
index fd6530e5404d26a08985c7abe5df66f555e69af6..0dda452b7a325230667e6636da28bd78eff38dff 100644 (file)
@@ -10,6 +10,7 @@ import edu.wpi.first.wpilibj.ADXRS450_Gyro;
 import edu.wpi.first.wpilibj.DoubleSolenoid;
 import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
 import edu.wpi.first.wpilibj.Encoder;
+import edu.wpi.first.wpilibj.I2C.Port;
 import edu.wpi.first.wpilibj.RobotDrive;
 import edu.wpi.first.wpilibj.command.Subsystem;
 
@@ -62,6 +63,15 @@ public class DriveTrain extends Subsystem {
         Constants.DriveTrain.LEFT_FORWARD, Constants.DriveTrain.LEFT_REVERSE);
     rightGearPiston = new DoubleSolenoid(Constants.DriveTrain.MODULE_NUMBER,
         Constants.DriveTrain.RIGHT_FORWARD, Constants.DriveTrain.RIGHT_REVERSE);
+
+    this.imu = BNO055.getInstance(BNO055.opmode_t.OPERATION_MODE_IMUPLUS,
+        BNO055.vector_type_t.VECTOR_EULER, Port.kOnboard, (byte) 0x28);
+    gyroZero = imu.getHeading();
+
+    leftGearPiston = new DoubleSolenoid(Constants.DriveTrain.MODULE_NUMBER,
+        Constants.DriveTrain.LEFT_FORWARD, Constants.DriveTrain.LEFT_REVERSE);
+    rightGearPiston = new DoubleSolenoid(Constants.DriveTrain.MODULE_NUMBER,
+        Constants.DriveTrain.RIGHT_FORWARD, Constants.DriveTrain.RIGHT_REVERSE);
   }
 
   public static DriveTrain getDriveTrain() {
@@ -110,6 +120,8 @@ public class DriveTrain extends Subsystem {
     // System.out.println("left: " + getLeftEncoderDistance());
     // System.out.println("right: " + getRightEncoderDistance());
     System.out.println(getAvgEncoderDistance());
+    System.out.println("left: " + getLeftEncoderDistance());
+    System.out.println("right: " + getRightEncoderDistance());
   }
 
   public double getAvgEncoderDistance() {
@@ -140,10 +152,22 @@ public class DriveTrain extends Subsystem {
 
   public void resetGyro() {
     this.imu.reset();
+
+  public double getAngle() {
+    if (!this.imu.isInitialized())
+      return -1;
+    return this.imu.getHeading() - this.gyroZero;
+  }
+
+  public void resetGyro() {
+    this.gyroZero = this.getAngle();
+
   }
 
   public double getZeroAngle() {
     return this.gyroZero;
+  }
+
   /*
    * @return a value that is the current setpoint for the piston kReverse or
    * KForward
@@ -153,8 +177,8 @@ public class DriveTrain extends Subsystem {
   }
 
   /*
-   * @return a value that is the current setppoint for the piston kReverse or
-   * kForward
+   * @return a value that is the current setpoint for the piston kReverse or
+   * KForward
    */
   public Value getRightGearPistonValue() {
     return rightGearPiston.get();
@@ -182,21 +206,6 @@ public class DriveTrain extends Subsystem {
     rightGearPiston.set(gear);
   }
 
-  public double getAngle() {
-    if (!this.imu.isInitialized())
-      return -1;
-    return this.imu.getHeading() - this.gyroZero;
-  }
-
-  public void resetGyro() {
-    this.gyroZero = this.getAngle();
-
-  }
-
-  public double getZeroAngle() {
-    return this.gyroZero;
-  }
-
   @Override
   protected void initDefaultCommand() {
     setDefaultCommand(new JoystickDrive());