def __init__(self, width, height, depth = 3, title = "Camera View", parent = None, visible = 0): """ To specify the resolution of a particular camera, overload this constructor with one that initalizes the dimensions itself """ PyrobotImage.__init__(self, width, height, depth, 0) Device.__init__(self, 'camera') self.app = 0 self.title = title self.filterMode = 1 self.callbackList = [] self.filterResults = [] self.callbackTextList = [] # specific camera type will define self.rgb = (0, 1, 2) offsets # and self.format = "RGB", for example self.lastWindowUpdate = 0 self.updateWindowInterval = 0.0 # update window once a second self.update() # call it once to initialize self.image = [] self.data = self.data self.grayscale = [] self.height = self.height self.width = self.width self.depth = self.depth self.filters = self.callbackTextList # Required: self.startDevice() # make these visible by default if visible and self.vision: self.makeWindow()
def __init__(self, portname=None, baudrate=None): Device.__init__(self, deviceType='ptz') if portname == None or baudrate == None: if portname == None: portname = '/dev/ttyS3' if baudrate == None: baudrate = 9600 result = ask("Please enter the parameters for the Canon PTZ", (("Port name", portname), ("Baud rate", baudrate), )) else: result = {'Port name': portname, 'Baud rate': baudrate} self.port = serial.Serial(result['Port name'], baudrate=result['Baud rate']) self._send(controlModePacket()) self._send(initPacket()) self._send(opticalZoomPacket(0)) self._send(digitalZoomPacket(1)) self._send(panSlewPacket(MAX_PAN_SLEW)) self._send(tiltSlewPacket(MAX_TILT_SLEW)) self._send(defaultTiltRangePacket()) self._pan = 0 self._tilt = 0 self._zoom = 0 self._magnify = 1 self._panSpeed = MAX_PAN_SLEW self._tiltSpeed = MAX_TILT_SLEW self.supports = ['pan', 'tilt', 'zoom', 'magnify'] print 'Canon PTZ device ready'
def __init__(self, portname=None, baudrate=None): Device.__init__(self, deviceType='ptz') if portname == None or baudrate == None: if portname == None: portname = '/dev/ttyS3' if baudrate == None: baudrate = 9600 result = ask("Please enter the parameters for the Canon PTZ", ( ("Port name", portname), ("Baud rate", baudrate), )) else: result = {'Port name': portname, 'Baud rate': baudrate} self.port = serial.Serial(result['Port name'], baudrate=result['Baud rate']) self._send(controlModePacket()) self._send(initPacket()) self._send(opticalZoomPacket(0)) self._send(digitalZoomPacket(1)) self._send(panSlewPacket(MAX_PAN_SLEW)) self._send(tiltSlewPacket(MAX_TILT_SLEW)) self._send(defaultTiltRangePacket()) self._pan = 0 self._tilt = 0 self._zoom = 0 self._magnify = 1 self._panSpeed = MAX_PAN_SLEW self._tiltSpeed = MAX_TILT_SLEW self.supports = ['pan', 'tilt', 'zoom', 'magnify'] print 'Canon PTZ device ready'
def __init__(self, robot): Device.__init__(self, "ptz") self.robot = robot # Turn on head remote control if off: self.robot.setRemoteControl("Head Remote Control", "on") time.sleep(1) # pause for a second self.dev = Listener(self.robot.PORT["Head Remote Control"], self.robot.host) self.supports = ["pan", "tilt", "roll"] self.pose = [0, 0, 0, 0]
def __init__(self, robot, what, width=400, height=120): Device.__init__(self, "view") self.width = width self.height = height self.what = what self.robot = robot self.dataMin = 0 self.dataMax = robot.range.getMaxvalue() self.dataWindowSize = 400 self.dataSample = 1 self.dataCount = 0 self.lastRun = 0 self.dataHist = [0] * self.robot.range.count self.source = self.what self.startDevice() self.makeWindow()
def __init__(self, robot, what, width = 400, height = 120): Device.__init__(self, "view") self.width = width self.height = height self.what = what self.robot = robot self.dataMin = 0 self.dataMax = robot.range.getMaxvalue() self.dataWindowSize = 400 self.dataSample = 1 self.dataCount = 0 self.lastRun = 0 self.dataHist = [0] * self.robot.range.count self.source = self.what self.startDevice() self.makeWindow()
def __init__(self, dev = "/dev/dsp", sampleTime = 1.0, fake = 0): """ This is an async device with no update(). dev: sound card device name sampleTime: time, in seconds, in which to sample """ Device.__init__(self, "frequency") self.fake = fake self.deviceName = dev self.status = "closed" self.number_of_channels= 1 self.sample_rate= 14400 self.sample_width= 1 self.format = ossaudiodev.AFMT_U8 self.sampleTime = sampleTime self.results = [1]*6 self.lastFreq = int(self.sample_rate * self.sampleTime/ 2.0) self.setAsync(1)
def __init__(self, dev="/dev/dsp", sampleTime=1.0, fake=0): """ This is an async device with no update(). dev: sound card device name sampleTime: time, in seconds, in which to sample """ Device.__init__(self, "frequency") self.fake = fake self.deviceName = dev self.status = "closed" self.number_of_channels = 1 self.sample_rate = 14400 self.sample_width = 1 self.format = ossaudiodev.AFMT_U8 self.sampleTime = sampleTime self.results = [1] * 6 self.lastFreq = int(self.sample_rate * self.sampleTime / 2.0) self.setAsync(1)
def __init__(self, robot): Device.__init__(self, "laser") self.robot = robot count = 90 part = int(count / 8) start = 0 posA = part posB = part * 2 posC = part * 3 posD = part * 4 posE = part * 5 posF = part * 6 posG = part * 7 end = count self.groups = { 'all': range(count), 'right': range(0, posB), 'left': range(posF, end), 'front': range(posC, posE), 'front-right': range(posB, posD), 'front-left': range(posD, posF), 'front-all': range(posB, posF), 'right-front': range(posA, posB), 'right-back': range(start, posA), 'left-front': range(posF, posG), 'left-back': range(posG, end), 'back-right': [], 'back-left': [], 'back': [], 'back-all': [] } self.units = "ROBOTS" self.noise = 0.0 self.arc = 1.0 * PIOVER180 # in radians # ------------------------------------------- self.rawunits = "METERS" self.maxvalueraw = 10.0 # ------------------------------------------- # These are fixed in meters: DO NOT CONVERT ---------------- self.radius = 0.750 # meters # ---------------------------------------------------------- self.count = count
def __init__(self, robot): Device.__init__(self, "laser") self.robot = robot count = 90 part = int(count/8) start = 0 posA = part posB = part * 2 posC = part * 3 posD = part * 4 posE = part * 5 posF = part * 6 posG = part * 7 end = count self.groups = {'all': range(count), 'right': range(0, posB), 'left': range(posF, end), 'front': range(posC, posE), 'front-right': range(posB, posD), 'front-left': range(posD, posF), 'front-all': range(posB, posF), 'right-front': range(posA, posB), 'right-back': range(start, posA), 'left-front': range(posF,posG), 'left-back': range(posG,end), 'back-right': [], 'back-left': [], 'back': [], 'back-all': []} self.units = "ROBOTS" self.noise = 0.0 self.arc = 1.0 * PIOVER180 # in radians # ------------------------------------------- self.rawunits = "METERS" self.maxvalueraw = 10.0 # ------------------------------------------- # These are fixed in meters: DO NOT CONVERT ---------------- self.radius = 0.750 # meters # ---------------------------------------------------------- self.count = count
def __init__(self, robot): Device.__init__(self, "simulation") self.robot = robot
def INIT(robot): return {"simple": Device()}