8829ed1a2f9c26089c70fc8a7d53d3a488c7ba1d
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / Robot.java
1 package org.usfirst.frc.team3501.robot;
2
3 import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
4 import org.usfirst.frc.team3501.robot.subsystems.Intake;
5 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
6
7 import edu.wpi.first.wpilibj.IterativeRobot;
8 import edu.wpi.first.wpilibj.command.Scheduler;
9 import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
10
11 public class Robot extends IterativeRobot {
12 private static DriveTrain driveTrain;
13 private static Shooter shooter;
14 private static OI oi;
15 private static Intake intake;
16
17 @Override
18 public void robotInit() {
19 driveTrain = DriveTrain.getDriveTrain();
20 oi = OI.getOI();
21 shooter = Shooter.getShooter();
22 intake = Intake.getIntake();
23 }
24
25 public static DriveTrain getDriveTrain() {
26 return driveTrain;
27 }
28
29 public static Shooter getShooter() {
30 return Shooter.getShooter();
31 }
32
33 public static OI getOI() {
34 return OI.getOI();
35 }
36
37 public static Intake getIntake() {
38 return Intake.getIntake();
39 }
40
41 // If the gear values do not match in the left and right piston, then they are
42 // both set to high gear
43 @Override
44 public void autonomousInit() {
45 driveTrain.setHighGear();
46
47 SmartDashboard.putNumber(Constants.DriveTrain.DRIVE_P_Val, 0);
48 SmartDashboard.putNumber(Constants.DriveTrain.DRIVE_I_Val, 0);
49 SmartDashboard.putNumber(Constants.DriveTrain.DRIVE_D_Val, 0);
50 SmartDashboard.putNumber(Constants.DriveTrain.DRIVE_TARGET_DIST, 50);
51 SmartDashboard.putNumber(Constants.DriveTrain.DRIVE_MOTOR_VAL, 0.5);
52
53 SmartDashboard.putNumber(Constants.DriveTrain.GYRO_P_Val, 0);
54 SmartDashboard.putNumber(Constants.DriveTrain.GYRO_I_Val, 0);
55 SmartDashboard.putNumber(Constants.DriveTrain.GYRO_D_Val, 0);
56
57 double driveP = SmartDashboard.getNumber(Constants.DriveTrain.DRIVE_D_Val,
58 Constants.DriveTrain.PID_ERROR);
59 double driveI = SmartDashboard.getNumber(Constants.DriveTrain.DRIVE_I_Val,
60 Constants.DriveTrain.PID_ERROR);
61 double driveD = SmartDashboard.getNumber(Constants.DriveTrain.DRIVE_D_Val,
62 Constants.DriveTrain.PID_ERROR);
63
64 double gyroP = SmartDashboard.getNumber(Constants.DriveTrain.GYRO_P_Val,
65 Constants.DriveTrain.PID_ERROR);
66 double gyroI = SmartDashboard.getNumber(Constants.DriveTrain.GYRO_I_Val,
67 Constants.DriveTrain.PID_ERROR);
68 double gyroD = SmartDashboard.getNumber(Constants.DriveTrain.GYRO_D_Val,
69 Constants.DriveTrain.PID_ERROR);
70
71 double Setpoint = SmartDashboard.getNumber(
72 Constants.DriveTrain.DRIVE_TARGET_DIST, Constants.DriveTrain.PID_ERROR);
73 double Speed = SmartDashboard.getNumber(
74 Constants.DriveTrain.DRIVE_MOTOR_VAL, Constants.DriveTrain.PID_ERROR);
75
76 driveTrain.getDriveController().setName("Drive");
77 driveTrain.getGyroController().setName("Gyro");
78
79 driveTrain.getDriveController().setConstants(driveP, driveI, driveD);
80
81 driveTrain.getGyroController().setConstants(gyroP, gyroI, gyroD);
82
83 }
84
85 @Override
86 public void autonomousPeriodic() {
87 Scheduler.getInstance().run();
88
89 double driveP = SmartDashboard.getNumber(Constants.DriveTrain.DRIVE_D_Val,
90 Constants.DriveTrain.PID_ERROR);
91 double driveI = SmartDashboard.getNumber(Constants.DriveTrain.DRIVE_I_Val,
92 Constants.DriveTrain.PID_ERROR);
93 double driveD = SmartDashboard.getNumber(Constants.DriveTrain.DRIVE_D_Val,
94 Constants.DriveTrain.PID_ERROR);
95
96 double gyroP = SmartDashboard.getNumber(Constants.DriveTrain.GYRO_P_Val,
97 Constants.DriveTrain.PID_ERROR);
98 double gyroI = SmartDashboard.getNumber(Constants.DriveTrain.GYRO_I_Val,
99 Constants.DriveTrain.PID_ERROR);
100 double gyroD = SmartDashboard.getNumber(Constants.DriveTrain.GYRO_D_Val,
101 Constants.DriveTrain.PID_ERROR);
102
103 driveTrain.getDriveController().setName("Drive");
104 driveTrain.getGyroController().setName("Gyro");
105
106 driveTrain.getDriveController().setConstants(driveP, driveI, driveD);
107
108 driveTrain.getGyroController().setConstants(gyroP, gyroI, gyroD);
109
110 // new DriveDistance(SETPOINT, SPEED).start();
111
112 // new TurnForAngle(0, Direction.FORWARD, 5).start();
113 }
114
115 @Override
116 public void teleopInit() {
117
118 }
119
120 @Override
121 public void teleopPeriodic() {
122 Scheduler.getInstance().run();
123 }
124 }