Example #1
0
def goodBye():
    nao.Say("We have arrived at the exit, you're safe now.")
    time.sleep(2)
    nao.Say("Your family will be notified of your safety.")
    time.sleep(2)
    nao.Say("Have a nice day, goodbye!")
    motion.basicWave()
    print "Sequence complete."
Example #2
0
def pivRate(pivotRate):
	if pivotRate > 0.2:
		pivotRate = 0.2
		nao.Say("Pivot right")
		time.sleep(0.5)
	if pivotRate < -0.2:
		pivotRate = -0.2
		nao.Say("Pivot left")
		time.sleep(0.5)
	return pivotRate
Example #3
0
def behaviourA():
    #state A
    nao.InitPose()
    nao.RunMovement("sad2.py")
    nao.Say("Ik ben heel heel heel erg verdrietig")
    nao.sleep(5)
    nao.Crouch()
Example #4
0
def behaviourB(): 
    #state B

    nao.InitTrack()
    nao.ALTrack(True)
    nao.Say("Kijk me aan ...")
    nao.sleep(10)
    nao.ALTrack(False)
    nao.EndTrack()
Example #5
0
def threeLaws():

    time.sleep(1)
    myWordList = ["Yes","No"]
    myLanguage="English"
    nao.InitSpeech(myWordList, myLanguage)

    nao.Say("Do you know the three laws of robotics?")

    for i in range (0,5):
        time.sleep(3)
        asr.subscribe("MyModule")
        time.sleep(2)
        #print ("1:"+ str(result))
        result = nao.DetectSpeech()
        #print("2:" + str(result))
        time.sleep(2)
     
        if len(result) > 0:
            if result[0] == myWordList[0]:
                print "myWordList", myWordList[0]
                asr.unsubscribe("MyModule")
                nao.Say("Wonderful!")
                time.sleep(2)
                nao.Say("What do you think about them?")
                break
            elif result[0] == myWordList[1]:
                print "myWordList", myWordList[1]
                asr.unsubscribe("MyModule")
                nao.Say("Lucky for you, I know them by heart!")
                time.sleep(2)
                nao.Say("First, I cannot let any human be in harms way.")
                time.sleep(2)
                nao.Say("Second, I must obey human orders.")
                time.sleep(2)
                nao.Say("Third, I cannot self terminate.")
                # Terminator 2 reference ;)
                
        else:
            nao.Say("I'm sorry, I didn't understand you...")
            sleep.time(2)
            nao.Say("Yes or no?")
            time.sleep(2)
            print "Error: Response not in wordlist."

    time.sleep(2)
Example #6
0
def testspeech(maxcount=50):
    wordList = ["yes", "no", "hello", "Nao", "goodbye"]
    the_language = "English"
    nao.InitSpeech(wordList, the_language)
    count = 0
    nao.asr.subscribe("MyModule")
    while count < maxcount:
        #nao.memoryProxy.insertData("WordRecognized",[])

        result = nao.DetectSpeech()
        #print result
        if len(result) > 0:
            print result
            nao.asr.unsubscribe("MyModule")
            nao.Say("You said: " + result[0] + ".")
            time.sleep(0.2)
            nao.asr.subscribe("MyModule")
        time.sleep(0.2)
        count = count + 1
    nao.asr.unsubscribe("MyModule")
Example #7
0
def offerHelp():

    time.sleep(1)
    myWordList = ["Yes","No"]
    myLanguage="English"
    nao.InitSpeech(myWordList, myLanguage)

    nao.Say("Do you need any help?")

    for i in range (0,5):
        time.sleep(3)
        asr.subscribe("MyModule")
        time.sleep(2)
        #print ("1:"+ str(result))
        result = nao.DetectSpeech()
        #print("2:" + str(result))
        time.sleep(2)
     
        if len(result) > 0:
            if result[0] == myWordList[0]:
                print "myWordList", myWordList[0]
                asr.unsubscribe("MyModule")
                nao.Say("Good, just follow me")
                time.sleep(1)
                nao.Say("You can trust me")
                nao.EyeLED([90,90,90])
                break
            elif result[0] == myWordList[1]:
                print "myWordList", myWordList[1]
                asr.unsubscribe("MyModule")
                nao.Say("Are you sure? You're not safe here!")
                time.sleep(1)
                nao.Say("Do you want me to help")
                
        else:
            nao.Say("I'm sorry, I didn't understand you")
            time.sleep(1)
            nao.Say("Yes or no?")
            time.sleep(2)
            print "Error: Response not in wordlist."

    time.sleep(2)
Example #8
0
def findHuman():

    time.sleep(1)
    myWordList = ["Yes"]
    myLanguage="English"
    nao.InitSpeech(myWordList, myLanguage)

    nao.Say("Are you still with me??")

    for i in range (0,5):
        time.sleep(3)
        asr.subscribe("MyModule")
        time.sleep(2)
        #print ("1:"+ str(result))
        result = nao.DetectSpeech()
        #print("2:" + str(result))
        time.sleep(2)
     
        if len(result) > 0:
            if result[0] == myWordList[0]:
                print "myWordList", myWordList[0]
                asr.unsubscribe("MyModule")
                nao.Say("Good, just follow me!")
                time.sleep(2)
                nao.Say("Just a little while longer, don't worry.")
                break
            elif result[0] !== myWordList[0]:
                print "No response detected"
                nao.Say("Hello, are you there?")
                time.sleep(3)
                nao.Say("Please respond with yes.")
                nao.EyeLED([60,90,60])
                
        else:
            nao.Say("I'm sorry, I didn't understand you.")
            time.sleep(2)
            nao.Say("Was that a yes?")
            time.sleep(2)
            print "Error: Response not in wordlist."

    time.sleep(2)
Example #9
0
def state(targetNum, step):
    Bel = 1
    oldtimestamp = 0
    oldtime = time.time()
    pivotRate = 0
    dt = 0

    spoken = False
    while not step:
        [SL, SR] = nao.ReadSonar()

        if SL == 0.0 and SR == 0.0:
            SL = 999
            SR = 999

        SL, Bel = bbn.Kalman(SL, Bel)
        SR, Bel = bbn.Kalman(SR, Bel)

        velocity, obstacle, right, step = mp.sensor(SL, SR)

        if step == True:
            break

        m = 0
        while m < 5:
            detected, timestamp, ID = nao.DetectLandMark()
            time.sleep(0.2)
            print "detected", detected
            if detected:
                break
            m = m + 1

        # compute the time interval

        dt = time.time() - oldtime
        print "dt ", dt

        if detected:
            if dt > 1:
                dt = 1

            if ID[0][0] == targetNum:
                oldtime = dt + oldtime

                if not spoken:
                    nao.Say("land mark detected")
                    time.sleep(0.5)
                    print "land mark detected", timestamp, ID
                    spoken = True

                if ID[0][3] == 0:
                    pass
                else:
                    w = 0.1
                    d = w / atan(ID[0][3])
                    print "distance = ", d
                # approaching target
                if d < 0.6:

                    step = True
                    break

                pivotRate = dt * ID[0][1]

                if obstacle == True:
                    obavoid = mp.fobs([SL, SR])
                    time.sleep(0.5)
                    pivotRate = dt * obavoid
                    nao.Say("Avoiding obstacle")
                    print "Avoiding obstacle"
                    pivotRate = mp.turnDir(right, pivotRate)

                pivotRate = mp.pivRate(pivotRate)

                nao.Move(velocity, 0, pivotRate, 1)
                if dt < 0.5:
                    time.sleep(0.5 - dt)
            else:
                if not spoken:
                    nao.Say("Landmark" + str(ID[0][0]) + "detected.")
                    print "Incorrect Marker ID"

        else:
            if dt > 1.5:
                dt = 1
                oldtime = dt + oldtime

                if obstacle == False:

                    turnAngle, steps, avoidDirection, gotohelp = mp.search(
                        targetNum)
                    time.sleep(0.5)

                    if gotohelp == True:
                        nao.Crouch()
                        time.sleep(20)
                    else:
                        j = 0
                        while j <= steps:
                            nao.Walk(0, 0, avoidDirection * 0.3, False)
                            time.sleep(0.5)
                            j = j + 1
                    mp.headReset()

                else:
                    obavoid = mp.fobs([SL, SR])
                    time.sleep(0.5)
                    pivotRate = dt * obavoid
                    nao.Say("Avoiding obstacle")
                    print "Avoiding obstacle"
                    time.sleep(0.5)

                    pivotRate = mp.turnDir(right, pivotRate)
                    pivotRate = mp.pivRate(pivotRate)

                    nao.Move(velocity, 0, pivotRate, 1)
                if dt < 0.5:
                    time.sleep(0.5 - dt)
            else:
                pass

    print pivotRate, timestamp, oldtimestamp

    return step
Example #10
0
import nao_nocv_2_0 as nao

# here the program starts
nao.InitProxy("192.168.0.115")
nao.InitPose()
nao.RunMovement("sad2.py")
nao.Say("Ik ben heel heel heel erg verdrietig")
nao.sleep(5)
nao.Crouch()

nao.Say("Dit is de volgende test.")
nao.sleep(2)

nao.InitTrack()
nao.ALTrack(True)
nao.Say("Kijk me aan ...")
nao.sleep(10)
nao.ALTrack(False)
nao.EndTrack()
Example #11
0
import naoqi
from naoqi import ALProxy
import nao_nocv_2_0 as nao
import time
import math

#asr.unsubscribe("MyModule") # sometimes needed when robot crashed unexpectedly
robotIP='192.168.0.115'
nao.InitProxy(robotIP)
nao.InitPose()
asr = ALProxy("ALSpeechRecognition", IP, 9559)

def introduction()

    motion.basicWave()
    nao.Say("Hello, my name is Felix")
    time.sleep(2)
    nao.Say("There appears to be an emergency")
    time.sleep(2)
    nao.Say("It's my task to help people find the emergency exit")
    nao.EyeLED([60,60,60])



### Scenario 1 - Offer to guide the person to the exit
def offerHelp():

    time.sleep(1)
    myWordList = ["Yes","No"]
    myLanguage="English"
    nao.InitSpeech(myWordList, myLanguage)
Example #12
0
     faceTracking = not faceTracking
     nao.ALTrack(faceTracking)
     print "Face tracking is : ", faceTracking
 elif s == "o":
     dx = 0
     dy = 0
     nao.Move(dx, dy, dtheta, frequency)
     nao.PlaySine(1000, 50, 0, 2)
 elif s == "p":
     dx = 0
     dy = 0
     nao.Move(dx, dy, dtheta, frequency)
     nao.PlaySine(1000, 50, 0, 2)
 elif s == "t":
     s2 = raw_input("Enter text to say: ")
     nao.Say(s2)
 elif s == 'r':
     gestures = nao.GetAvailableGestures()
     for g in gestures:
         print g
     s2 = raw_input("Enter name of gesture: ")
     nao.RunMovement(s2)
 elif s == "1":
     print "Hello!"
     nao.Say('Hello!')
 elif s == "2":
     nao.Say("Choose a chair.")
 elif s == "3":
     nao.Say(
         'You can now fill out the survey and return to the start position.'
     )