示例#1
0
    def handle(self):
        self.data = self.request.recv(1024).strip()
        global FLAG_L
        global FLAG_U

        print("{0} wrote {1}.".format(self.client_address[0], ord(self.data)))
        # TODO handle data
	
        #0 1 2 3 4 is movement of bot
        #0 for rest, 1 for fwd, 2 for back, 3 for turnLeft, 4 for turnRight
        #5 6 7 8 is movement of webcam arms
        #5 for lookLeft, 6 for lookRight, 7 for lookUp, 8 for lookDown
        if ord(self.data) == 49:
                pennapprobot.move_forward()
        elif ord(self.data) == 50:
                pennapprobot.move_backward()
        elif ord(self.data) == 51:
                pennapprobot.turn_left()
        elif ord(self.data) == 52:
                pennapprobot.turn_right()
        #CHANGE PORT!!!
        elif ord(self.data) == 53 and FLAG_L > -6:
                pennappcam.lower_l()
                FLAG_L-=1
        elif ord(self.data) == 54 and FLAG_L < 6:
                pennappcam.lower_r()
                FLAG_L+=1
        elif ord(self.data) == 55 and FLAG_U > -1:
                pennappcam.upper_b()
                FLAG_U-=1
        elif ord(self.data) == 56 and FLAG_U < 3:
                pennappcam.upper_f()
                FLAG_U+=1
        else:
                print("Nothing found")
        print("{0},{1}".format(FLAG_L,FLAG_U))		
#! /usr/bin/python3
import pennapprobot
import time

for i in range(75):
  pennapprobot.move_forward()
  time.sleep(0.2)