Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.usfirst.frc.team6155.robot;
- import edu.wpi.first.wpilibj.Compressor;
- import edu.wpi.first.wpilibj.DoubleSolenoid;
- import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
- import edu.wpi.first.wpilibj.GenericHID.Hand;
- import edu.wpi.first.wpilibj.IterativeRobot;
- import edu.wpi.first.wpilibj.Joystick;
- import edu.wpi.first.wpilibj.SpeedControllerGroup;
- import edu.wpi.first.wpilibj.Timer;
- import edu.wpi.first.wpilibj.VictorSP;
- import edu.wpi.first.wpilibj.XboxController;
- import edu.wpi.first.wpilibj.drive.DifferentialDrive;
- /**
- * The VM is configured to automatically run this class, and to call the
- * functions corresponding to each mode, as described in the IterativeRobot
- * documentation. If you change the name of this class or the package after
- * creating this project, you must also update the manifest file in the resource
- * directory.
- */
- public class Robot extends IterativeRobot {
- VictorSP frontLeftMotor = new VictorSP(0);
- VictorSP rearLeftMotor = new VictorSP(1);
- VictorSP frontRightMotor = new VictorSP(2);
- VictorSP rearRightMotor = new VictorSP(3);
- SpeedControllerGroup leftSide = new SpeedControllerGroup(frontLeftMotor, rearLeftMotor);
- SpeedControllerGroup rightSide = new SpeedControllerGroup(frontRightMotor, rearRightMotor);
- DifferentialDrive myRobot = new DifferentialDrive(leftSide, rightSide);
- XboxController controller = new XboxController(1);
- Joystick stick = new Joystick(2);
- Compressor compressor = new Compressor(0);
- DoubleSolenoid solenoid = new DoubleSolenoid(0, 1);
- Timer timer = new Timer();
- /**
- * This function is run when the robot is first started up and should be
- * used for any initialization code.
- */
- @Override
- public void robotInit() {
- }
- /**
- * This function is called periodically during all robot modes
- */
- @Override
- public void robotPeriodic() {
- }
- /**
- * This function is run once each time the robot enters autonomous mode
- */
- @Override
- public void autonomousInit() {
- timer.reset();
- timer.start();
- }
- /**
- * This function is called periodically during autonomous
- */
- @Override
- public void autonomousPeriodic() {
- }
- /**
- * This function is called once each time the robot enters operator control
- */
- @Override
- public void teleopInit() {
- compressor.start();
- }
- /**
- * This function is called periodically during operator control
- */
- @Override
- public void teleopPeriodic() {
- myRobot.tankDrive(-controller.getY(Hand.kLeft), -controller.getY(Hand.kRight));
- if(stick.getY() > 0) {
- solenoid.set(DoubleSolenoid.Value.kForward);
- } else if(stick.getY() < 0) {
- solenoid.set(DoubleSolenoid.Value.kReverse);
- } else {
- solenoid.set(DoubleSolenoid.Value.kOff);
- }
- }
- /**
- * This function is called once each time the robot enters test mode
- */
- @Override
- public void testInit() {
- }
- /**
- * This function is called periodically during test mode
- */
- @Override
- public void testPeriodic() {
- }
- /**
- * This function is called once each time the robot enters disabled mode
- */
- @Override
- public void disabledInit() {
- }
- /**
- * This function is called periodically during disabled mode
- */
- @Override
- public void disabledPeriodic() {
- }
- }
Add Comment
Please, Sign In to add comment