def robotInit(self): camera = wpilib.USBCamera() camera.setExposureManual(50) camera.setBrightness(80) camera.updateSettings() # force update before we start thread server = wpilib.CameraServer.getInstance() server.startAutomaticCapture(camera)
def __init__(self, robot): #This is for a USB camera. Uncomment it if we aren't using the Axis. self.camera = wpilib.USBCamera() self.camera.setExposureManual(50) self.camera.setBrightness(80) self.camera.updateSettings() self.camera.setFPS(10) self.camera.setSize(320, 240) self.camera.setWhiteBalanceAuto() #self.camera.setQuality(30) server = wpilib.CameraServer.getInstance() server.startAutomaticCapture(self.camera)
def robotInit(self): """initialises robot as a mecanum drive bot w/ 2 joysticks and a camera""" #want to change this to Xbox 360 controller eventually... probably sooner rather #than later. # #This is for a USB camera. Uncomment it if we aren't using the Axis. self.camera = wpilib.USBCamera() self.camera.setExposureManual(50) self.camera.setBrightness(80) self.camera.updateSettings() self.camera.setFPS(10) self.camera.setSize(320, 240) self.camera.setWhiteBalanceAuto() #self.camera.setQuality(30) server = wpilib.CameraServer.getInstance() server.startAutomaticCapture(self.camera) self.drive = wpilib.RobotDrive(3, 1, 2, 0) self.drive.setExpiration(0.1) self.stick_left = wpilib.Joystick(0) self.stick_right = wpilib.Joystick(1) self.drive.setInvertedMotor(self.drive.MotorType.kFrontRight, True) self.drive.setInvertedMotor(self.drive.MotorType.kRearRight, True) #self.gyro = wpilib.Gyro(0) self.aux_left = wpilib.Jaguar(6) self.aux_right = wpilib.Jaguar(4) self.window_motor = wpilib.Jaguar(5) self.smart_dashboard = NetworkTable.getTable("SmartDashboard") self.mast_pot = wpilib.AnalogPotentiometer(0) self.grabba_pot = wpilib.AnalogPotentiometer(1) self.lift_pot = wpilib.AnalogPotentiometer(2) def aux_combined(output): """use for PID control""" self.aux_left.pidWrite(output) self.aux_right.pidWrite(output) self.grabba_pid = wpilib.PIDController(4, 0.07, 0, self.grabba_pot.pidGet, self.window_motor.pidWrite) self.grabba_pid.disable() self.lift_pid = wpilib.PIDController(4, 0.07, 0, self.lift_pot.pidGet, aux_combined) self.lift_pid.disable()
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
import wpilib import time camera = wpilib.USBCamera() camera.startCapture() camera.setExposureAuto() #-1 old camera.setBrightness(10) #camera.setSize(camera.width / 2, camera.height / 2) #camera.setFPS(15) cameraServer = wpilib.CameraServer() cameraServer.startAutomaticCapture(camera) #a = input() time.sleep(3) camera.stopCapture()