Exemple #1
0
def main():
    direction = ''
    while direction != "\x03":
        direction = getch()
        if direction == 'w':
            roomba.moveForward(100)
        elif direction == 's':
            roomba.moveBackward(100)
        elif direction == 'a':
            roomba.turnLeft(100)
        elif direction == 'd':
            roomba.turnRight(100)
        elif direction == 'x':
            roomba.stop()
        elif direction == "\x03":
            print('Exiting.. Bye!')
        else:
            print('INVALID:', direction)
    roomba.stop()
Exemple #2
0
def main():
    while True:
        lsens = GPIO.input(left)
        csens = GPIO.input(cent)
        rsens = GPIO.input(rght)

        print(lsens, csens, rsens)

        if lsens == 0 and csens == 0 and rsens == 0:
            roomba.moveBackward(70)
        elif lsens == 0 and csens == 0 and rsens == 1:
            roomba.turnRight(50)
        elif lsens == 0 and csens == 1 and rsens == 0:
            roomba.moveForward(75)
        elif lsens == 0 and csens == 1 and rsens == 1:
            roomba.softRight(50)
        elif lsens == 1 and csens == 0 and rsens == 0:
            roomba.turnLeft(50)
        elif lsens == 1 and csens == 0 and rsens == 1:
            roomba.stop()
        elif lsens == 1 and csens == 1 and rsens == 0:
            roomba.softLeft(50)
        elif lsens == 1 and csens == 1 and rsens == 1:
            roomba.moveForward(75)
Exemple #3
0
 def nomove(self):
     roomba.stop()
     return index_html
Exemple #4
0
 def tright(self):
     roomba.turnRight(100)
     time.sleep(0.1)
     roomba.stop()
     return index_html
Exemple #5
0
 def tleft(self):
     roomba.turnLeft(100)
     time.sleep(0.1)
     roomba.stop()
     return index_html
Exemple #6
0
 def stback(self):
     roomba.moveBackward(100)
     time.sleep(1)
     roomba.stop()
     return index_html
Exemple #7
0
 def stfwd(self):
     roomba.moveForward(100)
     time.sleep(1)
     roomba.stop()
     return index_html
Exemple #8
0
    def run(self):
        while 1:
            value = self.sock.recv(1024).decode()
            print(value)

            if value[0] == 'T':
                BUTTON0 = True
                buttonChanged(0, True)
            if value[0] == 'F':
                BUTTON0 = False
                buttonChanged(0, False)
            if value[1] == 'T':
                BUTTON1 = True
                buttonChanged(1, True)
            if value[1] == 'F':
                BUTTON1 = False
                buttonChanged(1, False)
            if value[2] == 'T':
                BUTTON2 = True
                buttonChanged(2, True)
            if value[2] == 'F':
                BUTTON2 = False
                buttonChanged(2, False)
            if value[3] == 'T':
                BUTTON3 = True
                buttonChanged(3, True)
            if value[3] == 'F':
                BUTTON3 = False
                buttonChanged(3, False)
            if value[4] == 'T':
                BUTTON4 = True
                buttonChanged(4, True)
            if value[4] == 'F':
                BUTTON4 = False
                buttonChanged(4, False)
            if value[5] == 'T':
                BUTTON5 = True
                buttonChanged(5, True)
            if value[5] == 'F':
                BUTTON5 = False
                buttonChanged(5, False)
            if value[6] == 'T':
                BUTTON6 = True
                buttonChanged(6, True)
            if value[6] == 'F':
                BUTTON6 = False
                buttonChanged(6, False)
            if value[7] == 'T':
                BUTTON7 = True
                buttonChanged(7, True)
            if value[7] == 'F':
                BUTTON7 = False
                buttonChanged(7, False)
            if value[8] == 'T':
                BUTTON8 = True
                buttonChanged(8, True)
            if value[8] == 'F':
                BUTTON8 = False
                buttonChanged(8, False)

            cond = False
            for val in value:
                if val == 'T':
                    cond = True
            if cond == False:
                roomba.stop()

            print(cond)

            self.sock.send(b'Oi you sent something to me')