Advertisement
Guest User

RIO problems

a guest
Jan 30th, 2015
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.85 KB | None | 0 0
  1. import wpilib
  2. import wpilib.buttons
  3. import cmath
  4.  
  5. class MyRobot(wpilib.IterativeRobot):
  6.  
  7.  
  8. ##############SET UP FOR XBOX CONTROLLER###################
  9.  
  10.  
  11.     def robotInit(self):
  12.         """
  13.        This function is called upon program startup and
  14.        should be used for any initialization code.
  15.        """
  16.         self.motor1=wpilib.Jaguar(8)
  17.         self.motor2=wpilib.Jaguar(9)
  18.         self.slide_motor=wpilib.Jaguar(7)
  19.         self.test=wpilib.Jaguar(5)
  20.         self.non_existant_motor=wpilib.Jaguar(6)
  21.         self.sol=wpilib.Solenoid(0,4)
  22.         self.compress=wpilib.Compressor()
  23.         self.robot_drive = wpilib.RobotDrive(self.motor2,self.motor1)
  24.         self.stick = wpilib.Joystick(1)
  25.         self.stick1 = wpilib.Joystick(0)
  26.         self.joystick_button=wpilib.buttons.JoystickButton(self.stick1, 1)
  27.         self.joystick_button1=wpilib.buttons.JoystickButton(self.stick1, 2)
  28.         self.joystick_button2=wpilib.buttons.JoystickButton(self.stick1, 3)
  29.         self.joystick_button5=wpilib.buttons.JoystickButton(self.stick1, 5)
  30.         self.left=self.stick.getAxis(3)
  31.         self.counter=1
  32.         self.teleopPeriodic()
  33.     def teleopPeriodic(self):
  34.         """This function is called periodically dturing operator control."""
  35.         self.compress.setClosedLoopControl(True)
  36.         self.right_trig=self.stick1.getRawAxis(3)
  37.         self.left_trig=-1*self.stick1.getRawAxis(2)
  38.         if self.joystick_button.get()==True:
  39.             self.sol.set(True)
  40.         else:
  41.             self.sol.set(False)
  42.         total=self.right_trig+self.left_trig
  43.         self.right_stickX=self.stick1.getRawAxis(4)
  44.         self.non_existant_motor.set(total)
  45.         self.slide_motor.set(self.right_stickX)
  46.         self.robot_drive.arcadeDrive(self.stick1.getY(),self.stick1.getX(),True)
  47.        
  48. if __name__ == "__main__":
  49.     wpilib.run(MyRobot)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement