Ejemplo n.º 1
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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
lastm = ""


#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
Ejemplo n.º 4
0
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)
ohbot.wait(1)

ohbot.say("Now I am running in python you know", False)

for x in range(0, 10):
    ohbot.move(3, x)
    ohbot.eyeColour(x, 10 - x, x)
    ohbot.wait(0.3)
Ejemplo n.º 5
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)