Exemplo n.º 1
0
def blinkLids():
    while (blinking):
        ohbot.move(ohbot.LIDBLINK, 0)
        sleep(0.2)
        ohbot.move(ohbot.LIDBLINK, 10)
        #wait for a random amount of time for realistic blinking
        sleep(randint(0, 4))
Exemplo n.º 2
0
def moveLoop():

    while True:

        ohbot.move(randint(0, 2), randint(0, 9))

        ohbot.wait(randint(0, 3))
Exemplo n.º 3
0
def blinking():

    while True:

        ohbot.move(ohbot.LIDBLINK, 0, 10)

        ohbot.wait(random() / 3)

        ohbot.move(ohbot.LIDBLINK, 10, 10)

        ohbot.wait(randint(0, 6))
Exemplo n.º 4
0
def handleInputWiki():
    while True:

        text = input("Define:\n")
        ohbot.say(text)
        ohbot.eyeColour(10, 5, 0, True)
        randIndex = randrange(0, len(connectingPhrases))

        choice = connectingPhrases[randIndex]
        ohbot.move(ohbot.HEADTURN, 5)
        ohbot.move(ohbot.EYETILT, 7)
        ohbot.move(ohbot.HEADNOD, 9)
        ohbot.say(choice)

        try:
            res = wikipedia.summary(text)
            ohbot.say(res)
            ohbot.eyeColour(0, 10, 0, True)

        except:

            print('Answer not available')
            ohbot.say("Answer not available")
            ohbot.eyeColour(10, 0, 0, True)
            ohbot.move(ohbot.HEADTURN, 5)
Exemplo n.º 5
0
def handleInput():
    while True:

        text = input("Question:\n")
        ohbot.say(text)
        ohbot.eyeColour(10, 5, 0, True)
        randIndex = randrange(0, len(connectingPhrases))

        choice = connectingPhrases[randIndex]
        ohbot.move(ohbot.HEADTURN, 5)
        ohbot.move(ohbot.EYETILT, 7)
        ohbot.move(ohbot.HEADNOD, 9)
        ohbot.say(choice)

        try:
            res = wolfclient.query(text)
            ans = next(res.results).text
            ans = ans.replace("|", ".")
            ohbot.say(ans)
            ohbot.eyeColour(0, 10, 0, True)

        except:

            print('Answer not available')
            ohbot.say("Answer not available")
            ohbot.eyeColour(10, 0, 0, True)

        ohbot.move(ohbot.HEADTURN, 5)
Exemplo n.º 6
0
# import the ohbot module

from ohbotWin import ohbot

# Reset Ohbot

ohbot.reset()

# Move turn ohbot's head and eyes.
ohbot.move(1, 2)
ohbot.move(3, 1)

# Wait a few seconds for the motors to move

ohbot.wait(2)

# Move head back to the centre and say "Hello World"
ohbot.move(1, 5, 1)
ohbot.say("Hello World")

# Slowly increase the brightness of the eyes.

for x in range(0, 10):

    ohbot.eyeColour(x, x, x)
    ohbot.wait(0.1)

    ohbot.eyeColour(0, 0, 0)
    ohbot.wait(0.2)

ohbot.move(1, 5, 1)
Exemplo n.º 7
0
#this is called on a separate thread to blink the eyes while running
def blinkLids():
    while (blinking):
        ohbot.move(ohbot.LIDBLINK, 0)
        sleep(0.2)
        ohbot.move(ohbot.LIDBLINK, 10)
        #wait for a random amount of time for realistic blinking
        sleep(randint(0, 4))


#start up sequence resets to mid position, sets the eyes to blue then goes to sleep
ohbot.reset()
ohbot.eyeColour(0, 0, 10)
sleep(1.0)
ohbot.eyeColour(0, 0, 0)
ohbot.move(ohbot.HEADNOD, 0)
ohbot.move(ohbot.LIDBLINK, 0)
sleep(2.0)
#close to turn the motors off
ohbot.close()

while (True):
    #get seconds and minutes into strings
    s = strftime("%S", localtime())
    m = strftime("%M", localtime())
    #set this to False for testing to make Ohbot speak continuously
    everyQuarterHour = True
    if ((everyQuarterHour == False) or
        ((everyQuarterHour == True) and
         (m == "00" or m == "15" or m == "30" or m == "45") and m != lastm)):
        lastm = m
Exemplo n.º 8
0
from ohbotWin import ohbot

## Example program for using sensors with ohbot.
## Tilt sensor - a3
## Light sensor - a4
 
ohbot.reset()
while True:    

    val1 = ohbot.readSensor(4)
    
    val2 = ohbot.readSensor(3)
    
    ohbot.eyeColour(val2,10-val2,0,True)
    ohbot.move(ohbot.HEADTURN, val2)
    print(val2)
    if val1 > 2:
        ohbot.say("put me down")
    
    if val2 < 2:
        ohbot.say("who turned out the lights")

    ohbot.wait(0.1)