def provideDirections(self, nextCheckPoint, currentCheckPoint, pos_x, pos_y, speaker):
                print "start of provideDirections function"
                sayNextCheckPoint = 'next checkpoint %s\n' %(self.mapinfo['map'][nextCheckPoint - 1]['nodeName'])
                print sayNextCheckPoint
                
		speaking_proc = Process(target=speaker.threadedFeedback, args=(sayNextCheckPoint,))
		speaking_proc.start()
		speaking_proc.join()
		
		detourCheckPoint = False
                reachCheckPoint = False
                exitMap = False

		#initialise starting time
                start_time = time.time()
                time_to_speak = time.time()
		dist = None
		change_direction = None
		direction = '%s %lf degrees, %lf'
		speak_direction = '%s %d degrees, and walk %d point %d meters\n'
		isFirstTimeGivingDirections = False
		isFirstTimeProcDirections = True
		oneSecondHasPassed = False

                while True:
                        if (time.time() - start_time > 1) or isFirstTimeProcDirections:
                                start_time = time.time()
                                #distance, heading = input()
                                dataParser = DataParser()
				dataParser.get_readings()
                                step = dataParser.get_step_read()
                                #step = 1 # TO BE COMMENTED OUT
                                print "NUMBER OF STEPS %d\n" % (step)
                                compass_read = dataParser.get_compass_read()
				##IR_read = dataParser.get_IR_read()
				#sonar_read = dataParser.get_ultrasound_read()
                                #print "compass_read", compass_read
				#warnUser = False
                                ##del dataParser
				
				if not isFirstTimeProcDirections:
                                        print 'going to calculate displacement'
                                        #reachCheckPoint, pos_x, pos_y, detourCheckPoint, speak_direction = self.calcDisplacement(1, pos_x, pos_y, nextCheckPoint, currentCheckPoint)
                                	if step == 0:
						print 'going into calcDisplacement\n\n\n'
                                	        reachCheckPoint, pos_x, pos_y, detourCheckPoint, speak_direction = self.calcDisplacement(0, compass_read, 5, pos_x, pos_y, nextCheckPoint, currentCheckPoint)
					else:
                                		for i in range(step):
							print 'step #', i
                                        		reachCheckPoint, pos_x, pos_y, detourCheckPoint, speak_direction = self.calcDisplacement(1, compass_read, i, pos_x, pos_y, nextCheckPoint, currentCheckPoint)
				if oneSecondHasPassed:
                                        print 'one second has passed'
					isFirstTimeGivingDirections = True
					oneSecondHasPassed = False

				if isFirstTimeProcDirections:
                                        print 'isFirstTimeProcDirections'
					oneSecondHasPassed = True
					isFirstTimeProcDirections = False

                        if (time.time() - time_to_speak > 6) or isFirstTimeGivingDirections:
				isFirstTimeGivingDirections = False
                                time_to_speak = time.time()
                                print speak_direction
                                speaking_proc = Process(target=speaker.threadedFeedback, args=(speak_direction,))
                                speaking_proc.start()

                        if reachCheckPoint:
                                #speak_direction = 'arrived'
                                #print speak_direction
                                #speaking_proc = Process(target=speaker.threadedFeedback, args=(speak_direction,))
                                #speaking_proc.start()
                                break

                        if detourCheckPoint:
                                break
                        # check if user has left the map
##                        if (self.exitMap(pos_x, pos_y)):
##                                exitMap = True
##                                break
##                        else:
##                                print "don't exit map yet"

                return reachCheckPoint, pos_x, pos_y, detourCheckPoint, exitMap
    def provideDirections(self, nextCheckPoint, currentCheckPoint, pos_x,
                          pos_y, speaker):
        print "start of provideDirections function"
        sayNextCheckPoint = 'your next checkpoint is %s\n' % (
            self.mapinfo['map'][nextCheckPoint - 1]['nodeName'])
        print sayNextCheckPoint

        speaking_proc = Process(target=speaker.threadedFeedback,
                                args=(sayNextCheckPoint, ))
        speaking_proc.start()
        speaking_proc.join()

        detourCheckPoint = False
        reachCheckPoint = False
        exitMap = False

        #initialise starting time
        start_time = time.time()
        time_to_speak = time.time()
        dist = None
        change_direction = None
        direction = '%s %lf degrees, %lf'
        speak_direction = '%s %d degrees, and walk %d point %d meters\n'
        isFirstTimeGivingDirections = False
        isFirstTimeProcDirections = True
        oneSecondHasPassed = False

        while True:
            if (time.time() - start_time > 1) or isFirstTimeProcDirections:
                start_time = time.time()
                #distance, heading = input()
                dataParser = DataParser()
                dataParser.get_readings()
                step = dataParser.get_step_read()
                #step = 1 # TO BE COMMENTED OUT
                print "NUMBER OF STEPS %d\n" % (step)
                compass_read = dataParser.get_compass_read()
                ##IR_read = dataParser.get_IR_read()
                #sonar_read = dataParser.get_ultrasound_read()
                #print "compass_read", compass_read
                #warnUser = False
                ##del dataParser

                if not isFirstTimeProcDirections:
                    print 'going to calculate displacement'
                    #reachCheckPoint, pos_x, pos_y, detourCheckPoint, speak_direction = self.calcDisplacement(1, pos_x, pos_y, nextCheckPoint, currentCheckPoint)
                    if step == 0:
                        print 'going into calcDisplacement\n\n\n'
                        reachCheckPoint, pos_x, pos_y, detourCheckPoint, speak_direction = self.calcDisplacement(
                            0, compass_read, 5, pos_x, pos_y, nextCheckPoint,
                            currentCheckPoint)
                    else:
                        for i in range(step):
                            print 'step #', i
                            reachCheckPoint, pos_x, pos_y, detourCheckPoint, speak_direction = self.calcDisplacement(
                                1, compass_read, i, pos_x, pos_y,
                                nextCheckPoint, currentCheckPoint)
                if oneSecondHasPassed:
                    print 'one second has passed'
                    isFirstTimeGivingDirections = True
                    oneSecondHasPassed = False

                if isFirstTimeProcDirections:
                    print 'isFirstTimeProcDirections'
                    oneSecondHasPassed = True
                    isFirstTimeProcDirections = False

            if (time.time() - time_to_speak >
                    6) or isFirstTimeGivingDirections:
                isFirstTimeGivingDirections = False
                time_to_speak = time.time()
                print speak_direction
                speaking_proc = Process(target=speaker.threadedFeedback,
                                        args=(speak_direction, ))
                speaking_proc.start()

            if reachCheckPoint:
                #speak_direction = 'arrived'
                #print speak_direction
                #speaking_proc = Process(target=speaker.threadedFeedback, args=(speak_direction,))
                #speaking_proc.start()
                break

            if detourCheckPoint:
                break
            # check if user has left the map
##                        if (self.exitMap(pos_x, pos_y)):
##                                exitMap = True
##                                break
##                        else:
##                                print "don't exit map yet"

        return reachCheckPoint, pos_x, pos_y, detourCheckPoint, exitMap
	#	userInput = True
	print 'userInput is', userInput
	return userInput

       



if __name__ == '__main__':
        signal.signal(signal.SIGINT, signal_handler)
        #building = raw_input()
        #level = raw_input()
        internetConnection = False
	speechInput = None
	speaker = AudioFeedback()
	userInputInitialise = DataParser()
	interBuildingNumber = 0
	myMap = []
	buildingList = []
	levelList = []
        
	#initialising program announcement
	initProgAnnouncement = 'program initiated. press hex for key pad input or hold 5 for voice input'
	print initProgAnnouncement
	speaking_proc = Process(target=speaker.threadedFeedback, args=(initProgAnnouncement,))
	speaking_proc.start()
	speaking_proc.join()

	voiceInput, numpadData = userInputInitialise.location_input()
	#typeOfInput = userInputInitialise.location_input()
                    print 'inputAnswer is neither affirmative nor negative'
                    pass
    #if userInput is None:

#	userInput = True
    print 'userInput is', userInput
    return userInput

if __name__ == '__main__':
    signal.signal(signal.SIGINT, signal_handler)
    #building = raw_input()
    #level = raw_input()
    internetConnection = False
    speechInput = None
    speaker = AudioFeedback()
    userInputInitialise = DataParser()
    interBuildingNumber = 0
    myMap = []
    buildingList = []
    levelList = []

    #initialising program announcement
    initProgAnnouncement = 'program initiated. press hex for key pad input or hold 5 for voice input'
    print initProgAnnouncement
    speaking_proc = Process(target=speaker.threadedFeedback,
                            args=(initProgAnnouncement, ))
    speaking_proc.start()
    speaking_proc.join()

    voiceInput, numpadData = userInputInitialise.location_input()
    #typeOfInput = userInputInitialise.location_input()