def get_route(self, destination): destination = self.get_uid_from_map(destination) current_pos = self.get_current(); dest_id = self.get_index_from_uid(destination) curr_id = self.get_index_from_uid(current_pos) print "dest id = ", dest_id print "curr id = ", curr_id from Route import Route route = Route(curr_id, dest_id, [], [], []) path = route.findRoute() from Imu import IMU imu = IMU() print "imu reading = ", imu.get_heading() from obstacle import Obstacle o = Obstacle() print "setting up motors..." from Motor import Motor motor = Motor(o) motor.setup() print "setting up navigation..." from navigate import Navigate navigator = Navigate(motor,imu) navigator.set_direc(imu) for x in range(0,len(path)-1): #print (path[x],path[x+1]) #navigator.set_direc(imu) navigator.navigate(path[x], path[x+1])
def move(self,num): steps =0 #Forward Direction GPIO.output(7, GPIO.HIGH) #Setting directions Right GPIO.output(8, GPIO.LOW) #Left count = 0 from Imu import IMU #Get direction imu = IMU() print imu.get_heading() while(steps != num*255): ##int( "Step ", steps) #255 count = count + 1 if (count%20==0): if (self.__obstacle.get_distance() < 30): GPIO.output(21, GPIO.HIGH) time.sleep(5) #print "Motor 15: ", steps GPIO.output(15, GPIO.HIGH) #print "Motor 12L ", steps GPIO.output(12, GPIO.HIGH) time.sleep(0.010) GPIO.output(15,GPIO.LOW) GPIO.output(12,GPIO.LOW) time.sleep(0.010) steps = steps +1 GPIO.output(7, GPIO.LOW) GPIO.output(8, GPIO.LOW)