update code
authorEric Sandoval <harpnart@gmail.com>
Sun, 19 Feb 2017 22:02:51 +0000 (14:02 -0800)
committerEric Sandoval <harpnart@gmail.com>
Sun, 19 Feb 2017 22:02:51 +0000 (14:02 -0800)
src/org/usfirst/frc/team3501/robot/OI.java
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 29fc9aa348afdf224d1071e2b28c06aa5d7d8e18..cae940f3a499a8ee96229858d82c003f21ed6c00 100644 (file)
@@ -1,7 +1,5 @@
 package org.usfirst.frc.team3501.robot;
 
-import org.usfirst.frc.team3501.robot.commands.climber.MaintainClimbedPosition;
-import org.usfirst.frc.team3501.robot.commands.climber.RunWinchContinuous;
 import org.usfirst.frc.team3501.robot.commands.climber.ToggleWinch;
 import org.usfirst.frc.team3501.robot.commands.driving.ToggleGear;
 import org.usfirst.frc.team3501.robot.commands.intake.ReverseIntakeContinuous;
@@ -74,14 +72,6 @@ public class OI {
         Constants.OI.DECREASE_SHOOTER_SPEED_PORT);
     decreaseShooterSpeed.whenPressed(new DecreaseShootingSpeed());
 
-    if (!isClimbing) {
-      toggleWinch.whenPressed(new RunWinchContinuous());
-      isClimbing = true;
-    } else {
-      toggleWinch.whenPressed(new MaintainClimbedPosition());
-      isClimbing = false;
-    }
-
     /*
      * if (!Robot.getDriveTrain().isClimbing()) { toggleWinch.whenPressed(new
      * RunWinchContinuous()); Robot.getDriveTrain().setClimbing(true); } else {
index 0d736310e1dadd5cbd7fc42c45a59c99b2fae843..6388d0a171251eeebe101070816315715c7be208 100644 (file)
@@ -25,6 +25,8 @@ public class Robot extends IterativeRobot {
     SmartDashboard.putNumber(driveTrain.DRIVE_P_Val, 0);
     SmartDashboard.putNumber(driveTrain.DRIVE_I_Val, 0);
     SmartDashboard.putNumber(driveTrain.DRIVE_D_Val, 0);
+    SmartDashboard.putNumber(driveTrain.DRIVE_GYRO_P_Val, 0);
+
     SmartDashboard.putNumber(driveTrain.DRIVE_TARGET_DIST, 50);
     SmartDashboard.putNumber(driveTrain.MAX_TIME_OUT, 10);
 
@@ -77,11 +79,12 @@ public class Robot extends IterativeRobot {
 
     driveTrain.getDriveController().setName("Drive");
     driveTrain.getGyroController().setName("Gyro");
-    driveTrain.getDriveController().setConstants(driveP, driveI, driveD);
 
+    driveTrain.getDriveController().setConstants(driveP, driveI, driveD);
     driveTrain.getGyroController().setConstants(gyroP, gyroI, gyroD);
 
-    Scheduler.getInstance().add(new DriveDistance(setpoint, maxTimeOut));
+    Scheduler.getInstance()
+        .add(new DriveDistance(setpoint, maxTimeOut));
   }
 
   @Override
index bd923a2af73427ffa69ad842431c1736feb4a12e..cb8227f16017bdde5ef8c0c04c54ed645faad3a6 100755 (executable)
@@ -6,6 +6,7 @@ import org.usfirst.frc.team3501.robot.utils.PIDController;
 
 import edu.wpi.first.wpilibj.Preferences;
 import edu.wpi.first.wpilibj.command.Command;
+import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
 
 /**
  * This command makes the robot drive a specified distance using encoders on the
@@ -22,11 +23,13 @@ public class DriveDistance extends Command {
   private Preferences prefs;
   private PIDController driveController;
 
-  private double gyroP;
+  private double driveStraightGyroP;
 
   public DriveDistance(double distance, double maxTimeOut) {
     requires(driveTrain);
     this.target = distance;
+    driveStraightGyroP = SmartDashboard.getNumber(driveTrain.DRIVE_GYRO_P_Val,
+        driveTrain.PID_ERROR);
 
     this.driveController = driveTrain.getDriveController();
     this.driveController.setDoneRange(0.5);
@@ -42,12 +45,18 @@ public class DriveDistance extends Command {
 
   @Override
   protected void execute() {
-    double xVal = gyroP * (driveTrain.getAngle() - zeroAngle);
+    double xVal = driveStraightGyroP * (driveTrain.getAngle() - zeroAngle);
     double yVal = driveController.calcPID(driveTrain.getAvgEncoderDistance());
 
     double leftDrive = yVal - xVal;
     double rightDrive = yVal + xVal;
     this.driveTrain.setMotorValues(leftDrive, rightDrive);
+
+    System.out.println(
+        "PID VALS: " + driveController.getP() + " " + driveController.getI()
+            + " " + driveController.getD());
+
+    System.out.println(driveTrain.getAvgEncoderDistance());
   }
 
   @Override
index c832b8fc1f6109c5abf3a2d76d0056d263c67bb8..1196d168f3e109618b469702abc47e34780566e3 100644 (file)
@@ -21,6 +21,7 @@ public class DriveTrain extends Subsystem {
   public static final String DRIVE_P_Val = "DriveP";
   public static final String DRIVE_I_Val = "DriveI";
   public static final String DRIVE_D_Val = "DriveD";
+  public static final String DRIVE_GYRO_P_Val = "DriveGyroP";
   public static final String DRIVE_TARGET_DIST = "SET_DIST";
   public static final String MAX_TIME_OUT = "MaxTimeOut";
   public static final String GYRO_P_Val = "GyroP";
@@ -30,7 +31,7 @@ public class DriveTrain extends Subsystem {
   public static final int PID_ERROR = -1;
   public static final int TARGET_DISTANCE_ERROR = -1;
 
-  public static final double WHEEL_DIAMETER = 6; // inches
+  public static final double WHEEL_DIAMETER = 4; // inches
   public static final int ENCODER_PULSES_PER_REVOLUTION = 256;
   public static final double INCHES_PER_PULSE = WHEEL_DIAMETER * Math.PI
       / ENCODER_PULSES_PER_REVOLUTION;