コード例 #1
0
def informNewChoice():
    global clients, newOrder
    dw.set_led_head(dw.led_colors['GREEN'])
    OralInteraction.informNewChoice(clients, newOrder)
    waitingBarman = False
    while not waitingBarman:
        dw.set_led_head(dw.led_colors['GREEN'])
        waitingBarman = OralInteraction.waitingBarmanResponse()
    clients[0].cambiarEstadoPedido('esta listo')
    dw.set_led_head(dw.led_colors['GREEN'])
    OralInteraction.listingMissingObjects(clients)
    dw.set_led_head(dw.led_colors['GREEN'])
    verificationAccepted = OralInteraction.verifyMissingObject()
    dw.set_led_head(dw.led_colors['GREEN'])
    OralInteraction.returnToClients(clients)
コード例 #2
0
    'exit': 14,
    'takeBarPhoto': 15,
    'analyzeImage': 16,
    'checkOrder': 17,
    'waveBarman': 18
}

#Arreglo con los cliente de prueba para la maquina de estados. Comentar si es necesario.
#Cliente = Cliente("","","no esta disponible")
clients = [
    Cliente("Adelaida Zuluaga", "un guarito", "no esta listo"),
    Cliente("Juan José", "una gaseosa", "no esta listo"),
    Cliente("Juana", "un cafe", "no esta listo")
]
#clients = [Cliente("","","no esta listo")]
OralInteraction = OralInteraction()
missingDrink = MissingDrink(clients)
waitingBarman = False
verificationAccepted = False
alternativesAccepted = False
alternatives = ""

dictionary = {
    'age': 21,
    'gender': "female",
    'smile': 0,
    'beard': 0.2,
    'glasses': "glasses",
    'bald': 0.2,
    'hairColor': "brown",
    'eyeMakeUp': True,
コード例 #3
0
from OralInteraction import OralInteraction
from Cliente import Cliente
DictionaryStates = {
    'start': 1,
    'askForClient': 2,
    'waitForClient': 3,
    'informReadyChoice': 4,
    'die': 5
}

OralInteraction = OralInteraction()
# Arreglo de clientes inventado para la máquina de estados
clients = [
    Cliente("Adelaida ", "un cóctel", "no esta listo"),
    Cliente("Juan José", "una gaseosa", "esta listo"),
    Cliente("Pedro", "un cafe con leche", "esta listo")
]

state = 'start'
while True:
    print(state)
    if state == 'start':
        state = 'askForClient'

    if state == 'askForClient':
        OralInteraction.askForMissingClient(clients)
        state = 'waitForClient'

    if state == 'waitForClient':
        input("Press enter for informReadyChoice")
        state = 'informReadyChoice'
コード例 #4
0
def requestNewPerson():
    dw.set_led_head(dw.led_colors['GREEN'])
    OralInteraction.askForNewPerson()
    newPerson = OralInteraction.affirmationCheck(OralInteraction.captureAudio())
    while newPerson == -1:
        dw.set_led_head(dw.led_colors['GREEN'])
        OralInteraction.apologize()
        OralInteraction.askForNewPerson()
        newPerson = OralInteraction.affirmationCheck(OralInteraction.captureAudio())
    if(newPerson==1):
        dw.set_led_head(dw.led_colors['GREEN'])
        OralInteraction.say_something('De acuerdo')
        OralInteraction.say_something('Esperaré al siguiente cliente')
    else:
        dw.set_led_head(dw.led_colors['GREEN'])
        OralInteraction.say_something('Está bien')
        OralInteraction.say_something('Iré a realizar el pedido al bar')
    signals['newPerson'] = (newPerson == 1)
コード例 #5
0
def requestDrink():
    global newClient, clientCount, clients
    repeat = True
    while repeat:
        dw.set_led_head(dw.led_colors['GREEN'])
        OralInteraction.askForDrink()
        drink = OralInteraction.listeningDrink(OralInteraction.captureAudio())
        while drink == "":
            dw.set_led_head(dw.led_colors['GREEN'])
            OralInteraction.apologize()
            OralInteraction.askForDrink()
            drink = OralInteraction.listeningDrink(OralInteraction.captureAudio())
        affirmate = True
        while affirmate:
            dw.set_led_head(dw.led_colors['GREEN'])
            OralInteraction.verifyDrink(drink)
            affirmation = OralInteraction.affirmationCheck(OralInteraction.captureAudio())
            print('---- La Afirmacion es: ' + str(affirmation) + '---------')
            if affirmation == 0:
                affirmate = False
            if affirmation == 1:
                affirmate = False
                repeat = False
    newClient.cambiarPedido(drink)
    clients.append(newClient)
    print()
    clientCount+=1
コード例 #6
0
def askPresentation():
    global newClient
    repeat = True
    while repeat:
        dw.set_led_head(dw.led_colors['GREEN'])
        OralInteraction.askForName()
        name = OralInteraction.listeningName(OralInteraction.captureAudio())
        while name == "":
            dw.set_led_head(dw.led_colors['GREEN'])
            OralInteraction.apologize()
            OralInteraction.askForName()
            name = OralInteraction.listeningName(OralInteraction.captureAudio())
        affirmate = True
        while affirmate:
            dw.set_led_head(dw.led_colors['GREEN'])
            OralInteraction.verifyName(name)
            affirmation = OralInteraction.affirmationCheck(OralInteraction.captureAudio())
            if affirmation == 0:
                affirmate = False
            if affirmation == 1:
                affirmate = False
                repeat = False
    newClient = Cliente(name,"","no esta listo")
コード例 #7
0
def informReadyChoice():
    dw.set_led_head(dw.led_colors['GREEN'])
    OralInteraction.informReadyChoiceClient(clients)
    dw.set_led_head(dw.led_colors['GREEN'])
    OralInteraction.finalExit()
コード例 #8
0
def askForMissingClient():
    dw.set_led_head(dw.led_colors['GREEN'])
    OralInteraction.askForMissingClient(clients)
コード例 #9
0
def listingRequest():
    global clients, missingDrink, alternatives

    #-----------------INDUCIR CLIENTES-----------------

    # clients = [		Cliente("Bryan","un vino","no esta listo"), \
    # 				            Cliente("Lyna","una gaseosa","no esta listo"), \
    # 				            Cliente("Fabián","café","no esta listo")]
    # dictionary = {'age':21,'gender':"male", 'smile':0, 'beard':0.2, 'glasses':"glasses", 'bald' : 0.2, 'hairColor' : "brown", 'eyeMakeUp':True, 'lipMakeUp':True,'headWear':0.9, 'mustache':0.1}
    # for i in range(len(clients)):
    #  	clients[i].assignAttributes(dictionary)

    #---------------------------------------------------

    missingDrink = MissingDrink(clients, capture)
    dw.set_led_head(dw.led_colors['GREEN'])
    OralInteraction.listingRequest(clients)
    waitingBarman = False
    while not waitingBarman:
        dw.set_led_head(dw.led_colors['GREEN'])
        waitingBarman = OralInteraction.waitingBarmanResponse()
    done = False
    takePhoto = True
    while takePhoto:
        while not done:
            done = missingDrink.takeBarPhoto()
        missingDrink.analyzeImage()
        clients = missingDrink.checkOrder()
        verify = True
        while verify:
            dw.set_led_head(dw.led_colors['GREEN'])
            OralInteraction.listingMissingObjects(clients)
            verificationAccepted = OralInteraction.verifyMissingObject()
            if verificationAccepted == 1:
                takePhoto = False
                verify = False
            elif verificationAccepted == 0:
                verify = False
            else:
                dw.set_led_head(dw.led_colors['GREEN'])
                OralInteraction.apologizeBarman()
    reqAlternatives = False
    for client in clients:
        if client.darEstadoPedido() == "no esta listo":
            reqAlternatives = True
            break
    while reqAlternatives:
        dw.set_led_head(dw.led_colors['GREEN'])
        OralInteraction.requestAlternatives()
        dw.set_led_head(dw.led_colors['GREEN'])
        alternatives = OralInteraction.listeningAlternatives()
        while alternatives == '':
            OralInteraction.apologizeBarman()
            alternatives = OralInteraction.listeningAlternatives()
        alternativesAccepted = -1
        while alternativesAccepted == -1:
            dw.set_led_head(dw.led_colors['GREEN'])
            alternativesAccepted = OralInteraction.verifyAlternatives(alternatives)
        if alternativesAccepted == 1:
            reqAlternatives = False
        else:
            dw.set_led_head(dw.led_colors['GREEN'])
            # OralInteraction.apologizeAlternatives()
            reqAlternatives = True
    dw.set_led_head(dw.led_colors['GREEN'])

    # alternatives = "gaseosa y café"

    OralInteraction.waveBarman()
コード例 #10
0
def informOrderState():
    global clients, Recognized_name, newOrder
    dw.set_led_head(dw.led_colors['GREEN'])
    beverageFound = OralInteraction.informOrderState(clients, Recognized_name)
    if beverageFound:
        for i, client in enumerate(clients):
            if (Recognized_name == client.darNombre()):
                del clients[i]
                break
    elif beverageFound == False:
        dw.set_led_head(dw.led_colors['GREEN'])
        OralInteraction.apologizeClient()
        repeat = True
        while repeat:
            dw.set_led_head(dw.led_colors['GREEN'])
            OralInteraction.listingAlternatives(alternatives)
            dw.set_led_head(dw.led_colors['GREEN'])
            newOrder = OralInteraction.listeningDrink(OralInteraction.captureAudio())
            while newOrder == "":
                dw.set_led_head(dw.led_colors['GREEN'])
                OralInteraction.apologize()
                dw.set_led_head(dw.led_colors['GREEN'])
                OralInteraction.listingAlternatives(alternatives)
                dw.set_led_head(dw.led_colors['GREEN'])
                newOrder = OralInteraction.listeningDrink(OralInteraction.captureAudio())
            affirmate = True
            while affirmate:
                dw.set_led_head(dw.led_colors['GREEN'])
                confirmRes = OralInteraction.confirmOrder(newOrder)
                if confirmRes == 0:
                    affirmate = False
                if confirmRes == 1:
                    affirmate = False
                    repeat = False
コード例 #11
0
from threading import Thread
from OralInteraction import OralInteraction
from Cliente import Cliente
from missingDrink import MissingDrink
import darwin_tcp.darwin as dw

OralInteraction = OralInteraction()
OralInteraction.setRedLedFunction(dw.set_led_head)
missingDrink = []
newClient = []
clientCount = 0
clients = []
capture = []
speakThread = []
signals = []
Recognized_name = []
alternatives = ''
newOrder = ''

def checkThreads():
    try:
        if speakThread.isAlive():
            signals['speaking'] = True
        else:
            signals['speaking'] = False
    except:
        signals['speaking'] = False

def launchGreet():
    global speakThread
    speakThread = Thread(target = OralInteraction.greet, args = ())
コード例 #12
0
#Maquina de estados vuelta al cliente
from OralInteraction import OralInteraction
import darwin_tcp.darwin as dw
#from missingDrink import MissingDrink
#from Cliente import Cliente
States = {
    'start': 1,
    'introduction': 2,
    'listening': 3,
    'answer': 4,
    'final': 5
}

dw.init(20063)

OralInteraction = OralInteraction()

state = States['start']
while True:

    if state == States['start']:
        input("Presione enter para empezar")
        state = States['introduction']

    if state == States['introduction']:
        dw.set_action(dw.actions['SPEAK06'])
        OralInteraction.introduction()
        dw.stop_action(dw.actions['STAND'])
        state = States['listening']

    if state == States['listening']:
コード例 #13
0
#Diccionario de estados
DictionaryStates = {
    'start': 1,
    'waitForBarman': 2,
    'informNewChoice': 3,
    'waitForBarmanResponse': 5,
    'verifyBarmanResponse': 7,
    'returnToClients': 8,
    'takeBarPhoto': 9,
    'analyzeImage': 10
}
# Arreglo de clientes inventado para la máquina de estados
clients = [Cliente("Adelaida ", "una gaseosa", "no esta listo")]
# String con el nuevo pedido del cliente al que le falto la bebida
newOrder = "una gaseosa"
OralInteraction = OralInteraction()
missingDrink = MissingDrink(clients)
verificationAccepted = False

state = 'start'
while 1:
    print(state)
    if state == 'start':
        state = 'waitForBarman'

    if state == 'waitForBarman':
        input("Press enter if barman is ready to listen")
        state = 'informNewChoice'

    if state == 'informNewChoice':
        #Dice el nuevo pedido del cliente faltante
コード例 #14
0
#Maquina de estados vuelta al cliente
from OralInteraction import OralInteraction
#from missingDrink import MissingDrink
from Cliente import Cliente
DictionaryStates = {'arriveToClient' : 1, 'requestClients' : 2, 'clientArrived' : 3,'identifyClient':4,'informOrderState':5, 'apology':6, 'listingAlternatives': 9, 'listenChoice':10,'confirmOrder':11, 'returnToBar':13, 'exit':14, 'arrivedNewClient':15, 'confirmUnderstoodNewChoice' : 16}
clients = [Cliente("Adelaida","un guarito","no esta listo"),Cliente("Juan","un cafe","esta listo"),Cliente("José","un milo","esta listo")]
OralInteraction= OralInteraction()
#missingDrink= MissingDrink()
beverageFound= False
# Variable para la nueva orden
newOrder= " "
# Numero de clientes totales
totalClients = len(clients)-1
# Variable de iteración
i = 0
# Alternativas dadas por el bartender previamente
alternatives = " agua, gaseosa o cerveza"
# arreglo de nombres que le pueden pasar dependiendo de la persona que identifica, en la practica solo es el string que se identifica en IdentifyClient
nombres = ["Adelaida", "Juan", "José"]
missUnderstoodNewOrder = False
apologizeBeveerageNotFound = False

def func(x):
	pass

OralInteraction.setRedLedFunction(func)

state = 'arriveToClient'
while 1:
	if state == 'arriveToClient':
		input("Press Enter to state arriveToClient")
コード例 #15
0
    'waitingNewPerson': 11,
    'exit': 12,
    'apology': 13,
    'listeningNewPerson': 14,
    'verifyNewPerson': 15,
    'affirmationNewPerson': 16
}

state = 'start'
missunderstoodName = False
missunderstoodDrink = False
missunderstoodNewPerson = False
name = ""
drink = ""
newPerson = ""
OralInteraction = OralInteraction()
clientCount = 0
clients = []

while True:
    print(state)
    if state == 'start':
        state = 'introduction'
        print(state)

    if state == 'introduction':
        OralInteraction.greet()
        state = 'waitingPerson'
        print(state)

    if state == 'waitingPerson':