naoqi python sdk でいくつかの問題が発生しています。Caresse Detector の次のコードがあります。私のクラスは ALModule から継承され、頭部触覚センサーのイベントに登録されます。
# -*- encoding: UTF-8 -*-
import sys
from naoqi import ALProxy
from naoqi import ALModule
from naoqi import ALBroker
import time
class caresseDetector(ALModule):
def __init__(self,name="caresseDetectorModule"):
ALModule.__init__(self,name)
self.tts = ALProxy("ALTextToSpeech")
self.memory = ALProxy("ALMemory")
self.memory.subscribeToEvent("FrontTactilTouched",name,"onFrontTouched")
self.memory.subscribeToEvent("RearTactilTouched",name,"onRearTouched")
self.memory.subscribeToEvent("MiddleTactilTouched",name,"onMiddleTouched")
self.touchFlags = [False,False,False]
self.t0 = 0
self.gestureDuration = 0.5
def onFrontTouched(self):
print self.touchFlags
if time.time()-self.t0 < self.gestureDuration:
if self.touchFlags == [False,True,True]:
self.greet()
else:
self.touchFlags = [False,False,False]
if self.touchFlags == [True,False,False]:
self.t0 = time.time()
elif self.touchFlags == [False,False,False]:
self.t0 = time.time()
self.touchFlags[0] = True
# else:
# self.touchFlags = [False,False,False]
# self.t0 = 0
def onRearTouched(self):
# print self.touchFlags
exec('print ' + str(self.touchFlags))
if time.time() - self.t0 < self.gestureDuration:
if self.touchFlags == [True,True,False]:
self.greet()
else:
self.touchFlags = [False,False,False]
if self.touchFlags == [False,False,True]:
self.t0 = time.time()
elif self.touchFlags == [False,False,False]:
self.t0 = time.time()
self.touchFlags[2] = True
# else:
# self.touchFlags = [False, False, False]
# self.t0 = 0
def onMiddleTouched(self):
# print self.touchFlags
exec ('print ' + str(self.touchFlags))
self.touchFlags[1] = True
if self.touchFlags == [True,True,True]:
self.greet()
# else:
# self.touchFlags = [False,False,False]
# self.t0 = 0
def greet(self):
# print "-------"
exec ('print ' + str(self.touchFlags))
self.t0 = 0
id = self.tts.post.say("Grazie!")
self.touchFlags = [False,False,False]
self.tts.wait(id,0)
def detect(self,broker):
# myBroker = ALBroker("myBroker", "0.0.0.0", 0, self.robotIP, self.port)
try:
while True:
time.sleep(1)
except:
# print
# print "Interrupted, shutting down"
exec ('print')
exec ('print "Interrupted, shutting down"')
broker.shutdown()
def __del__(self):
self.memory = None
self.tts = None
# robotIP = "194.119.214.185"
#
# myBroker = ALBroker("myBroker","0.0.0.0",0,robotIP,9559)
# goofy = caresseDetector("detector")
# goofy.detect(myBroker)
コードの最後にコメントされている最後の手順を実行すると、モジュールは正常に動作しますが、クラスをインポートする外部ファイルで同じコードを実行すると、イベントが発生したときに次のエラーが発生します。
[E] 4099 qitype.dynamicobject: ALPythonTools::eval
python object not found detector
テストする外部ファイルは次のようになります。
from naoqi import ALBroker
from caresseDetector import caresseDetector
robotIP = "194.119.214.185"
myBroker = ALBroker("myBroker","0.0.0.0",0,robotIP,9559)
goofy = caresseDetector("detector")
goofy.detect(myBroker)
オンラインで何も見つかりませんでした。誰か助けてもらえますか?
前もって感謝します