SHARE
TWEET

Team 988 Robot Code

Arnatious Feb 18th, 2012 31 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*----------------------------------------------------------------------------*/
  2. /* Copyright (c) FIRST 2008. All Rights Reserved.                             */
  3. /* Open Source Software - may be modified and shared by FRC teams. The code   */
  4. /* must be accompanied by the FIRST BSD license file in the root directory of */
  5. /* the project.                                                               */
  6. /*----------------------------------------------------------------------------*/
  7.  
  8. package edu.wpi.first.wpilibj.templates;
  9.  
  10.  
  11. import edu.wpi.first.wpilibj.SimpleRobot;
  12. import edu.wpi.first.wpilibj.Jaguar;
  13. import edu.wpi.first.wpilibj.Victor;
  14. import edu.wpi.first.wpilibj.Joystick;
  15. import edu.wpi.first.wpilibj.Timer;
  16. import edu.wpi.first.wpilibj.RobotDrive;
  17.  
  18. public class BotCode extends SimpleRobot
  19. {
  20.     RobotDrive drive = new RobotDrive(1,2);
  21.     Jaguar fireLeft = new Jaguar(3);
  22.     Jaguar fireRight = new Jaguar(4);
  23.     //Victor ballSucker = new Victor(5);
  24.     Victor ballFlap = new Victor(6);
  25.    
  26.     Joystick leftStick = new Joystick(1);
  27.     Joystick rightStick = new Joystick(2);
  28.     double FIRE_SPEED = 0.0;
  29.  
  30.     public BotCode()
  31.     {
  32.         drive.setSafetyEnabled(false);
  33.     }
  34.  
  35.     public void autonomous()
  36.     {
  37.         /*Kinect Code currently in 988KinectTester. Copy it from there later. That means you, future me.*/
  38.     }
  39.  
  40.     public void operatorControl()
  41.     {
  42.         while (isOperatorControl() && isEnabled())
  43.         {
  44.  
  45.             tankDrive(leftStick,rightStick);
  46.             if (rightStick.getRawButton(1)) fusRohDah();
  47.             if (leftStick.getRawButton(1)) dahRohFus();
  48.             if (leftStick.getRawButton(2)) ballSucker.set(.50);
  49.             if (leftStick.getRawButton(3)) ballSucker.set(-.50);
  50.  
  51.             if (rightStick.getRawButton(8)) ballFlap.set(.50);
  52.             if (rightStick.getRawButton(6)) ballFlap.set(-.50);
  53.             if (rightStick.getRawButton(7)) ballFlap.set(0);
  54.             if (rightStick.getRawButton(3)) FIRE_SPEED += 0.001;
  55.             if (rightStick.getRawButton(2)) FIRE_SPEED += -0.001;
  56.             if (rightStick.getRawButton(10)) ballSucker.set(-.50);
  57.             if (rightStick.getRawButton(11)) ballSucker.set(0);
  58.             if (rightStick.getRawButton(9)) ballSucker.set(.50);
  59.  
  60.            
  61.             Timer.delay(0.005);
  62.         }
  63.     }
  64.  
  65.     public void fusRohDah()
  66.     {
  67.        fireRight.set(-FIRE_SPEED);
  68.        fireLeft.set(FIRE_SPEED);
  69.     }
  70.     public void dahRohFus()
  71.     {
  72.        fireRight.set(0);
  73.        fireLeft.set(0);
  74.     }
  75.  
  76.     public void tankDrive(Joystick leftStick, Joystick rightStick) {
  77.         if (leftStick == null || rightStick == null) {
  78.             throw new NullPointerException("Null HID provided");
  79.         }
  80.         drive.tankDrive(leftStick.getY(), -rightStick.getY());
  81.     }
  82.  
  83. }
RAW Paste Data
Top