python - Naoqi eventhandling 10 Secounds delay -
i working nao-robot on windows-xp machine , python 2.7.
i want detect markers in speech. whole thing worked, unfortunately have face 10 secounds delay , events aren't detected (the callback function isnt invoked).
first, main-function:
from naoqi import alproxy, albroker speecheventmodule import speecheventmodule mystring = "put \\mrk=1\\ there." nao_ip = "192.168.0.105" nao_port = 9559 memory = alproxy("almemory", nao_ip, nao_port) tts = alproxy("altexttospeech", nao_ip, nao_port) tts.enablenotifications() mybroker = albroker("mybroker", "0.0.0.0", # listen 0, # find free port , use nao_ip, # parent broker ip nao_port) # parent broker port global speecheventlistener speecheventlistener = speecheventmodule("speecheventlistener", memory) memory.subscribetoevent("altexttospeech/currentbookmark", "speecheventlistener", "onbookmarkdetected") tts.say(initialstring)
and here speecheventmodule:
from naoqi import almodule naoqi import alproxy nao_ip = "192.168.0.105" nao_port = 9559 speecheventlistener = none leds = none memory = none class speecheventmodule(almodule): def __init__(self, name, ext_memory): almodule.__init__(self, name) global memory memory = ext_memory global leds leds = alproxy("alleds",nao_ip, nao_port) def onbookmarkdetected(self, key, value, message): print "event detected!" print "key: ", key print "value: " , value print "message: " , message if(value == 1): global leds leds.fadergb("faceleds", 0x00ff0000, 0.2) if(value == 2): global leds leds.fadergb("faceleds", 0x000000ff, 0.2)
please, have same problem? can give me advice?
thanks in advance!
you subscribing event outside module. if not wrong have __init__
method.
class speecheventmodule(almodule): def __init__(self, name, ext_memory): almodule.__init__(self, name) memory = alproxy("almemory") leds = alproxy("alleds")
anyway, check main function keeps running forever (better if catch keyboard interruption) or program end before can catch keyword.
try: while true: time.sleep(1) except keyboardinterrupt: print print "interrupted user, shutting down" mybroker.shutdown() sys.exit(0)
take this tutorial, helpful.
Comments
Post a Comment