Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import wpilib
- import wpilib.buttons
- import cmath
- class MyRobot(wpilib.IterativeRobot):
- ##############SET UP FOR XBOX CONTROLLER###################
- def robotInit(self):
- """
- This function is called upon program startup and
- should be used for any initialization code.
- """
- self.motor1=wpilib.Jaguar(8)
- self.motor2=wpilib.Jaguar(9)
- self.slide_motor=wpilib.Jaguar(7)
- self.test=wpilib.Jaguar(5)
- self.non_existant_motor=wpilib.Jaguar(6)
- self.sol=wpilib.Solenoid(0,4)
- self.compress=wpilib.Compressor()
- self.robot_drive = wpilib.RobotDrive(self.motor2,self.motor1)
- self.stick = wpilib.Joystick(1)
- self.stick1 = wpilib.Joystick(0)
- self.joystick_button=wpilib.buttons.JoystickButton(self.stick1, 1)
- self.joystick_button1=wpilib.buttons.JoystickButton(self.stick1, 2)
- self.joystick_button2=wpilib.buttons.JoystickButton(self.stick1, 3)
- self.joystick_button5=wpilib.buttons.JoystickButton(self.stick1, 5)
- self.left=self.stick.getAxis(3)
- self.counter=1
- self.teleopPeriodic()
- def teleopPeriodic(self):
- """This function is called periodically dturing operator control."""
- self.compress.setClosedLoopControl(True)
- self.right_trig=self.stick1.getRawAxis(3)
- self.left_trig=-1*self.stick1.getRawAxis(2)
- if self.joystick_button.get()==True:
- self.sol.set(True)
- else:
- self.sol.set(False)
- total=self.right_trig+self.left_trig
- self.right_stickX=self.stick1.getRawAxis(4)
- self.non_existant_motor.set(total)
- self.slide_motor.set(self.right_stickX)
- self.robot_drive.arcadeDrive(self.stick1.getY(),self.stick1.getX(),True)
- if __name__ == "__main__":
- wpilib.run(MyRobot)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement