def teleop(): dog = wpilib.GetWatchdog() dog.SetEnabled(True) dog.SetExpiration(0.25) shiftTime = wpilib.Timer() shiftTime.Start() while wpilib.IsOperatorControl() and wpilib.IsEnabled(): dog.Feed() checkRestart() if shiftTime.Get() > 0.3: shifter1.Set(False) shifter2.Set(False) # Shifter control if rstick.GetTrigger(): shifter1.Set(True) shifter2.Set(False) shiftTime.Reset() highGear = True elif lstick.GetTrigger(): shifter1.Set(False) shifter2.Set(True) shiftTime.Reset() highGear = False # Drive control drive.TankDrive(lstick, rstick) wpilib.Wait(0.04)
def teleop(): dog = wpilib.GetWatchdog() dog.SetEnabled(True) dog.SetExpiration(0.25) while wpilib.IsOperatorControl() and wpilib.IsEnabled(): dog.Feed() drive.TankDrive(stick1, stick2) checkRestart() wpilib.Wait(0.01)
def teleop(): dog = wpi.GetWatchdog() dog.SetEnabled(True) dog.SetExpiration(0.25) dog.SetEnabled(False) dog.Kill() while wpi.IsOperatorControl() and wpi.IsEnabled(): dog.Feed() drive.tankDrive(stick1, stick2) #a quiet jaunt around the park checkRestart() wpi.Wait(0.01)
def teleop(): dog = wpilib.GetWatchdog() dog.SetEnabled(True) dog.SetExpiration(0.25) while wpilib.IsOperatorControl() and wpilib.IsEnabled(): dog.Feed() checkRestart() # Motor control motor.Set(lstick.GetY()) wpilib.Wait(0.04)
def teleop(): print("Robot Teleoperated") dog = wpi.GetWatchdog() global doggy if doggy: dog.SetEnabled(True) dog.SetExpiration(0.25) else: dog.SetEnabled(False) dog.Kill() while wpi.IsOperatorControl() and wpi.IsEnabled(): dog.Feed() drive.arcadeDrive(stick1) #a quiet jaunt around the park checkRestart() wpi.Wait(0.01)
def run_old(): """Main loop, old""" while 1: if wpi.IsDisabled(): print("Running disabled()") disabled() while wpi.IsDisabled(): wpi.Wait(0.01) elif wpi.IsAutonomous(): print("Running autonomous()") autonomous() while wpi.IsAutonomous() and wpi.IsEnabled(): wpi.Wait(0.01) else: print("Running teleop()") teleop() while wpi.IsOperatorControl() and wpi.IsEnabled(): wpi.Wait(0.01)
def run(): """Main loop""" print("Start compressor") compressor.Start() while 1: if wpilib.IsDisabled(): print("Running disabled()") disabled() while wpilib.IsDisabled(): wpilib.Wait(0.01) elif wpilib.IsAutonomous(): print("Running autonomous()") autonomous() while wpilib.IsAutonomous() and wpilib.IsEnabled(): wpilib.Wait(0.01) else: print("Running teleop()") teleop() while wpilib.IsOperatorControl() and wpilib.IsEnabled(): wpilib.Wait(0.01)
def teleop(): print ("Robot Teleoperated") dog = wpi.GetWatchdog() global doggy if doggy: dog.SetEnabled(True) dog.SetExpiration(0.25) else: dog.SetEnabled(False) dog.Kill() while wpi.IsOperatorControl() and wpi.IsEnabled(): dog.Feed() if stick1.get_button(stick1.a): drive.arcadeDrive(stick1) #a quiet jaunt around the park else: drive.tankDrive(stick1) #base.send(stick1.getStickAxes()) #base.send(stick1.get_button_list()) checkRestart() wpi.Wait(0.01)
def OperatorControl(self): self.dog.SetEnabled(True) self.dog.SetExpiration(0.25) solenoidTimer = wpilib.Timer() solenoidTimer.Start() while wpilib.IsOperatorControl() and wpilib.IsEnabled(): self.dog.Feed() if self.stick1.GetRawButton(6): raise SystemRestart # Normal motors yval = self.stick2.GetY() self.motor1.Set(yval) self.motor2.Set(yval) # Solenoid control if self.stick1.GetTrigger(): self.solenoid1.Set(True) self.solenoid2.Set(False) solenoidTimer.Reset() if self.stick2.GetTrigger(): self.solenoid1.Set(False) self.solenoid2.Set(True) solenoidTimer.Reset() if solenoidTimer.Get() > 0.2: self.solenoid1.Set(False) self.solenoid2.Set(False) # Relay driven motor if self.stick3.GetTrigger(): self.relayMotor.Set(wpilib.Relay.kForward) elif self.stick3.GetTop(): self.relayMotor.Set(wpilib.Relay.kReverse) else: self.relayMotor.Set(wpilib.Relay.kOff) # Servo control serveMan = (1.0 + self.stick3.GetY()) / 2.0 # Left Arm if self.stick3.GetRawButton(7): self.leftArm.Set(serveMan) else: self.leftArm.Set((1.0 + self.leftArmStick.GetY()) / 2.0) # Right Arm if self.stick3.GetRawButton(8): self.rightArm.Set((1.0 - self.stick3.GetY()) / 2.0) else: self.rightArm.Set((1.0 - self.rightArmStick.GetY()) / 2.0) # Left Leg if self.stick3.GetRawButton(9): self.leftLeg.Set(serveMan) else: self.leftLeg.Set(0.2 + 0.36 * (1.0 + self.leftArmStick.GetX()) / 2.0) #elif self.leftArmStick.GetRawButton(3): # self.leftLeg.Set(0.2) #else: # self.leftLeg.Set(0.56) # Right Leg if self.stick3.GetRawButton(10): self.rightLeg.Set(serveMan) else: self.rightLeg.Set(0.58 + 0.42 * (1.0 - self.rightArmStick.GetX()) / 2.0) #elif self.leftArmStick.GetRawButton(2): # self.rightLeg.Set(1.0) #else: # self.rightLeg.Set(0.58) # Spinner if self.stick3.GetRawButton(11): self.spinner.Set(serveMan) elif self.leftArmStick.GetY() < -0.5 and self.rightArmStick.GetY( ) < -0.5: self.spinner.Set(1.0) else: self.spinner.Set(0.5) wpilib.Wait(0.04)
def teleop(): while wpilib.IsOperatorControl() and wpilib.IsEnabled(): checkRestart() wpilib.Wait(0.01)