本文整理汇总了Python中naoqi.ALProxy.wait方法的典型用法代码示例。如果您正苦于以下问题:Python ALProxy.wait方法的具体用法?Python ALProxy.wait怎么用?Python ALProxy.wait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类naoqi.ALProxy
的用法示例。
在下文中一共展示了ALProxy.wait方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: say
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import wait [as 别名]
def say( text, shape, speed, color ):
# Verbindung mit ALBroker herstellen
tts = ALProxy( "ALTextToSpeech", config.naoIP, config.naoPort )
mem = ALProxy( 'ALMemory', config.naoIP, config.naoPort )
# Sprachausgabe formatieren
sentence = "\RSPD="+ str( speed )+ "\ "
sentence += "\VCT="+ str( shape ) + "\ "
sentence += text
sentence += "\RST\ "
# AUugenfarbe setzen
setEyeCol( color )
# Text ausgeben und bis Ende warten
if config.bodytalk:
mem.raiseMicroEvent( "naostory_say_bodytalk", sentence )
while mem.getData( "naostory_talking" ) :
try: sleep(0.1)
except: pass
else:
ID = tts.post.say( str(sentence) )
tts.wait( ID, 0 )
return True
示例2: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import wait [as 别名]
def main():
""" Main entry point
"""
################MAIN() CODE FOR FREEZING BOT#############################
global brokyControlly
brokyControlly = BrokerController()
brokyControlly.createBroker()
# Warning: BotFreezer must be a global variable
# The name given to the constructor must be the name of the
# variable
global BotFreezer
BotFreezer = BotFreezerModule("BotFreezer")
##########END MAIN() CODE FOR FREEZING BOT################################
#############################PROGRAM SPECIFIC ############################
# Program specific proxies
speechProxy = ALProxy("ALTextToSpeech")
global nonBlockyWalky
nonBlockyWalky = NonBlockWalk2("nonBlockyWalky")
nonBlocky = ALProxy("nonBlockyWalky")
# nonBlocky also has to have a post in it, along with
# the walk commands INSIDE "NonBlockWalk2.py", if wait()
# is going to work correctly
id = nonBlocky.post.walk()
nonBlocky.wait(id, 0)
speechProxy.say("I have arrived.")
############################END PROGRAM SPECIFIC############################
################MAIN() CODE FOR FREEZING BOT################################
brokyControlly.waitToStop()
示例3: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import wait [as 别名]
def main():
""" Main entry point
"""
########################FOR FREEZING BOT#######################
global brokyControlly
brokyControlly = BrokerController()
brokyControlly.createBroker()
# Warning: BotFreezer must be a global variable
# The name given to the constructor must be the name of the
# variable
global BotFreezer
BotFreezer = BotFreezerModule("BotFreezer")
global cmModule
cmModule = customMotions("cmModule")
cm = ALProxy("cmModule")
###################FOR FREEZING BOT############################
########################FOR FOOT#######################
global FootFreezer
FootFreezer = FootFreezerModule("FootFreezer")
###################FOR FOOT############################
stiffnesses = 1.0
motionProxy.setStiffnesses("Body", stiffnesses)
postureProxy.goToPosture("StandInit", 1.0)
time.sleep(1)
motionProxy.setExternalCollisionProtectionEnabled("All", False)
#id = cm.post.detectMarkAndMoveToRight()
#cm.wait(id,0)
id = cm.post.moveForward(1)
cm.wait(id,0)
id = cm.post.wave()
cm.wait(id,0)
tts.say("Hello, I am Robbie.")
id = cm.post.turnAround()
cm.wait(id,0)
#id = cm.post.detectMarkAndMoveToLeft()
#cm.wait(id,0)
#id = cm.post.detectMarkAndMoveTo()
#cm.wait(id,0)
id = cm.post.turnAround()
cm.wait(id,0)
#id = cm.post.turnAround()
#cm.wait(id, 0)
#time.sleep(2)
#tts.say("I am turned around")
postureProxy.goToPosture("Sit", 1.0)
#################FOR FREEZING BOT###########################
# end broker to stop
brokyControlly.waitToStop()
示例4: plSound
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import wait [as 别名]
def plSound( path, bg ):
# Verbindung mit ALAudioPlayer herstellen
player = ALProxy( 'ALAudioPlayer', config.naoIP, config.naoPort )
# Path verarbeiten
path = str(path)
path = path.strip()
# Laustaerke setzen
global plVolume
print "play soundfile |"+path+"| with volume "+str( int(plVolume * 100) )+"%"
print "\tbg = " + str(bg) + ""
# Datei abspielen
if not bg:
try: ID = player.post.playFile( path, plVolume, 0.0 )
except: return False
else:
try: ID = player.post.playFileInLoop( path, plVolume , 0.0 )
except: return False
Sounds.append( [path, ID] )
if not bg:
# ggf. auf Ende des Abspielens warten
player.wait( ID, 0 )
# Apsielvorgang wider aus Liste entfernen
Sounds.remove( [path, ID] )
return True
示例5:
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import wait [as 别名]
namesMotion = []
# todo: replace time data with parametric values, or see ipnb for other ideas.
timesMotion = []
keysMotion = []
movementList = []
movementList = mtmd.successList[self.currentStateGameWinAnimation]
for n, t, k in movementList:
namesMotion.append(n)
timesMotion.append(t)
keysMotion.append(k)
self.bIsRunning = True
try:
id = animatedSpeechProxy.post.say(sayPhrase1, self.bodyLanguageModeConfig)
self.ids.append(id)
animatedSpeechProxy.wait(id, 0)
id1 = aupProxy.post.playFile(soundFile, self.volume, self.pan)
self.ids.append(id1)
id2 = robotMotionProxy.post.angleInterpolationBezier(namesMotion, timesMotion, keysMotion)
self.ids.append(id2)
robotMotionProxy.wait(id2, 0)
id3 = animatedSpeechProxy.post.say(sayPhrase2, self.bodyLanguageModeConfig)
self.ids.append(id3)
animatedSpeechProxy.wait(id3, 0)
finally:
try:
self.ids.remove(id)
self.ids.remove(id1)
示例6: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import wait [as 别名]
def main():
""" Main entry point
"""
########################FOR FREEZING BOT#######################
global brokyControlly
brokyControlly = BrokerController()
brokyControlly.createBroker()
# Warning: BotFreezer must be a global variable
# The name given to the constructor must be the name of the
# variable
global BotFreezer
BotFreezer = BotFreezerModule("BotFreezer")
global cmModule
cmModule = customMotions("cmModule")
cm = ALProxy("cmModule")
###################FOR FREEZING BOT############################
stiffnesses = 1.0
motionProxy.setStiffnesses("Body", stiffnesses)
postureProxy.goToPosture("StandInit", 1.0)
time.sleep(1)
motionProxy.setExternalCollisionProtectionEnabled("All", False)
#nonBlocky also has to have a post in it, along with
#the walk commands INSIDE "NonBlockWalk2.py", if wait()
#is going to work correctly
#Print information
# print "x " + str(x) + " (in meters)
# print "y " + str(y) + " (in meters)"
# print "z " + str(z) + " (in meters)"
#turnAround()
#detectMarkAndMoveTo()
#id = customMotions.detectMarkAndMoveTo()
#customMotions.moveForwardY(0, -.25)
#customMotions.detectMarkAndMoveTo()
#customMotions.wave()
#tts.say("Hello I am Robbie")
id = cm.post.detectMarkAndMoveTo()
cm.wait(id, 0)
id = cm.post.moveForwardY(0, -.25)
cm.wait(id, 0)
id = cm.post.detectMarkAndMoveTo()
cm.wait(id, 0)
# id = cm.post.wave()
# cm.wait(id, 0)
id = cm.post.turnAround()
cm.wait(id, 0)
id = cm.post.detectMarkAndMoveTo()
cm.wait(id, 0)
id = cm.post.detectMarkAndMoveTo()
cm.wait(id, 0)
id = cm.post.turnAround()
cm.wait(id, 0)
#time.sleep(2)
#tts.say("I am turned around")
#customMotions.detectMarkAndMoveTo()
#customMotions.detectMarkAndMoveTo()
#customMotions.turnAround()
#motionProxy.changeAngles("HeadYaw",1, 0.1)
#print motionProxy.getAngles("HeadYaw",False)
#turnLeft90()
#print motionProxy.getAngles("HeadYaw", False)
postureProxy.goToPosture("Sit", 1.0)
#################FOR FREEZING BOT###########################
# end broker to stop
brokyControlly.waitToStop()
示例7: ALProxy
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import wait [as 别名]
from naoqi import ALProxy
if __name__ == '__main__':
motion = ALProxy("ALMotion", "nao.local", 9559)
tts = ALProxy("ALTextToSpeech", "nao.local", 9559)
motion.setStiffnesses("Body", 1.0)
motion.moveInit()
motion.moveTo(0.5, 0, 0)
id = motion.post.moveTo(0.5, 0, 0)
motion.wait(id, 0)
tts.say("I am walking")
示例8: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import wait [as 别名]
class NaoBehavior:
def __init__(self, robotIP ,port):
# behavior lists
self.l_type = []
self.l_behaviors = []
# auto
self.breathEnabled = False
self.idletime = 8 # waits for half a second so 10 = 5 seconds
self.idlecount = 0
# activation
self.active = False
self.resting = False
self.speechini= False
self.headOdom = [0,0]
self.stop = False
self.headlock =False
self.enableAutoRotate = True
# proxies
self.memoryProxy = ALProxy("ALMemory", robotIP, port)
self.managerProxy = ALProxy("ALBehaviorManager", robotIP, port)
self.motionProxy = ALProxy("ALMotion", robotIP, port)
self.animatedSpeechProxy = ALProxy("ALAnimatedSpeech", robotIP, port)
self.navigationProxy = ALProxy("ALNavigation", robotIP, port)
self.postureProxy = ALProxy("ALRobotPosture", robotIP, port)
self.asr = ALProxy("ALSpeechRecognition", robotIP, port)
self.autonomousMovesProxy = ALProxy("ALAutonomousMoves", robotIP, port)
self.autonomousMovesProxy.setExpressiveListeningEnabled(False)
self.memValue = "WordRecognized"
self.tts = ALProxy("ALTextToSpeech", robotIP, port)
self.tts.setParameter("speed", 100)
#topics
rospy.Subscriber("/nao_behavior/add", String, self.run_callback)
self.statesub = rospy.Subscriber("/joint_states", JointState, self.jointstateC)
rospy.Subscriber("/nao_audio/audio_source_localization", AudioSourceLocalization, self.audio_callback)
self.speechPub = rospy.Publisher('/nao_behavior/speech_detection', Bool, queue_size=5)
#speech ini
rospy.Subscriber("/nao_behavior/head", Float32MultiArray, self.move)
self.breath(True)
def move(self, data):
if self.headlock == True:
return
self.headlock == True
# we want to tilt the body if the position is too far to the endge
if self.enableAutoRotate:
if data.data[0] > 2:
self.rotate(0.1)
elif data.data[0] < -2:
self.rotate(-0.1)
self.headlock == false
return
Id = self.motionProxy.post.setAngles(["HeadYaw", "HeadPitch"], [data.data[0],data.data[1]], data.data[2])
self.motionProxy.wait(Id, 0)
self.headlock == False
def headmove(self, angles,speed):
if self.headlock == True:
return
self.headlock == True
Id = self.motionProxy.post.setAngles(["HeadYaw", "HeadPitch"], angles, speed)
self.motionProxy.wait(Id, 0)
self.headlock == False
def search(self):
prevodom = self.headOdom
self.headmove([-0.8,self.headOdom[1]],0.1)
time.sleep(2)
if self.stop == False :
self.headmove([0.8, self.headOdom[1]],0.1)
time.sleep(2)
#return to original
if self.stop == False:
self.headmove(prevodom,0.1)
self.stop = False
def audio_callback(self,msg):
if self.speechini == False :
self.speechini = True
self.asr.pause(True)
self.vocabulary = ["yes", "no", "please", "hello","the","be","to","of","and","in","that","have","it","robot"]
#.........这里部分代码省略.........
示例9: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import wait [as 别名]
def main():
""" Main entry point
"""
########################FOR FREEZING BOT#######################
global brokyControlly
brokyControlly = BrokerController()
brokyControlly.createBroker()
# Warning: BotFreezer must be a global variable
# The name given to the constructor must be the name of the
# variable
global BotFreezer
BotFreezer = BotFreezerModule("BotFreezer")
global cmModule
cmModule = customMotions("cmModule")
cm = ALProxy("cmModule")
#global FootFreezer
#FootFreezer = FootFreezerModule("FootFreezer")
###################FOR FREEZING BOT############################
stiffnesses = 1.0
motionProxy.setStiffnesses("Body", stiffnesses)
postureProxy.goToPosture("StandInit", 1.0)
time.sleep(1)
motionProxy.setExternalCollisionProtectionEnabled("All", False)
id = cm.post.detectMarkAndMoveTo75Right(80)
cm.wait(id,0)
id = cm.post.moveForwardY(0,-.2)
cm.wait(id,0)
id = cm.post.detectMarkAndMoveTo75(107)
cm.wait(id,0)
id = cm.post.turnRight90()
cm.wait(id,0)
id = cm.post.lookAroundForMark(114)
cm.wait(id,0)
id = cm.post.wave()
cm.wait(id,0)
tts.say("Hello, I am Robbie. I'm a NAO robot. I'm designed and manufactured by the Aldebaan company in France, but all of my present behaviors have been programmed as part of a Senior Software Engineering project. Except for Josh Lee. He didn't do shit")
tts.say("There's very little I can do without the programs that have designed and constructed by the Senior Software Engineering students here at Montana Tech. I'm afraid that programming me is not easy, but these students have been well equiped by their education here at Tech to deal with complex problems.")
id = cm.post.fistBump()
cm.wait(id,0)
id = cm.post.turnRight50()
cm.wait(id,0)
id = cm.post.detectMarkSearch(64, "l")
cm.wait(id,0)
id = cm.post.moveForward(.2)
cm.wait(id,0)
id = cm.post.detectMarkSearchForward(68)
cm.wait(id,0)
id = cm.post.turnAround()
cm.wait(id,0)
#id = cm.post.turnAround()
#cm.wait(id, 0)
#time.sleep(2)
#tts.say("I am turned around")
postureProxy.goToPosture("Sit", 1.0)
#################FOR FREEZING BOT###########################
# end broker to stop
brokyControlly.waitToStop()
示例10: time
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import wait [as 别名]
# At the beginning we wait for some time (5sec here)
sleep(5)
# Wake the robot up
motion.wakeUp()
# Ask the robot to go in stand up posture. The second parameter indicates the speed (btw 0 and 1) of execution
posture.goToPosture("StandInit", 0.8)
# First difficulty say hello while moving the arm
motion_id = hello.run_animation(motion)
tts.say("Hello there")
# Wait for the hello animation to stop
motion.wait(motion_id, 0) # The second argument is the timeout: 0 for wait indefinitely
# Ask the robot to dance for us
taichi.dance(motion)
# The robot might be tired by now
motion_id = wipe.run_animation(motion)
tts.say("This was tyring. Let's rest a little bit")
# Wait for the wipe forehead animation to finish
motion.wait(motion_id, 0)
# Ask the robot to lay down
posture.goToPosture("LyingBack", 0.5)
# Let the robot rest for some time
示例11: ALProxy
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import wait [as 别名]
try:
motion = ALProxy("ALMotion", robotIP, 9559)
except Exception, e:
print "Could notcreate proxy to ALMotion"
print "Error was: ", e
try:
postureProxy = ALProxy("ALRobotPosture", robotIP, 9559)
except Exception, e:
print "Could not create proxy to ALRobotPosture"
print "Error was: ", e
StiffnessOn(motion)
id = postureProxy.goToPosture("StandInit", 0.5)
postureProxy.wait(id, 0)
motion.moveInit()
motion.setAngles(LArm, LArmAngles[0], fractionMaxSpeed)
motion.setAngles(RArm, RArmAngles[0], fractionMaxSpeed)
motion.setAngles(LLeg, LLegAngles[0], fractionMaxSpeed)
id = motion.setAngles(RLeg, RLegAngles[0], fractionMaxSpeed)
time.sleep(1)
i = 0
rand = random.randint(0, len(Combo))
while 1:
motion.setAngles(LArm, LArmAngles[Combo[rand][i]], fractionMaxSpeed)
motion.setAngles(RArm, RArmAngles[Combo[rand][i]], fractionMaxSpeed)
示例12: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import wait [as 别名]
def main(robotIP, PORT=9559):
'''
Example of a whole body multiple effectors control "LArm", "RArm" and "Torso"
Warning: Needs a PoseInit before executing
Whole body balancer must be inactivated at the end of the script
'''
motionProxy = ALProxy("ALMotion", robotIP, PORT)
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
# end initialize proxy, begin go to Stand Init
# Wake up robot
motionProxy.wakeUp()
# Send robot to Stand Init
id = postureProxy.post.goToPosture("Stand", 0.5)
postureProxy.wait(id, 0)
# end go to Stand Init, begin initialize whole body
# Enable Whole Body Balancer
isEnabled = True
motionProxy.wbEnable(isEnabled)
# Legs are constrained fixed
stateName = "Fixed"
supportLeg = "Legs"
motionProxy.wbFootState(stateName, supportLeg)
# Constraint Balance Motion
isEnable = True
supportLeg = "Legs"
motionProxy.wbEnableBalanceConstraint(isEnable, supportLeg)
# end initialize whole body, define arms motions
useSensorValues = False
# ***************************************************************
# effectorList = ["LArm"]
# arm = "LArm"
# axisDirection = 1 # +1 for LArm, -1 for RArm
# frame = motion.FRAME_WORLD
# currentTf = motionProxy.getTransform(arm, frame, useSensorValues)
for i in range(5):
print i
# Arms motion
effectorList = ["LArm"]
arm = "LArm"
axisDirection = 1 # +1 for LArm, -1 for RArm
frame = motion.FRAME_WORLD
pathArm = []
currentTf = motionProxy.getTransform(arm, frame, useSensorValues)
# 1 - arm ready out front
target1Tf = almath.Transform(currentTf)
target1Tf.r1_c4 += 0.05 # x
target1Tf.r2_c4 += 0.00 * axisDirection # y
target1Tf.r3_c4 += 0.00 # z
# 2 - arm back
target2Tf = almath.Transform(currentTf)
target2Tf.r1_c4 += 0.00
target2Tf.r2_c4 += 0.15
target2Tf.r3_c4 += 0.15
# 3 - arm to ball using ball.y
target3Tf = almath.Transform(currentTf)
target3Tf.r1_c4 += 0.05
target3Tf.r2_c4 += 0.00 * axisDirection
target3Tf.r3_c4 += 0.10
pathArm.append(list(target1Tf.toVector()))
pathArm.append(list(target2Tf.toVector()))
pathArm.append(list(target3Tf.toVector()))
pathList = [pathArm]
axisMaskList = [almath.AXIS_MASK_VEL]
coef = 1.5
timesList = [coef * (i + 1) for i in range(len(pathArm))]
# And move!
id = motionProxy.post.transformInterpolations(effectorList, frame, pathArm, axisMaskList, timesList)
motionProxy.wait(id, 0)
# It is necessary to return the robot to the start position so the next target
# positions are not added to the last move position.
# id = postureProxy.post.goToPosture("Stand", 0.75)
# postureProxy.wait(id, 0)
#.........这里部分代码省略.........
示例13: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import wait [as 别名]
class face:
def __init__(self,robotIP):
#pythonModule = myModule("pythonModule")
# Create a proxy to ALFaceDetection
self.faceProxy = ALProxy("ALFaceDetection", robotIP, 9559)
period = 500
self.faceProxy.subscribe("Test_Face", period, 0.0)
self.memValue = "FaceDetected"
# Create a proxy to ALMemory
self.memoryProxy = ALProxy("ALMemory", robotIP, 9559)
self.motionProxy = ALProxy("ALMotion", robotIP, 9559)
self.faces =0
self.motionProxy.setStiffnesses("Head", 1.0)
def getFace(self):#
while True:
time.sleep(0.5)
self.faces = self.memoryProxy.getData(self.memValue, 0)
if (self.faces and len(self.faces ) > 2):
self.run()
def onexit(self):
self.faceProxy.unsubscribe("Test_Face")
def run(self):
val = self.faces
if (val and len(val) > 2):
closestface = [99.0,99.0]
# closestface[0] = 99
# closestface[1] = 99
faceInfoArray = val[1]
try:
# Browse the faceInfoArray to get info on each detected face.
for j in range(len(faceInfoArray) - 1):
try:
faceInfo = faceInfoArray[j]
faceShapeInfo = faceInfo[0]
faceExtraInfo = faceInfo[1]
except:
continue
# print " alpha %.3f - beta %.3f" % (faceShapeInfo[1], faceShapeInfo[2])
x = faceShapeInfo[1]
y = faceShapeInfo[2]
if x < closestface[0]:
closestface[0] =x
closestface[1] = y
self.headmove([closestface[0], closestface[1]])
except Exception as e:
print(e)
def headmove(self,angles):
# Simple command for the HeadYaw joint at 10% max speed
#
print angles[0] , angles[1]
curangles = self.motionProxy.getAngles(["HeadYaw", "HeadPitch"], True)
names = ["HeadYaw", "HeadPitch"]
# print angles[0] , angles[1]
fractionMaxSpeed = 0.1
id =self.motionProxy.post.setAngles(names, angles, fractionMaxSpeed)
self.motionProxy.wait(id, 0)