python-2.7 - 定义 NAOqi ALProxy 代理
问题描述
我为 NAO 机器人编写了一个 python 脚本,以便它可以拍照。我已经编写了 importfrom naoqi import ALProxy
并写出了如下的 try 语句:
try:
postureProxy = ALProxy("ALRobotPosture", ip, port)
motionProxy = ALProxy("ALMotion", ip, port)
speechProxy = ALProxy("ALTextToSpeech", ip, port)
anspeechProxy = ALProxy("ALAnimatedSpeech", ip, port)
sprecogProxy = ALProxy("ALSpeechRecognition", ip, port)
memoryProxy = ALProxy("ALMemory", ip, port)
photoCaptureProxy = ALProxy("ALPhotoCapture", ip, port)
稍后在我的脚本中,我有以下内容:
sprecogProxy.setLanguage("English")
我收到一条错误消息:
NameError: name 'sprecogProxy' is not defined 另外,稍后在我的代码中,我指的是语音代理,正如我所说:
speechProxy.say("Place the object in the view")
我犯了同样的错误。早些时候我的程序工作正常,突然间我收到了这个错误。有什么办法可以减轻这个程序的影响,以便这个脚本可以持续运行?如果需要更多信息,请告诉我。
解决方案
这看起来像是您的 Python 中的一个错误,就像您尝试使用从未创建的变量一样(例如,您的 ALProxy 对象之一在创建时引发了异常,因此它从未到达它创建 sprecogProxy 的部分)。