本文整理汇总了Python中naoqi.ALModule类的典型用法代码示例。如果您正苦于以下问题:Python ALModule类的具体用法?Python ALModule怎么用?Python ALModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ALModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, ip, port, _myBroker):
ALModule.__init__(self, "BasicMotions")
myBroker=_myBroker
bModulePresent = myBroker.isModulePresent("BasicMotions")
print("BasicMotions module status:", bModulePresent)
self.tts = ALProxy("ALTextToSpeech")
global memory
memory = ALProxy("ALMemory")
self.SubscribeAllTouchEvent()
self.NAOip = ip
self.NAOport = port
self.createEyeGroup()
self.eyeColor={'happy': 0x0000FF00,
'sad': 0x00600088,
'scared1': 0x00000060,
'scared2': 0x00000060,
'fear': 0x00000060,
'hope': 0x00FFB428,
'anger': 0x00FF0000}
self.eyeShape={'happy': "EyeTop",
'sad': "EyeBottom",
'scared1': "EyeNone",
'scared2': "EyeNone",
'fear': "EyeBottom",
'hope': "EyeTop",
'anger': "EyeTopBottom"}
self.bScared = False
示例2: __init__
def __init__(self, name):
# 基类初始化
ALModule.__init__(self, name)
self.name = name # 记录实例的名称;订阅事件时要用到;
# ----------> 类成员变量 <----------
# 为机器人头部三块触摸区域指定编码;
# Head/Touch/Front =1
# Head/Touch/Middle =2
# Head/Touch/Rear =3
self.HEAD_FRONT = 1
self.HEAD_MIDDLE = 2
self.HEAD_REAR = 3
# 密码序列,只有按照下面序列依次触摸机器人,才会通过验证;
# 密码元素: 单个数字、字符;后面语音反馈,机器人需要念出密码元素;
self.password = [1,3,2,3,1,2]
# 记录用户的输入密码,最后用来与正确密码做比较;
self.input_passwd = []
# 验证标志, 输入正确密码会设置标志为True; 默认为False;
self.verify_flag = False
# naoqi.ALProxy
try:
# 语音反馈
self.tts = ALProxy("ALTextToSpeech")
# 触摸事件订阅
self.memory = ALProxy("ALMemory")
except Exception, e:
print "Could not create proxy by ALProxy in Class MP3player"
print "Error: ", e
示例3: __init__
def __init__(self, name):
""" Initialise module.
"""
ALModule.__init__(self, name)
# Globals for proxies
global touchProxy
global memoryProxy
self.rightHandFlag = False
self.leftHandFlag = False
self.subscriptionListRight = [
"HandRightBackTouched",
"HandRightLeftTouched",
"HandRightRightTouched"
]
self.subscriptionListLeft = [
"HandLeftBackTouched",
"HandLeftLeftTouched",
"HandLeftRightTouched"
]
# Setup proxies
try:
touchProxy = ALProxy("ALTouch")
except Exception, e:
print "Could not create proxy to ALTouch. Error: ", e
示例4: __init__
def __init__(self):
ALModule.__init__(self, 'sensorModule')
modules.append(self)
self.memory = ALProxy('ALMemory')
try:
self.memory.subscribeToEvent("FrontTactilTouched",
"sensorModule",
"onTactilTouched")
self.memory.subscribeToEvent("RearTactilTouched",
"sensorModule",
"onTactilTouched")
self.memory.subscribeToEvent("HandLeftLeftTouched",
"sensorModule",
"onTactilTouched")
self.memory.subscribeToEvent("HandLeftRightTouched",
"sensorModule",
"onTactilTouched")
self.memory.subscribeToEvent("HandLeftBackTouched",
"sensorModule",
"onTactilTouched")
self.memory.subscribeToEvent("HandRightLeftTouched",
"sensorModule",
"onTactilTouched")
self.memory.subscribeToEvent("HandRightRightTouched",
"sensorModule",
"onTactilTouched")
self.memory.subscribeToEvent("HandRightBackTouched",
"sensorModule",
"onTactilTouched")
except Exception, e:
print e
示例5: __init__
def __init__(self, name, robot_controller, color="red", diameter=0.2):
ALModule.__init__(self, name)
self.name = name
self.blobDetector = robot_controller.blobProxy
if color == "red":
pprint("Looking for a red ball...")
self.blobDetector.setColor(*self.red)
elif color == "blue":
pprint("Looking for a blue ball...")
self.blobDetector.setColor(*self.blue)
elif color == "yellow":
pprint("Looking for a yellow ball...")
self.blobDetector.setColor(*self.yellow)
else:
pwrite(">> Warning << Invalid color set in BallDetector! ")
print("Defaulting to red...")
self.blobDetector.setColor(*self.red)
self.blobDetector.setObjectProperties(20, diameter, "Circle")
self.memoryProxy = robot_controller.memoryProxy
self.memoryProxy.subscribeToEvent("ALTracker/ColorBlobDetected",
self.name, "onBlobDetection")
self.motionProxy = robot_controller.motionProxy
self.camProxy = robot_controller.camProxy
pprint("BallDetector initialized!")
self.lock = threading.Lock()
self.info = None
示例6: __init__
def __init__(self, name): #contructor of the class, which takes two parameters, self refers to the instance of the class and the name parameter which is just a string
ALModule.__init__(self, name) #calling of the contructpor of the ALModule
self.tts = ALProxy("ALTextToSpeech", ip, 9559) #proxy creation on the tts module
self.asr = ALProxy("ALSpeechRecognition", ip, 9559) #proxy creation on the asr module
self.memory = ALProxy("ALMemory", ip, 9559) #proxy creation on the memory module
self.num1 = random.randint(1, 10) #here are two integers randomly selected from 1 to 10
self.num2 = random.randint(1, 10)
self.operator = random.choice("-") #here is randomly choosen operator which is then applied to the equation
self.tts.setLanguage("English") #set the the language which NAO uses for talking
if self.operator == "-": #NAO was programmed to create equations which have a positive result
if self.num1 > self.num2: #the numbers are compared in order to asure that the larger number is first
self.result = str(eval(str(self.num1) + self.operator + str(self.num2))) #the result is evaluated and put into a string so NOA can say it
self.operator = " minus " #and so is the operator
self.question = "What is the result of " + str(self.num1) + self.operator + str(self.num2) + "?" #the question is created
else:
self.result = str(eval(str(self.num2) + self.operator + str(self.num1)))
self.operator = " minus "
self.question = "What is the result of " + str(self.num2) + self.operator + str(self.num1) + "?"
else:
self.result = str(eval(str(self.num1) + self.operator + str(self.num2)))
self.operator = " plus "
self.question = "What is the result of " + str(self.num1) + self.operator + str(self.num2) + "?"
print self.question #the question is printed to the terminal
print self.result #the reslt is printed to the terminal
self.tts.say(self.question) #NAO tells the question
self.speech_recognition() #the speech_recognition method is called
示例7: __init__
def __init__(self, ip, port, publisher):
# Get a (unique) name for naoqi module which is based on the node name
# and is a valid Python identifier (will be useful later)
self.naoqi_name = "ros" + rospy.get_name().replace("/", "_")
#Start ALBroker (needed by ALModule)
self.broker = ALBroker(self.naoqi_name + "_broker",
"0.0.0.0", # listen to anyone
0, # find a free port and use it
ip, # parent broker IP
port # parent broker port
)
#Init superclassALModule
ALModule.__init__( self, self.naoqi_name )
self.memory = ALProxy("ALMemory")
self.proxy = ALProxy("ALSpeechRecognition")
#Keep publisher to send word recognized
self.pub = publisher
#Install global variables needed by Naoqi
self.install_naoqi_globals()
示例8: __init__
def __init__(self, name):
ALModule.__init__(self, name)
try:
redBallDetectionProxy = ALProxy("ALRedBallDetection", NAO_IP, 9559)
except Exception, e:
print "Couldn't create proxy to ALRedBallDetection.\nError was:", e
示例9: __init__
def __init__(self, name, memory):
ALModule.__init__(self, name)
self.__name = name;
self.__memory = memory;
self.__faceDetectedEvent = "FaceDetected";
self.__faceDetectedFunction = "onFaceDetected";
self.__pictureDetectedEvent = "PictureDetected";
self.__pictureDetectedFunction = "onPictureDetected";
self.__speechDetectedEvent = "SpeechDetected";
self.__speechDetectedFunction = "onSpeechDetected";
self.__wordRecognizedEvent = "WordRecognized";
self.__onWordRecognizedFunction = "onWordRecognized";
self.__lastWordRecognizedEvent = "LastWordRecognized";
self.__onLastWordRecognizedFunction = "onLastWordRecognized";
self.__handRightBackTouched = "HandRightBackTouched";
self.__handRightLeftTouched = "HandRightLeftTouched";
self.__handRightRightTouched = "HandRightRightTouched";
self.__handLeftBackTouched = "HandLeftBackTouched";
self.__handLeftLeftTouched = "HandLeftLeftTouched";
self.__handLeftRightTouched = "HandLeftRightTouched";
self.__frontTactilTouched = "FrontTactilTouched";
self.__middleTactilTouched = "MiddleTactilTouched";
self.__rearTactilTouched = "RearTactilTouched";
self.__onTactileEventFunction = "onTactileEvent";
示例10: __init__
def __init__(self,name):
ALModule.__init__(self, name)
rospy.init_node('acore_state_server')
self.moduleName = name
self.connectNaoQi()
self.startSubscriber()
self.dataNamesList = ["DCM/Time",
"Device/SubDeviceList/InertialSensor/AngleX/Sensor/Value",
"Device/SubDeviceList/InertialSensor/AngleY/Sensor/Value",
"Device/SubDeviceList/InertialSensor/AngleZ/Sensor/Value",
"Device/SubDeviceList/InertialSensor/GyroscopeX/Sensor/Value",
"Device/SubDeviceList/InertialSensor/GyroscopeY/Sensor/Value",
"Device/SubDeviceList/InertialSensor/GyroscopeZ/Sensor/Value",
"Device/SubDeviceList/InertialSensor/AccelerometerX/Sensor/Value",
"Device/SubDeviceList/InertialSensor/AccelerometerY/Sensor/Value",
"Device/SubDeviceList/InertialSensor/AccelerometerZ/Sensor/Value"]
self.FSRdataList = ["Device/SubDeviceList/LFoot/FSR/FrontLeft/Sensor/Value",
"Device/SubDeviceList/LFoot/FSR/FrontRight/Sensor/Value",
"Device/SubDeviceList/LFoot/FSR/RearLeft/Sensor/Value",
"Device/SubDeviceList/LFoot/FSR/RearRight/Sensor/Value",
"Device/SubDeviceList/RFoot/FSR/FrontLeft/Sensor/Value",
"Device/SubDeviceList/RFoot/FSR/FrontRight/Sensor/Value",
"Device/SubDeviceList/RFoot/FSR/RearLeft/Sensor/Value",
"Device/SubDeviceList/RFoot/FSR/RearRight/Sensor/Value"]
self.MsgsInit()
示例11: __init__
def __init__(self, name):
ALModule.__init__(self, name)
# No need for IP and port here because
# we have our Python broker connected to NAOqi broker
# HUE service
self._hue = None
self._teller = None
# Create a proxy to ALTextToSpeech for later use
global tts
tts = ALProxy("ALTextToSpeech", NAO_IP, 9559)
# Subscribe to the FaceDetected event:
global memory
self.leds = ALProxy("ALLeds", NAO_IP, 9559)
memory = ALProxy("ALMemory")
memory.subscribeToEvent("MiddleTactilTouched",
"HumanGreeter",
"onMiddleTouchSensed")
# memory.unsubscribeToEvent("WordRecognized",
# "HumanGreeter")
speechrecog = ALProxy("ALSpeechRecognition")
speechrecog.setLanguage("French")
wordList = ["bleu", "rouge", "vert", "jaune",
"porte", "température", "meteo"]
try:
speechrecog.setVocabulary(wordList, True)
except Exception as ex:
_logger.warning("Got exception: %s", ex)
tts.say("Je suis prêt à recevoir des ordres")
示例12: __init__
def __init__(self, name):
ALModule.__init__(self, name)
self.memory = ALProxy("ALMemory")
self.subscriptions = []
print "... initialized " + self.getName()
示例13: __init__
def __init__(self, name):
ALModule.__init__(self, name)
try:
self.asr = ALProxy("ALSpeechRecognition")
except Exception as e:
self.asr = None
self.memory = ALProxy("ALMemory")
示例14: __init__
def __init__(self, name):
ALModule.__init__(self, name)
# Create proxies for the instance.
global memory
memory = ALProxy("ALMemory")
self.tts = ALProxy("ALTextToSpeech")
self.leds = ALProxy("ALLeds")
self.motion = ALProxy("ALMotion")
# Write empty valence and arousal values to memory.
valence = 0
arousal = 0
param1 = 'null'
current_emotion = [(valence, arousal), ("valence_mood", "arousal_mood"), ("personality"), (param1, "param2")]
memory.insertData("Emotion/Current", current_emotion)
# Disable ALAutonomousLife to better demonstrate emotional actions.
self.autonomous_life = ALProxy("ALAutonomousLife")
if (self.autonomous_life.getState() != "disabled"):
self.autonomous_life.setState("disabled")
time.sleep(1.0)
self.motion.wakeUp()
# Run behaviour when a tactile touched.
memory.subscribeToEvent("VAChanged", self.getName(), "express_current_emotion")
示例15: __init__
def __init__(self, name):
ALModule.__init__(self, name)
self.name = name
self.tts = ALProxy("ALTextToSpeech")
self.posture = ALProxy("ALRobotPosture")
self.memory = ALProxy("ALMemory")
self.memory.subscribeToEvent("HandDetectedEvent", name, "handleDetection")