fix alot of unnecessary/not used code and init gyroController
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / Robot.java
index 5f4715cb6ac2e9b1fcb8a7e1bef891cc95163eae..44c513d5085fe4fda891a4ab086a838106454f50 100644 (file)
@@ -1,11 +1,13 @@
 package org.usfirst.frc.team3501.robot;
 
+import org.usfirst.frc.team3501.robot.commands.driving.DriveDistance;
 import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
 import org.usfirst.frc.team3501.robot.subsystems.Intake;
 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
 
 import edu.wpi.first.wpilibj.IterativeRobot;
 import edu.wpi.first.wpilibj.command.Scheduler;
+import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
 
 public class Robot extends IterativeRobot {
   private static DriveTrain driveTrain;
@@ -19,10 +21,21 @@ public class Robot extends IterativeRobot {
     oi = OI.getOI();
     shooter = Shooter.getShooter();
     intake = Intake.getIntake();
+
+    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_TARGET_DIST, 50);
+    SmartDashboard.putNumber(driveTrain.DRIVE_MOTOR_VAL, 0.5);
+
+    SmartDashboard.putNumber(driveTrain.GYRO_P_Val, 0);
+    SmartDashboard.putNumber(driveTrain.GYRO_I_Val, 0);
+    SmartDashboard.putNumber(driveTrain.GYRO_D_Val, 0);
+
   }
 
   public static DriveTrain getDriveTrain() {
-    return DriveTrain.getDriveTrain();
+    return driveTrain;
   }
 
   public static Shooter getShooter() {
@@ -37,8 +50,46 @@ public class Robot extends IterativeRobot {
     return Intake.getIntake();
   }
 
+  // If the gear values do not match in the left and right piston, then they are
+  // both set to high gear
   @Override
   public void autonomousInit() {
+    driveTrain.setHighGear();
+
+    double driveP = SmartDashboard.getNumber(driveTrain.DRIVE_D_Val,
+        driveTrain.PID_ERROR);
+    double driveI = SmartDashboard.getNumber(driveTrain.DRIVE_I_Val,
+        driveTrain.PID_ERROR);
+    double driveD = SmartDashboard.getNumber(driveTrain.DRIVE_D_Val,
+        driveTrain.PID_ERROR);
+
+    double gyroP = SmartDashboard.getNumber(driveTrain.GYRO_P_Val,
+        driveTrain.PID_ERROR);
+    double gyroI = SmartDashboard.getNumber(driveTrain.GYRO_I_Val,
+        driveTrain.PID_ERROR);
+    double gyroD = SmartDashboard.getNumber(driveTrain.GYRO_D_Val,
+        driveTrain.PID_ERROR);
+
+    double Setpoint = SmartDashboard.getNumber(driveTrain.DRIVE_TARGET_DIST,
+        driveTrain.PID_ERROR);
+    double Speed = SmartDashboard.getNumber(driveTrain.DRIVE_MOTOR_VAL,
+        driveTrain.PID_ERROR);
+
+    driveTrain.getDriveController().setName("Drive");
+    driveTrain.getGyroController().setName("Gyro");
+
+    driveTrain.getDriveController().setConstants(driveP, driveI, driveD);
+
+    driveTrain.getGyroController().setConstants(gyroP, gyroI, gyroD);
+
+    Scheduler.getInstance().add(new DriveDistance(Setpoint, Speed));
+
+    SmartDashboard.putNumber(Constants.DriveTrain.P_Val, 0);
+    SmartDashboard.putNumber(Constants.DriveTrain.I_Val, 0);
+    SmartDashboard.putNumber(Constants.DriveTrain.D_Val, 0);
+    SmartDashboard.putNumber(Constants.DriveTrain.TARGET_DIST, 50);
+    SmartDashboard.putNumber(Constants.DriveTrain.MOTOR_VAL, 0.5);
+
   }
 
   @Override
@@ -49,11 +100,11 @@ public class Robot extends IterativeRobot {
 
   @Override
   public void teleopInit() {
+
   }
 
   @Override
   public void teleopPeriodic() {
     Scheduler.getInstance().run();
-
   }
 }