X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2FRobot.java;h=3778ad0e30dbc7d9ff561a2f502ed927610234ca;hb=d1930cd9ed9720c44bc9471b7741f4218f5da842;hp=36ca70bc268a526c02d33f5531c1d8d550fcbe90;hpb=38a404b33adc222b57179884470913cb4c0a011d;p=3501%2F2017steamworks diff --git a/src/org/usfirst/frc/team3501/robot/Robot.java b/src/org/usfirst/frc/team3501/robot/Robot.java index 36ca70b..3778ad0 100644 --- a/src/org/usfirst/frc/team3501/robot/Robot.java +++ b/src/org/usfirst/frc/team3501/robot/Robot.java @@ -1,36 +1,112 @@ package org.usfirst.frc.team3501.robot; -import org.usfirst.frc.team3501.robot.Constants.DriveTrain; +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.cscore.UsbCamera; +import edu.wpi.first.wpilibj.CameraServer; +import edu.wpi.first.wpilibj.DriverStation; 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 { - public static OI oi; - public static DriveTrain driveTrain; + private static DriveTrain driveTrain; + private static Shooter shooter; + private static OI oi; + private static Intake intake; + private static CameraServer server; @Override public void robotInit() { - driveTrain = new DriveTrain(); - oi = new OI(); + driveTrain = DriveTrain.getDriveTrain(); + oi = OI.getOI(); + shooter = Shooter.getShooter(); + intake = Intake.getIntake(); + + server = CameraServer.getInstance(); + UsbCamera climberCam = server.startAutomaticCapture("climbercam", 0); + UsbCamera intakeCam = server.startAutomaticCapture("intakecam", 1); + + driveTrain.setCANTalonsBrakeMode(driveTrain.DRIVE_COAST_MODE); + } + + public static DriveTrain getDriveTrain() { + + return DriveTrain.getDriveTrain(); + } + + public static Shooter getShooter() { + return Shooter.getShooter(); + } + + public static OI getOI() { + return OI.getOI(); } + public static Intake getIntake() { + return Intake.getIntake(); + } + + public static void swapCameraFeed() { + if (Intake.getIntake().getIntakeCameraFeed() == 1) { + UsbCamera climberCam = server.startAutomaticCapture("climbercam", 1); + UsbCamera intakeCam = server.startAutomaticCapture("intakecam", 0); + Intake.getIntake().setIntakeCameraFeed(0); + } else { + UsbCamera climberCam = server.startAutomaticCapture("climbercam", 0); + UsbCamera intakeCam = server.startAutomaticCapture("intakecam", 1); + Intake.getIntake().setIntakeCameraFeed(1); + } + + } + + // 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(); + driveTrain.setCANTalonsBrakeMode(driveTrain.DRIVE_COAST_MODE); } @Override public void autonomousPeriodic() { Scheduler.getInstance().run(); - } @Override public void teleopInit() { + driveTrain.setCANTalonsBrakeMode(driveTrain.DRIVE_COAST_MODE); } @Override public void teleopPeriodic() { + // driveTrain.printEncoderOutput(); Scheduler.getInstance().run(); + updateSmartDashboard(); + } + + @Override + public void disabledInit() { + driveTrain.setCANTalonsBrakeMode(driveTrain.DRIVE_BRAKE_MODE); + } + // + // @Override + // public void disabledPeriodic() { + // Scheduler.getInstance().add(new RunFlyWheel(2)); + // } + public void updateSmartDashboard() { + SmartDashboard.putNumber("left encode ", + driveTrain.getLeftEncoderDistance()); + SmartDashboard.putNumber("right encoder", + driveTrain.getRightEncoderDistance()); + SmartDashboard.putNumber("angle", driveTrain.getAngle()); + SmartDashboard.putNumber("voltage", + DriverStation.getInstance().getBatteryVoltage()); + SmartDashboard.putNumber("rpm", shooter.getShooterRPM()); + SmartDashboard.putNumber("target shooting", + shooter.getTargetShootingSpeed()); } }