使用指导
引言
本使用指导介绍如何使用ALAudioSourceLocalization模块。
注释: |
本使用指导使用Python语言编写。 |
---|
订阅至ALAudioSourceLocalization/SoundLocated事件
由于ALAudioSourceLocalization/SoundLocated是一个事件,因此您可以使用一个回调来处理您的计算方法。
from naoqi import ALModule, ALProxy import time # define python module class MyModule(ALModule): """ this python module test ALAudioSourceLocalization module """ def __init__( self, strName ): ALModule.__init__( self, strName ); def myCallBack(self, strVarName, angle, strMessage) : """ just print value of event """ print "sound location : " + str(angle[1][0]) + str(angle[1][1]) print "confidence : " + str(angle[1][2]) if __name__ == "__main__": # Replace IP with your robot's IP address broker = ALBroker("pythonBroker", "0.0.0.0", 9600,IP, 9559) pythonModule = MyModule("MypythonModule") ALMemoryProxy = ALProxy("ALMemory") #subscribe to ALAudioSourceLocalization/SoundLocated event ALMemoryProxy.subscribeToEvent("ALAudioSourceLocalization/SoundLocated","MypythonModule", "myCallBack") time.sleep(9) ALMemoryProxy.unsubscribeToEvent("ALAudioSourceLocalization/SoundLocated","MypythonModule")