change lidar ports
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / DriveTrain.java
index a4bba48b5fe7bd276b372f0144995d81493d7daf..203078ccfd7f88d9103b8a6ddf4ac529b6212c4c 100644 (file)
@@ -22,8 +22,7 @@ public class DriveTrain extends PIDSubsystem {
 
   private Encoder leftEncoder, rightEncoder;
 
-  public static Lidar leftLidar;
-  public static Lidar rightLidar;
+  public static Lidar lidar;
 
   private CANTalon frontLeft, frontRight, rearLeft, rearRight;
   private RobotDrive robotDrive;
@@ -45,9 +44,7 @@ public class DriveTrain extends PIDSubsystem {
 
     robotDrive = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight);
 
-    leftLidar = new Lidar(I2C.Port.kOnboard);
-    rightLidar = new Lidar(I2C.Port.kOnboard); // TODO: find port for second
-    // lidar
+    lidar = new Lidar(I2C.Port.kMXP);
     leftEncoder = new Encoder(Constants.DriveTrain.ENCODER_LEFT_A,
         Constants.DriveTrain.ENCODER_LEFT_B, false, EncodingType.k4X);
     rightEncoder = new Encoder(Constants.DriveTrain.ENCODER_RIGHT_A,
@@ -106,12 +103,8 @@ public class DriveTrain extends PIDSubsystem {
     rightEncoder.reset();
   }
 
-  public double getLeftLidarDistance() {
-    return leftLidar.pidGet();
-  }
-
-  public double getsRightLidarDistance() {
-    return rightLidar.pidGet();
+  public double getLidarDistance() {
+    return lidar.pidGet();
   }
 
   public double getRightSpeed() {
@@ -203,10 +196,10 @@ public class DriveTrain extends PIDSubsystem {
   /*
    * Method is a required method that the PID Subsystem uses to return the
    * calculated PID value to the driver
-   *
+   * 
    * @param Gives the user the output from the PID algorithm that is calculated
    * internally
-   *
+   * 
    * Body: Uses the output, does some filtering and drives the robot
    */
   @Override
@@ -234,10 +227,9 @@ public class DriveTrain extends PIDSubsystem {
 
   /*
    * Checks the drive mode
-   *
-   * @return the current state of the robot in each state
-   * Average distance from both sides of tank drive for Encoder Mode
-   * Angle from the gyro in GYRO_MODE
+   * 
+   * @return the current state of the robot in each state Average distance from
+   * both sides of tank drive for Encoder Mode Angle from the gyro in GYRO_MODE
    */
   private double sensorFeedback() {
     if (DRIVE_MODE == Constants.DriveTrain.ENCODER_MODE)
@@ -252,16 +244,14 @@ public class DriveTrain extends PIDSubsystem {
   /*
    * @param left and right setpoints to set to the left and right side of tank
    * inverted is for Logan, wants the robot to invert all controls left = right
-   * and right = left
-   * negative input is required for the regular rotation because RobotDrive
-   * tankdrive method drives inverted
+   * and right = left negative input is required for the regular rotation
+   * because RobotDrive tankdrive method drives inverted
    */
   public void drive(double left, double right) {
     robotDrive.tankDrive(-left, -right);
     // dunno why but inverted drive (- values is forward)
     if (!Constants.DriveTrain.inverted)
-      robotDrive.tankDrive(-left,
-          -right);
+      robotDrive.tankDrive(-left, -right);
     else
       robotDrive.tankDrive(right, left);
   }
@@ -281,9 +271,8 @@ public class DriveTrain extends PIDSubsystem {
   }
 
   /*
-   * Sets the encoder mode
-   * Updates the PID constants sets the tolerance and sets output/input ranges
-   * Enables the PID controllers
+   * Sets the encoder mode Updates the PID constants sets the tolerance and sets
+   * output/input ranges Enables the PID controllers
    */
   public void setEncoderPID() {
     DRIVE_MODE = Constants.DriveTrain.ENCODER_MODE;
@@ -295,9 +284,8 @@ public class DriveTrain extends PIDSubsystem {
   }
 
   /*
-   * Sets the Gyro Mode
-   * Updates the PID constants, sets the tolerance and sets output/input ranges
-   * Enables the PID controllers
+   * Sets the Gyro Mode Updates the PID constants, sets the tolerance and sets
+   * output/input ranges Enables the PID controllers
    */
   private void setGyroPID() {
     DRIVE_MODE = Constants.DriveTrain.GYRO_MODE;
@@ -313,10 +301,10 @@ public class DriveTrain extends PIDSubsystem {
 
   /*
    * Turning method that should be used repeatedly in a command
-   *
+   * 
    * First constrains the angle to within -360 and 360 since that is as much as
    * we need to turn
-   *
+   * 
    * Configures Gyro PID and sets the setpoint as an angle
    */
   public void turnAngle(double angle) {
@@ -335,16 +323,16 @@ public class DriveTrain extends PIDSubsystem {
   }
 
   /*
-   * @return a value that is the current setpoint for the piston
-   * kReverse or kForward
+   * @return a value that is the current setpoint for the piston kReverse or
+   * kForward
    */
   public Value getLeftGearPistonValue() {
     return leftGearPiston.get();
   }
 
   /*
-   * @return a value that is the current setpoint 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();
@@ -371,4 +359,5 @@ public class DriveTrain extends PIDSubsystem {
     leftGearPiston.set(gear);
     rightGearPiston.set(gear);
   }
+
 }