def __init__(self, leftMotPort, rightMotPort, solenoidUpPort, solenoidDownPort, motGain=1, intPos=0): self._leftMot = wp.TalonSRX(leftMotPort) self._rightMot = wp.TalonSRX(rightMotPort) #self._feedNoid = 5 if (self._joystickObj.getAxisCount() == 0) else self._joystickObj.getAxisCount() self._feedNoid = wp.DoubleSolenoid(solenoidUpPort, solenoidDownPort) self._feedNoid.set(intPos) self._leftSpeed = 0 self._rightSpeed = 0 self._motGain = motGain
def robotInit(self): """ This function is called upon program startup and should be used for any initialization code. """ #traceback.print_stack() m1 = wpilib.TalonSRX(MOTOR1) m2 = wpilib.TalonSRX(MOTOR2) self.robot_drive = wpilib.RobotDrive(m1, m2) self.stick = wpilib.Joystick(0) print(self.stick) #pprint (vars(self.stick)) #self.button1 = wpilib.buttons.JoystickButton(self.stick, 0) self.s1 = wpilib.DigitalOutput(SOLENOID) self.CannonIsFiring = False
def robotInit(self): '''Robot initialization function''' #positions = [0,-625,-1210,-1815,-2425,-2635] positions = [0, -325, -650, -975, -1300, -1395] scorePos = [0, 0, -275, -545, -805, -1075] self.motorFrontRight = wp.TalonSRX(frontRightPort) self.motorBackRight = wp.TalonSRX(backRightPort) self.motorFrontLeft = wp.TalonSRX(frontLeftPort) self.motorBackLeft = wp.TalonSRX(backLeftPort) self.stick = joy.happyHappyJoyJoy(leftDriveJoyPort) self.stick2 = joy.happyHappyJoyJoy(rightDriveJoyPort) self.cop = joy.happyHappyJoyJoy(coPilotJoyPort) self.smartDs = wp.SmartDashboard() #the smart dashboard communication self.accel = wp.BuiltInAccelerometer() self.driveEncd = wp.Encoder(driveEncdAPort, driveEncdBPort) self.feeders = feed.feedMe(feederLeftPort, feederRightPort, feedUpChannel, feedDownChannel, 0.35) self.rightSwitch = wp.DigitalInput(rightToteDetPort) self.leftSwitch = wp.DigitalInput(leftToteDetPort) self.autoSwitch = wp.DigitalInput(autoSwitchPort) self.comp = wp.Compressor() self.Vator = ele.elevatorObj(liftMotPort, liftEncdAPort, liftEncdBPort, positions, scorePos, 0.75, 30) try: self.camServ = wp.CameraServer() self.usbCam = wp.USBCamera() self.usbCam.setExposureManual(50) self.usbCam.setBrightness(80) self.usbCam.updateSettings() # force update before we start thread self.camServ.startAutomaticCapture(self.usbCam) except: pass
def __init__(self, motorPort, encdA, encdB, positions, scorePos, motScaler = 1, gain = 35, intIndex = 0, manual = False): self._liftMot = wp.TalonSRX(motorPort) self._encd = wp.Encoder(encdA, encdB) self._encd.reset() self._gain = gain self._positions = positions self._index = intIndex self._position = self._positions[self._index] self._manual = manual self._motScaler = motScaler self._manSpeed = 0 self._speed = 0 self._setPosion = False self._scorePos = scorePos
#!/usr/bin/env python import time import hal import wpilib #from talonsrx import TalonSRX #import piRobotLib import logging from pprint import pprint # Constants for the pins the motors are connected to. MOTOR1 = 0 try: print('starting test') #pprint(vars(hal)) m1 = wpilib.TalonSRX(MOTOR1) print(m1) pprint(vars(m1)) loopTime = hal.getLoopTiming() / ( wpilib.SensorBase.kSystemClockTicksPerMicrosecond * 1e3) print('loopTime: ', loopTime) # set the speed of the motor - speed is between -1 and 1 for i in range(-10, 11): m1.setSpeed(i / 10.0) time.sleep(10) except KeyboardInterrupt: pass