Exemplo n.º 1
0
def wheelDropSensor():
    print "t1"
    while(interface.bumpWheelDrop(2) == 0 or interface.bumpWheelDrop(3) == 0):
        interface.sleep()
    interface.song()
    interface.play()
    interface.driveDirect(0,0,0,0)
Exemplo n.º 2
0
interface.start()
# Sets roomba to save mode.
interface.full()
interface.song()
# creates a infinite while loop that breaks the clean button is pressed.
while (1):
    if (interface.readButton() == 1):
        break

# waits 0.5 for the code to process.
time.sleep(0.5)

# Uses a for loop to run drive and turn codes six times.
while (1):
    # Drives straight at a speed of 200 mm per second.
    x = interface.driveDirect(0, 200, 0, 200)
    # set an array to the array of cliff readings
    cliff = interface.cliffRead()
    '''
    cliffTF = False
    for i in range(0,4):
        if (cliff[i] == 1):
            cliffTF = True
    '''
    # time = distance/speed = 30 cm / 20 cm/s = 1.5 s

    # loop is repeated 50 times because the readButton() method sleep
    # 0.03 seconds in total, and 1.5 seconds/0.03 seconds = 50 times.

    # waits for a total of 1.5 seconds (drives straight for 30 cm)
    # while no bumps/wheel drop and no cliffs
Exemplo n.º 3
0
def turnCounterClockwise():
    interface.driveDirect(0,200,255,56)
    time.sleep(1.846 + random.uniform(-0.307,0.307))
    interface.driveDirect(0,200,0,200)
Exemplo n.º 4
0
#Starts roomba.
interface.start()
#Sets roomba to save mode.
interface.full()
#Initializes values used in the loops.


#To make sure roomba is started and set to passive mode and safe mode. 
while(1):
    if (interface.readButton() == 1):
        break
#When the button is pressed, breaks the while loop and runs the for loop.
#Uses a for loop to run drive straight method and turn method six times 
#in case button is pressed and gets out of the inner for loop.

interface.driveDirect(0,200,0,200)
t = threading.Thread(target=wheelDropSensor)
t.daemon = True
t.start()
counter = 0
while(1):
    if(not(t.isAlive())):
    	t = threading.Thread(target=wheelDropSensor)
        t.daemon = True
        t.start()
    bumpRight = interface.bumpWheelDrop(0)
    interface.sleep()
    bumpLeft = interface.bumpWheelDrop(1)
    interface.sleep()
    cleanButton = interface.readButton()
    interface.sleep()