def run(self): global isNextPathNeeded global nextPathSema while 1: # if isNextPathNeeded: # print self.threadName, "blocking" # nextPathSema.acquire() locationTrackerLock.acquire() if self.count == 0: locationTracker.updateLocation(stop=isNextPathNeeded, recalibrating=newLevelReached) print "Total Steps:", locationTracker.getTotalSteps() print "Total Distance:", locationTracker.getTotalDistance() print "Deviation from N:", locationTracker.getHeadingInDeg() print "True deviation from N:", locationTracker.getTrueHeadingInDeg() print locationTracker.getLocation() print "Height:", locationTracker.getHeightInCM() self.count = 0 else: self.count += 1 locationTrackerLock.release() time.sleep(1.5)
def run(self): while 1: locationTrackerLock.acquire() locationTracker.updateLocation(False, False) if self.count == 0: print "Total Steps:", locationTracker.getTotalSteps() print "Total Distance:", locationTracker.getTotalDistance() print "Deviation from N:", locationTracker.getHeadingInDeg() print "True deviation from N:", locationTracker.getTrueHeadingInDeg() print locationTracker.getLocation() print "Height:", locationTracker.getHeightInCM() self.count = 0 else: self.count += 1 # locationTracker.gyroCompass.updateOffset() locationTrackerLock.release() time.sleep(1.5)
def run(self): global naviCount global obstacleDetected global checkSideObstacle global isFirstCleared while 1: # feedback steps walked navi.feedbackWalking(locationTracker.getTotalSteps()) naviCount += 1 locationTrackerLock.acquire() curX = locationTracker.getXCoord() curY = locationTracker.getYCoord() heading = locationTracker.getHeadingInDeg() locationTrackerLock.release() # update location and next node direction for obstacle avoidance ## obstacle.setNextNodeDirection(navi.getGeneralTurnDirection()) ## obstacle.setCurrentLocation(curX, curY) # every second, check navigation ## if (naviCount%10 == 0) : ## navi.updateCurLocation(curX, curY, heading) ## if obstacleDetected == 1 or checkSideObstacle == 1: ## navi.ignoreNodeObstacle() ## time.sleep(0.1) ## continue ## if isFirstCleared == 1 : ## navi.updateClearSteps(locationTracker.getTotalSteps()) ## isFirstCleared = 0 ## else : ## navi.updateCurrentSteps(locationTracker.getTotalSteps()) isNavigationDone = navi.fullNavigate() if isNavigationDone is True: return time.sleep(1)
def run(self): global navi global skip_init global isNextPathNeeded global nextPathSema global data global newLevelReached initialResponseIsLow = True while 1: ## if isNextPathNeeded: ## print self.threadName, "blocking" ## nextPathSema.acquire() locationTrackerLock.acquire() curX = locationTracker.getXCoord() curY = locationTracker.getYCoord() heading = locationTracker.getHeadingInDeg() locationTrackerLock.release() navi.updateCurLocation(curX, curY, heading) isNavigationDone = navi.fullNavigate() # push button for switching to next node response = keypad.get_binary_response_timed(initialResponseIsLow, 0.1) initialResponseIsLow = response[1] if response[0]: navi.reroutePath() if isNavigationDone is True : print ("\n\n\n\n\nLE SWITCHEROO\n\n\n\n") if navi.hasNextPath() is True : isNextPathNeeded = True # userInputLock.acquire() print "press start to continue" UISpeaker.speak("Now entering new map. Press start to continue.") while keypad.get_binary_response(): pass # print "data in serial / data before flush:", dataFeeder.serialPort.inWaiting(), len(data[2]), len(data[3]) # data = [deque() for x in range(NUM_QUEUED_ID)] # data_single = [0 for x in range(NUM_SINGLE_ID)] # data.extend(data_single) # dataFeeder.serialPort.flushInput() # dataFeeder.serialPort.flushOutput() # print "data in serial / data after flush:", dataFeeder.serialPort.inWaiting(), len(data[2]), len(data[3]) navi.switchToNextPathList() # update location tracker initial heading/coordinates locationTracker.updateMapNorth(navi.getNorthDifference()) (initX, initY) = navi.getFirstCoordinates() locationTracker.setLocation(initX, initY) newLevelReached = navi.isDifferentLevel() isNextPathNeeded = False # turn on location tracker and receive data threads # userInputLock.release() # for thread in mainThreads: # if thread.threadID != 6 and thread.threadID != 5: # nextPathSema.release() else : return time.sleep(3)