def __init__(self, voiceQueue, voiceSema) : self.prev_message_time_turn = 0 self.prev_message_time_str = 0 self.message_delay = 0 self.voiceQueue = voiceQueue self.voiceSema = voiceSema self.ANGLE_TOLERANCE = 0 self.pathFind = pathFinder() self.hasAnotherPath = False self.hasTwoPaths = False self.hasThreePaths = False self.startBuilding = None self.endBuilding = None self.startLevel = 0 self.endLevel = 0 self.midBuilding = None self.midLevel = None self.mapNumber = 0 # index of map in comMap list self.startLocation = 0 self.endLocation = 0 self.curX = 0 # cm self.curY = 0 # cm self.heading = 0 # -180 to 180 degrees # used to feedback steps to user self.walkingCount = 0 self.WALKING_VIBRATE_DURATION = 0.1 # tolerance self.maxTolerance = 200 # list of json parsing maps self.comMap = [] # path lists self.pathList = [] self.pathList2 = [] self.pathList3 = [] # north of cuurent map self.curMapNorth = 0 # if connection between the building has stairs self.hasStairs1 = 0 self.hasStairs2 = 0 # parameters to set when switching to new map self.hasStairs = 0 self.northDifference = 0 self.xFirst = None self.yFirst = None self.pathListIndex = 0 self.northAt = 0 # 0 to 360 degrees self.prevX = 0 # cm self.prevY = 0 # cm self.nexX = 0 # cm self.nexY = 0 # cm self.nodeNavi = navigation(self.voiceQueue, self.voiceSema) self.leftPin = 9 self.rightPin = 10
import p2pNavi voiceQueue = None voiceSema = None p2p = p2pNavi.navigation(voiceQueue, voiceSema) p2p.setNorthAt(0) p2p.setPrevCoordinates(0, 0) p2p.setNexCoordinates(1500, 1500) p2p.setNextNodeName("random node") isDone = 0 while(isDone == 0) : x = int(raw_input("x: ")) y = int(raw_input("y: ")) p2p.updateHeading(0) p2p.updateCurCoord(x, y) print "alrdy alerted: " + str(p2p.alreadyAlerted) isDone = p2p.navigate() p2p.setNexCoordinates(2500, 2500) isDone = 0 while(isDone == 0) : x = int(raw_input("x: ")) y = int(raw_input("y: ")) p2p.updateHeading(0) p2p.updateCurCoord(x, y) print "alrdy alerted: " + str(p2p.alreadyAlerted) isDone = p2p.navigate()