code review changes and add code for braking cantalons
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / Robot.java
CommitLineData
38a404b3
KZ
1package org.usfirst.frc.team3501.robot;
2
cca02549 3import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
6f3b6d29 4import org.usfirst.frc.team3501.robot.subsystems.Intake;
079a8cb6 5import org.usfirst.frc.team3501.robot.subsystems.Shooter;
6acd1f1b 6
5d967c55
CZ
7import edu.wpi.cscore.UsbCamera;
8import edu.wpi.first.wpilibj.CameraServer;
1782cbad 9import edu.wpi.first.wpilibj.DriverStation;
38a404b3
KZ
10import edu.wpi.first.wpilibj.IterativeRobot;
11import edu.wpi.first.wpilibj.command.Scheduler;
1782cbad 12import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
38a404b3
KZ
13
14public class Robot extends IterativeRobot {
6acd1f1b 15 private static DriveTrain driveTrain;
414d5638 16 private static Shooter shooter;
6acd1f1b 17 private static OI oi;
6f3b6d29 18 private static Intake intake;
38a404b3
KZ
19
20 @Override
21 public void robotInit() {
6acd1f1b
CZ
22 driveTrain = DriveTrain.getDriveTrain();
23 oi = OI.getOI();
079a8cb6 24 shooter = Shooter.getShooter();
6f3b6d29 25 intake = Intake.getIntake();
f56e6ebf 26
5d967c55
CZ
27 CameraServer server = CameraServer.getInstance();
28 UsbCamera climberCam = server.startAutomaticCapture("climbercam", 0);
29 UsbCamera intakeCam = server.startAutomaticCapture("intakecam", 1);
f56e6ebf
CZ
30
31 driveTrain.setCANTalonsBrakeMode(driveTrain.DRIVE_COAST_MODE);
cca02549 32 }
6acd1f1b
CZ
33
34 public static DriveTrain getDriveTrain() {
35 return DriveTrain.getDriveTrain();
cca02549 36 }
6acd1f1b 37
414d5638 38 public static Shooter getShooter() {
39 return Shooter.getShooter();
40 }
41
6acd1f1b
CZ
42 public static OI getOI() {
43 return OI.getOI();
38a404b3
KZ
44 }
45
6f3b6d29 46 public static Intake getIntake() {
7992f152
AD
47 return Intake.getIntake();
48 }
49
538715b1
AD
50 // If the gear values do not match in the left and right piston, then they are
51 // both set to high gear
38a404b3
KZ
52 @Override
53 public void autonomousInit() {
202468a5 54 driveTrain.setHighGear();
f56e6ebf 55 driveTrain.setCANTalonsBrakeMode(driveTrain.DRIVE_COAST_MODE);
38a404b3
KZ
56 }
57
58 @Override
59 public void autonomousPeriodic() {
60 Scheduler.getInstance().run();
38a404b3
KZ
61 }
62
63 @Override
64 public void teleopInit() {
f56e6ebf 65 driveTrain.setCANTalonsBrakeMode(driveTrain.DRIVE_COAST_MODE);
38a404b3
KZ
66 }
67
68 @Override
69 public void teleopPeriodic() {
f56e6ebf 70 // driveTrain.printEncoderOutput();
88ecb8d3 71 Scheduler.getInstance().run();
1782cbad
CZ
72 updateSmartDashboard();
73 }
74
f56e6ebf
CZ
75 @Override
76 public void disabledInit() {
77 driveTrain.setCANTalonsBrakeMode(driveTrain.DRIVE_BRAKE_MODE);
78 }
79 //
80 // @Override
81 // public void disabledPeriodic() {
82 // Scheduler.getInstance().add(new RunFlyWheel(2));
83 // }
84
1782cbad 85 public void updateSmartDashboard() {
f56e6ebf
CZ
86 SmartDashboard.putNumber("left encode ",
87 driveTrain.getLeftEncoderDistance());
88 SmartDashboard.putNumber("right encoder",
89 driveTrain.getRightEncoderDistance());
1782cbad
CZ
90 SmartDashboard.putNumber("angle", driveTrain.getAngle());
91 SmartDashboard.putNumber("voltage",
92 DriverStation.getInstance().getBatteryVoltage());
93 SmartDashboard.putNumber("rpm", shooter.getShooterRPM());
f56e6ebf
CZ
94 SmartDashboard.putNumber("target shooting",
95 shooter.getTargetShootingSpeed());
38a404b3
KZ
96 }
97}