fix bugs
authorCindy Zhang <cindyzyx9@gmail.com>
Fri, 27 Jan 2017 03:36:14 +0000 (19:36 -0800)
committerArunima DIvya <adivya822@student.fuhsd.org>
Fri, 3 Feb 2017 03:21:03 +0000 (19:21 -0800)
src/org/usfirst/frc/team3501/robot/Robot.java
src/org/usfirst/frc/team3501/robot/commands/driving/DriveDistance.java
src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java

index 5f4715cb6ac2e9b1fcb8a7e1bef891cc95163eae..908a52dcf0339b44735147d174f069500b873280 100644 (file)
@@ -1,5 +1,9 @@
 package org.usfirst.frc.team3501.robot;
 
+<<<<<<< HEAD
+=======
+import org.usfirst.frc.team3501.robot.commands.driving.DriveDistance;
+>>>>>>> fix bugs
 import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
 import org.usfirst.frc.team3501.robot.subsystems.Intake;
 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
@@ -39,6 +43,10 @@ public class Robot extends IterativeRobot {
 
   @Override
   public void autonomousInit() {
+<<<<<<< HEAD
+=======
+    Scheduler.getInstance().add(new DriveDistance(25, 10));
+>>>>>>> fix bugs
   }
 
   @Override
index 76bc52fef569641a5b3c7a2d1c8d9cc592602505..2b77348e781bf917e5755b9464b9b2bb168edee7 100755 (executable)
@@ -1,6 +1,5 @@
 package org.usfirst.frc.team3501.robot.commands.driving;
 
-import org.usfirst.frc.team3501.robot.MathLib;
 import org.usfirst.frc.team3501.robot.Robot;
 import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
 import org.usfirst.frc.team3501.robot.utils.PIDController;
@@ -47,6 +46,9 @@ public class DriveDistance extends Command {
 
   public DriveDistance(double distance, double motorVal) {
     requires(driveTrain);
+    this.maxTimeOut = maxTimeOut;
+    this.target = distance;
+
     this.driveP = driveTrain.driveP;
     this.driveI = driveTrain.driveI;
     this.driveD = driveTrain.driveD;
@@ -89,12 +91,12 @@ public class DriveDistance extends Command {
 
     driveTrain.printEncoderOutput();
     // System.out.println("turn: " + xVal);
-    double leftDrive = MathLib.calcLeftTankDrive(-xVal, yVal);
-    double rightDrive = MathLib.calcRightTankDrive(xVal, -yVal);
+    double leftDrive = yVal - xVal;
+    double rightDrive = yVal + xVal;
 
     this.driveTrain.setMotorValues(leftDrive, rightDrive);
 
-    System.out.println(driveTrain.getAvgEncoderDistance());
+    driveTrain.printEncoderOutput();
     // System.out.println("motorval: " + yVal);
   }
 
index fd6530e5404d26a08985c7abe5df66f555e69af6..f69167241f16cd85bff6fd3d3f48788a1df90014 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,10 @@ 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();
   }
 
   public static DriveTrain getDriveTrain() {
@@ -110,6 +115,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() {