2
0
mirror of https://github.com/team2059/Zaphod synced 2024-12-18 20:12:28 -05:00

updated the main.py and started work on a drive.py with a drive class that will take the joystick input and power the motors

This commit is contained in:
Adam Long 2014-04-06 16:57:09 -04:00
parent 5a002751f5
commit b72e5261cf
2 changed files with 42 additions and 0 deletions

6
python/drive.py Normal file
View File

@ -0,0 +1,6 @@
try:
import wpilib
except ImportError:
from pyfrc import wpilib
class drive():
def _init_(self, rightBack, rightMid, rightFront, leftBack, leftMid, leftFront):

36
python/main.py Normal file
View File

@ -0,0 +1,36 @@
import sys
import drive
try:
import wpilib
except ImportError:
from pyfrc import wpilib
DriveStick = wpilib.Joystick(1)
ShootStick = wpilib.Joystick(2)
leftMotor = wpilib.Jaguar(1)
compressor = wpilib.Compressor(2,1)
def restartCode():
if stick.GetRawButton(2):
raise RuntimeError("restarting")
# Contains the Disabled, Auto, and Teleop functions
class Zaphod(wpilib.SimpleRobot):
def Disabled(self):
while self.IsDisabled():
wpilib.Wait(0.01)
def Autonomous(self):
self.GetWatchdog().SetEnabled(False)
while self.IsAutonomous() and self.IsEnabled():
wpilib.Wait(0.01)
def OperatorControl(self):
# Create the watchdog (and actually use it)
dog = self.GetWatchdog()
dog.SetEnabled(True)
dog.SetExpiration(0.25)
compressor.Start()
while self.IsOperatorControl() and self.IsEnabled():
dog.Feed()
leftMotor.Set(DriveStick.GetY())
wpilib.Wait(0.04)
def run():
robot = Zaphod()
robot.StartCompetition()
return robot