From b72e5261cf28c5a50962ebc6274c5234d4abd3f2 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Sun, 6 Apr 2014 16:57:09 -0400 Subject: [PATCH] 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 --- python/drive.py | 6 ++++++ python/main.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 python/drive.py create mode 100644 python/main.py diff --git a/python/drive.py b/python/drive.py new file mode 100644 index 0000000..fe4c06e --- /dev/null +++ b/python/drive.py @@ -0,0 +1,6 @@ +try: + import wpilib +except ImportError: + from pyfrc import wpilib +class drive(): + def _init_(self, rightBack, rightMid, rightFront, leftBack, leftMid, leftFront): diff --git a/python/main.py b/python/main.py new file mode 100644 index 0000000..34b0755 --- /dev/null +++ b/python/main.py @@ -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