fix alot of unnecessary/not used code and init gyroController
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / Robot.java
index b24596c7f84f93f3546dd6375fe6a046828781cc..44c513d5085fe4fda891a4ab086a838106454f50 100644 (file)
@@ -1,5 +1,6 @@
 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;
@@ -20,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() {
@@ -44,8 +56,39 @@ public class Robot extends IterativeRobot {
   public void autonomousInit() {
     driveTrain.setHighGear();
 
-    SmartDashboard.putNumber(Constants.DriveTrain.I_Val, -1);
-    SmartDashboard.putNumber(Constants.DriveTrain.D_Val, -1);
+    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);
 
   }
 
@@ -53,8 +96,6 @@ public class Robot extends IterativeRobot {
   public void autonomousPeriodic() {
     Scheduler.getInstance().run();
 
-    DriveTrain.getDriveTrain().getDriveController().setConstants(p, i, d);
-
   }
 
   @Override