def set8x8(self, index, gridType): # simulation self.display.set8x8(index, gridType) # real commObject = CommRequest('b') commObject.markDone() return commObject
def set8x8(self, index, gridType): # types: # T = objective tunnel, # D = dead end, # E = empty commandObj = CommRequest(gridType + '|' + str(index)) self.ard.requestCommand(commandObj) return commandObj
def set7segment(self, number): commandObj = CommRequest('N' + '|' + str(number)) if number < 1 or number > 6: commandObj.response = 'INVALID' commandObj.markDone() else: self.ard.requestCommand(commandObj) return commandObj
def goForward(self): commObject = CommRequest('f') self.drive(1) self.forwardCounter += 1 self.play_sound(self.sound1) print "FORWARDS: %s \nTURNS: %s" % (self.forwardCounter, self.turnCounter) # commObject.markDone() self.move_to_do = commObject return commObject
def rotateClockwise(self): commObject = CommRequest('r') self.changeDirection(-1) self.MAP.rotateClockwise() self.turnCounter += 1 self.play_sound(self.sound5) print "FORWARDS: %s \nTURNS: %s" % (self.forwardCounter, self.turnCounter) # commObject.markDone() self.move_to_do = commObject return commObject
def readSensor(self, value): commObject = CommRequest('S%s' % value) returnvalue = None if value == 1: returnvalue = self.read_distance() elif value == 2: returnvalue = self.read_electromagnetic() elif value == 3: returnvalue = self.read_capacitive() commObject.response = returnvalue commObject.markDone() return commObject
def moveForward(self): commandObj = CommRequest('f') self.nxtC.requestCommand(commandObj) return commandObj
def beginningObstacleThresholdCalibration(self): commandObj = CommRequest('@') self.ard.requestCommand(commandObj) return commandObj
def goCalibrateIR(self, side): to_return = CommRequest('c|' + side) self.move_to_do = to_return return to_return
def moveRight(self): commandObj = CommRequest('r') self.nxtC.requestCommand(commandObj) return commandObj
def getStopButton(self): commandObj = CommRequest('B' + '|S') self.ard.requestCommand(commandObj) return commandObj
def setReadyLight(self): commandObj = CommRequest('R') self.ard.requestCommand(commandObj) return commandObj
def goCalibrateIR(self, side): commandObj = CommRequest('c|' + side) self.ard.requestCommand(commandObj) return commandObj
def goCalibrate(self): commandObj = CommRequest('c') self.ard.requestCommand(commandObj) return commandObj
def moveBackward(self): commandObj = CommRequest('b') self.nxtC.requestCommand(commandObj) return commandObj
def moveLeft(self): commandObj = CommRequest('l') self.nxtC.requestCommand(commandObj) return commandObj
def getEMFreading(self): commandObj = CommRequest('S' + '|E', returnAsList=True) self.ard.requestCommand(commandObj) return commandObj
if automatic: if resp.startswith("BAD") or resp.startswith("BAd"): automatic = False print "was on: %s" % possibilities[index] print 'attempting to flush...' time.sleep(0.1) ard_funcs.ard.serial.flushInput() ard_funcs.ard.serial.flushOutput() continue index = (index+1)%3 user_inp = possibilities[index] #time.sleep(0.001) else: user_inp = raw_input('> ') if user_inp == 'y': commandObj = CommRequest("L|Y") ard_funcs.ard.requestCommand(commandObj) resp = wait_till_done(commandObj) print "%s: %s" % (user_inp,resp) elif user_inp == 'b': commandObj = CommRequest("L|B") ard_funcs.ard.requestCommand(commandObj) resp = wait_till_done(commandObj) print "%s: %s" % (user_inp,resp) elif user_inp == 'g': commandObj = CommRequest("L|G") ard_funcs.ard.requestCommand(commandObj) resp = wait_till_done(commandObj) print "%s: %s" % (user_inp,resp) elif user_inp == 'n': commandObj = CommRequest("L|N")
def getObstacleReport(self): commandObj = CommRequest('S' + '|O') self.ard.requestCommand(commandObj) return commandObj
def performTap(self): commandObj = CommRequest('A') self.ard.requestCommand(commandObj) return commandObj
def moveLeft(self): print("in arduinofuncs moveLeft function") commandObj = CommRequest('l') self.ard.requestCommand(commandObj) return commandObj
def goBackward(self): commObject = CommRequest('b') self.drive(-1) self.forwardCounter += 1 commObject.markDone() return commObject
def beginningRightCalibration(self): commandObj = CommRequest(']') self.ard.requestCommand(commandObj) return commandObj
def setReadyLight(self): commObject = CommRequest('b') commObject.markDone() return commObject
def beginningBackCalibration(self): commandObj = CommRequest('v') self.ard.requestCommand(commandObj) return commandObj
def set7segment(self, number): commObject = CommRequest('b') commObject.markDone() return commObject
def checkEMF2(self): commandObj = CommRequest('2') self.ard.requestCommand(commandObj) return commandObj