SHARE
TWEET

Robot2013.java

a guest Feb 16th, 2013 9 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package edu.wpi.first.wpilibj.templates;
  2.  
  3. import edu.wpi.first.wpilibj.Relay;
  4. import edu.wpi.first.wpilibj.SimpleRobot;
  5. import edu.wpi.first.wpilibj.Timer;
  6.  
  7. public class Robot2013 extends SimpleRobot {
  8.    
  9.     public static final double REFRESH_RATE = 0.05;
  10.    
  11.     private DriveStation driveStation;
  12.    
  13.     private static boolean auto;
  14.     private static boolean teleop;
  15.    
  16.     public Robot2013() {
  17.         getWatchdog().setEnabled(false);
  18.         this.driveStation = new DriveStation();
  19.         new Relay(1).set(Relay.Value.kForward);
  20.     }
  21.    
  22.     public void autonomous() {
  23.         auto = true;
  24.         teleop = false;
  25.         if(isAutonomousMode() && isEnabled())
  26.         {
  27.             driveStation.autonomousControl();
  28.             driveStation.updateLCD();
  29.         }
  30.     }
  31.    
  32.     public void operatorControl() {
  33.         auto = false;
  34.         teleop = true;
  35.         driveStation.updateLCD();
  36.         while (isOperatorControl() && isEnabled()) {
  37.             driveStation.operatorControl();
  38.             Timer.delay(REFRESH_RATE);
  39.         }
  40.     }
  41.    
  42.     public boolean isAutonomousMode() {
  43.         return (isAutonomous() && isEnabled());
  44.     }
  45.    
  46.     public boolean isOperatorMode() {
  47.         return (this.isOperatorControl() && isEnabled());
  48.     }
  49.    
  50.     public static boolean isAuto()
  51.     {
  52.         return auto;
  53.     }
  54.     public static boolean isTeleop()
  55.     {
  56.         return teleop;
  57.     }
  58. }
RAW Paste Data
Top