SHARE
TWEET

Untitled

a guest Feb 12th, 2011 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "WPILib.h"
  2.  
  3. class Robot : public SimpleRobot
  4. {
  5.         RobotDrive myRobot;
  6.        
  7.         Jaguar leftJaguar;
  8.         Jaguar rightJaguar;
  9.        
  10.         Joystick leftStick;
  11.         Joystick rightStick;
  12.         Servo servo;
  13.        
  14.         Relay relay;
  15.         Compressor compressor;
  16.        
  17.         Solenoid solenoidRetract1;
  18.         Solenoid solenoidExtend1;
  19.        
  20.         Solenoid solenoidRetract2;
  21.         Solenoid solenoidExtend2;
  22.        
  23. public:
  24.         Robot(void):
  25.                 myRobot(1, 2), 
  26.                
  27.                 leftJaguar(1),
  28.                 rightJaguar(2),
  29.                
  30.                 leftStick(1),
  31.                 rightStick(2),
  32.                
  33.                 servo(3),
  34.                
  35.                 relay(1),
  36.                 compressor(1, 1),
  37.                
  38.                 solenoidRetract1(2),
  39.                 solenoidExtend1(1),
  40.                
  41.                 solenoidRetract2(4),
  42.                 solenoidExtend2(3)
  43.         {
  44.                 compressor.Start();
  45.                 myRobot.SetExpiration(0.1);
  46.         }
  47.  
  48.         void Autonomous(void)
  49.         {
  50.                 myRobot.SetSafetyEnabled(true);
  51.                
  52.                 AxisCamera& camera = camera.GetInstance();
  53.  
  54.                 while(IsAutonomous())
  55.                 {
  56.                        
  57.                 }
  58.         }
  59.  
  60.         void OperatorControl(void)
  61.         {
  62.                 myRobot.SetSafetyEnabled(true);
  63.                                                
  64.                 AxisCamera& camera = camera.GetInstance();
  65.                
  66.                 while (IsOperatorControl())
  67.                 {                              
  68.                        
  69.                         if (leftStick.GetRawButton(4))
  70.                         {
  71.                                 servo.SetAngle(280);
  72.                         }
  73.                         if (leftStick.GetRawButton(5))
  74.                         {
  75.                                 servo.SetAngle(120);
  76.                         }
  77.                        
  78.                         if (leftStick.GetRawButton(2))
  79.                         {
  80.                                 solenoidExtend1.Set(true);
  81.                                 solenoidRetract1.Set(false);
  82.        
  83.                                 solenoidExtend2.Set(true);
  84.                                 solenoidRetract2.Set(false);
  85.                         }
  86.                        
  87.                         if (leftStick.GetRawButton(3))
  88.                         {
  89.                                 solenoidRetract1.Set(false);
  90.                                 solenoidExtend1.Set(true);
  91.                                
  92.                                 solenoidExtend1.Set(false);
  93.                                 solenoidRetract1.Set(true);
  94.                         }
  95.                        
  96.                        
  97.                         if (compressor.GetPressureSwitchValue() > 119)
  98.                         {
  99.                                 compressor.Stop();
  100.                         }
  101.                         else if (compressor.GetPressureSwitchValue() < 110)
  102.                         {
  103.                                 compressor.Start();
  104.                         }
  105.                        
  106.                         myRobot.ArcadeDrive(leftStick);        
  107.                        
  108.                         Wait(0.005);
  109.                 }
  110.         }
  111. };
  112.  
  113. START_ROBOT_CLASS(Robot);
RAW Paste Data
Top