本文整理汇总了Python中naoqi.ALProxy.waitUntilMoveIsFinished方法的典型用法代码示例。如果您正苦于以下问题:Python ALProxy.waitUntilMoveIsFinished方法的具体用法?Python ALProxy.waitUntilMoveIsFinished怎么用?Python ALProxy.waitUntilMoveIsFinished使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类naoqi.ALProxy
的用法示例。
在下文中一共展示了ALProxy.waitUntilMoveIsFinished方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import waitUntilMoveIsFinished [as 别名]
def main(robotIP, PORT=9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
# Wake up robot
motionProxy.wakeUp()
# Send robot to Stand Init
postureProxy.goToPosture("StandInit", 0.5)
#####################
## Enable arms control by move algorithm
#####################
motionProxy.setMoveArmsEnabled(True, True)
#~ motionProxy.setMoveArmsEnabled(False, False)
#####################
## FOOT CONTACT PROTECTION
#####################
#~ motionProxy.setMotionConfig([["ENABLE_FOOT_CONTACT_PROTECTION",False]])
motionProxy.setMotionConfig([["ENABLE_FOOT_CONTACT_PROTECTION", True]])
#####################
## get robot position before move
#####################
initRobotPosition = m.Pose2D(motionProxy.getRobotPosition(False))
X = 0.0
Y = 0.0
Theta = math.pi/2.0
motionProxy.post.moveTo(X, Y, Theta)
motionProxy.setAngles("HeadYaw", 0.6, 0.6)
# wait is useful because with post moveTo is not blocking function
motionProxy.waitUntilMoveIsFinished()
#####################
## get robot position after move
#####################
endRobotPosition = m.Pose2D(motionProxy.getRobotPosition(False))
#####################
## compute and print the robot motion
#####################
robotMove = m.pose2DInverse(initRobotPosition)*endRobotPosition
# return an angle between ]-PI, PI]
robotMove.theta = m.modulo2PI(robotMove.theta)
print "Robot Move:", robotMove
# Go to rest position
motionProxy.rest()
示例2: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import waitUntilMoveIsFinished [as 别名]
def main(robotIP, PORT=9559):
# tts = ALProxy("ALTextToSpeech", robotIP, PORT)
# tts.post.say("turn right")
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
postureProxy.goToPosture("StandInit", 0.5)
motionProxy = ALProxy("ALMotion", robotIP, PORT)
motionProxy.wakeUp()
motionProxy.setMoveArmsEnabled(True, True)
motionProxy.setMotionConfig([["ENABLE_FOOT_CONTACT_PROTECTION", True]])
motionProxy.post.moveTo(0.2, -0.2, -math.pi / 2.0)
motionProxy.waitUntilMoveIsFinished()
print "Robot Move: right"
示例3: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import waitUntilMoveIsFinished [as 别名]
def main(robotIP, PORT=9559):
# tts = ALProxy("ALTextToSpeech", robotIP, PORT)
# tts.post.say("前进,,前进.")
audiodevice = ALProxy("ALAudioDevice", robotIP, PORT)
currentVoice = audiodevice.getOutputVolume()
audiodevice.setOutputVolume(currentVoice + 10)
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
postureProxy.goToPosture("StandInit", 0.5)
motionProxy = ALProxy("ALMotion", robotIP, PORT)
# Wake up robot
motionProxy.wakeUp()
motionProxy.setMoveArmsEnabled(True, True)
motionProxy.setMotionConfig([["ENABLE_FOOT_CONTACT_PROTECTION", True]])
motionProxy.post.moveTo(0.8, 0, 0)
motionProxy.waitUntilMoveIsFinished()
print "Robot Move forward"
示例4: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import waitUntilMoveIsFinished [as 别名]
def main(robotIP, PORT=9559):
# tts = ALProxy("ALTextToSpeech", robotIP, PORT)
# tts.post.say("我这就退后0.6米.")
# lower the volume by 10%
audioDevice = ALProxy("ALAudioDevice", robotIP, PORT)
currentVoice = audioDevice.getOutputVolume()
audioDevice.setOutputVolume(currentVoice - 10)
# stand first
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
postureProxy.goToPosture("StandInit", 0.5)
motionProxy = ALProxy("ALMotion", robotIP, PORT)
motionProxy.wakeUp()
motionProxy.setMoveArmsEnabled(True, True)
motionProxy.setMotionConfig([["ENABLE_FOOT_CONTACT_PROTECTION", True]])
# action move
motionProxy.post.moveTo(-0.618, 0, 0)
motionProxy.waitUntilMoveIsFinished()
print "Robot Move: back"
示例5: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import waitUntilMoveIsFinished [as 别名]
def main(robotIP, PORT=9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
# Wake up robot
motionProxy.wakeUp()
# Send robot to Pose Init
postureProxy.goToPosture("StandInit", 0.5)
# A small step forwards and anti-clockwise with the left foot
legName = ["LLeg"]
X = 0.04
Y = 0.1
Theta = 0.3
footSteps = [[X, Y, Theta]]
timeList = [0.6]
clearExisting = False
motionProxy.setFootSteps(legName, footSteps, timeList, clearExisting)
time.sleep(1.0)
# A small step forwards and anti-clockwise with the left foot
legName = ["LLeg", "RLeg"]
X = 0.04
Y = 0.1
Theta = 0.3
footSteps = [[X, Y, Theta], [X, -Y, Theta]]
timeList = [0.6, 1.2]
clearExisting = False
motionProxy.setFootSteps(legName, footSteps, timeList, clearExisting)
motionProxy.waitUntilMoveIsFinished()
# Go to rest position
motionProxy.rest()
示例6: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import waitUntilMoveIsFinished [as 别名]
class move_pepper:
def __init__(self,coord,ID):
self.motionProxy = ALProxy("ALMotion",IP,PORT)
self.postureProxy = ALProxy("ALRobotPosture", IP,PORT)
self.move=False
tab_coord=str(coord).split()
self.coord=[float(tab_coord[0]), float(tab_coord[1]), float(tab_coord[2])]
print self.coord
self.tosend = [0,0,0]
self.clock=rospy.Time.now()
self.id_markeur_tete=ID
rospy.Subscriber("/result_position", Marker,self.position_callback)
rospy.Timer(rospy.Duration(TIMER_ALMOTION), self.timer_callback)
def angle_to_turn(self,quaternion):
euler=euler_from_quaternion(quaternion)
to_turn = self.coord[2] - euler[2] # ce quon veut moins ce quon a
if abs(to_turn)<pi: # !!changement de signe a PI dans le repere rviz
print "iiiiif"
print "to turn",to_turn
return to_turn
else:
print "else"
to_turn = pi - abs(self.coord[2]) + pi - abs(euler[2])
print "to turn",to_turn
return to_turn*(-sign(self.coord[2]))
def position_callback(self,data):
print "coucou"
self.tosend = [self.coord[0]-data.pose.position.x,self.coord[1]-data.pose.position.y,0] # repere rviz
quaternion=[data.pose.orientation.x,data.pose.orientation.y,data.pose.orientation.z,data.pose.orientation.w]
self.tosend[2] = self.angle_to_turn(quaternion)
if data.pose.position.z>HAUTEUR_ERREUR and data.text == "detected": # to avoid the bug of bad calibration that makes the robot fly
print "bug calib or not detected "
self.move=False
else:
if (abs(self.tosend[0])>FINESSE or abs(self.tosend[1])>FINESSE or abs(self.tosend[2])>FINESSE ):
self.move=True
print "True"
else:
self.move=False
print "goal reached"
rospy.signal_shutdown(' goal reached ')
def timer_callback(self,data):
print "timer"
if self.move==True :
print self.tosend
print "mooove"
a=self.motionProxy.post.moveTo(self.tosend[0], self.tosend[1], self.tosend[2]) # sens axes repere pepper = sens axes repere rviz ICIIIIIIIIIIIIIIIIIIIIIIII
# wait is useful because with porospy.Time.now()st moveTo is not blocking function
print "pre wait"
self.motionProxy.waitUntilMoveIsFinished()
print "post wait"
示例7:
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import waitUntilMoveIsFinished [as 别名]
print
print
print "-------------------------------------"
print "Desplazamiento directo"
print "-------------------------------------"
pos1 = almath.Pose2D([0, 0, 0])
pos2 = almath.Pose2D([0, 0, 0])
if robot1: locationProxy1.learnHome()
if robot2: locationProxy2.learnHome()
if robot1: pos1 = almath.Pose2D(locationProxy1.getRobotPosition(False))
if robot2: pos2 = almath.Pose2D(locationProxy2.getRobotPosition(False))
if robot1:
motionProxy1.moveTo(0.3-pos1.x, 0.5-pos1.y, 0)
motionProxy1.waitUntilMoveIsFinished()
pos1 = almath.Pose2D(locationProxy1.getRobotPosition(False))
print "1:Caja", pos1
motionProxy1.moveTo(1.0-pos1.x, 1.0-pos1.y, 0)
motionProxy1.waitUntilMoveIsFinished()
pos1 = almath.Pose2D(locationProxy1.getRobotPosition(False))
print "1:Contenedor", pos1
motionProxy1.moveTo(0.5-pos1.x, 1.0-pos1.y, 0)
motionProxy1.waitUntilMoveIsFinished()
pos1 = almath.Pose2D(locationProxy1.getRobotPosition(False))
print "1:Caja", pos1
if robot2:
motionProxy2.moveTo(0.3-pos2.x, 0.5-pos2.y, 0)
motionProxy2.waitUntilMoveIsFinished()
pos2 = almath.Pose2D(locationProxy2.getRobotPosition(False))
print "2:Caja", pos2
示例8: NaoMove
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import waitUntilMoveIsFinished [as 别名]
class NaoMove():
# Class used to make all movements to Nao
def __init__(self, parent):
#Constructor
self.motionProxy = None
self.postureProxy = None
self.tts = None
self.memoryProxy = None
self.behaviourProxy = None
self.motorOn = False
self.parent = parent
self.memValue = ["FaceDetected"]
self.headNames = ["HeadYaw", "HeadPitch"]
self.leftArmNames = ["LShoulderRoll","LShoulderPitch","LElbowRoll","LElbowYaw"]
self.rightArmNames = ["RShoulderRoll","RShoulderPitch","RElbowRoll","RElbowYaw"]
def connect(self, robotIP, port):
try:
self.motionProxy = ALProxy("ALMotion", robotIP , port)
self.tts = ALProxy("ALTextToSpeech", robotIP, port)
self.postureProxy = ALProxy("ALRobotPosture", robotIP, port)
self.memoryProxy = ALProxy("ALMemory", robotIP, port)
self.behaviourProxy = ALProxy("ALBehaviorManager", robotIP, port)
except:
return 1
# If connection is successful, we initialize few variables for Arms
self.anglesRight = self.motionProxy.getAngles(self.rightArmNames, True)
self.anglesLeft = self.motionProxy.getAngles(self.leftArmNames, True)
return 0
def walk(self,x,y,theta,frequency):
# Test if the stiffness of Nao is set to 1.0
self.testMotorOn()
# Launch the walk
self.motionProxy.setWalkTargetVelocity(x, y, theta, frequency)
def stopWalk(self, frequency):
self.motionProxy.setWalkTargetVelocity(0.0, 0.0, 0.0, frequency)
self.motionProxy.waitUntilMoveIsFinished()
def stop(self):
self.motionProxy.killMove()
def standInit(self):
self.postureProxy.goToPosture("StandInit", constante.FREQUENCY)
def crouch(self):
self.postureProxy.goToPosture("Crouch", constante.FREQUENCY)
def runHello(self):
self.testMotorOn()
self.behaviourProxy.runBehavior("helloBoy")
def openHand(self, hand):
if hand == constante.RIGHT_HAND:
self.motionProxy.openHand('RHand')
else:
self.motionProxy.openHand('LHand')
def closeHand(self, hand):
if hand == constante.RIGHT_HAND:
self.motionProxy.closeHand('RHand')
else:
self.motionProxy.closeHand('LHand')
def moveHead(self, angles):
# Test if the stiffness of Nao is set to 1.0
self.testMotorOn()
current = self.motionProxy.getAngles(self.headNames, True)
# this boucle is used to dynamically calculate the speed of the movement
for i in range(len(angles)):
speed = abs(angles[i]-current[i])/2.0
if speed < 0.05:
speed = 0.05
if speed > 0.8:
speed = 0.8
# Make the movement
self.motionProxy.setAngles(self.headNames[i], angles[i], speed)
def detectFace(self):
# Check that it is not already running.
if (not self.behaviourProxy.isBehaviorRunning("faceDetect")):
# Launch behavior. This is a blocking call, use post if you do not
# want to wait for the behavior to finish.
self.behaviourProxy.post.runBehavior("faceDetect")
def naoMoveTwoArms(self, listPos):
# Test if the stiffness of Nao is set to 1.0
#.........这里部分代码省略.........
示例9: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import waitUntilMoveIsFinished [as 别名]
#.........这里部分代码省略.........
# take a picture
def __takePicture(self):
# for debug
print "takePicture"
naoImage = self.camProxy.getImageRemote(self.videoClient)
width = naoImage[0]; height = naoImage[1]
nchanels = naoImage[2]; array = naoImage[6]
return self.__str2array(array, (height, width, nchanels))
def __str2array(self, string, shape):
assert len(string) == shape[0] * shape[1] * shape[2], len(shape) == 3
image = numpy.zeros(shape, numpy.uint8)
for i in range(0, shape[0]):
p1 = i * shape[1] * shape[2]
for j in range(0, shape[1]):
p2 = j * shape[2]
for c in range(0, shape[2]):
p3 = shape[2] - c - 1
image[i, j, c] = ord(string[p1 + p2 + p3])
return image
# turn left or turn right
# 原地转圈
def turn(self, rad):
# for debug
print 'turning radius %f. ' %(rad)
self.motionProxy.moveTo(0.0, 0.0, rad)
# blocking
self.motionProxy.waitUntilMoveIsFinished()
self.__position_grid[2] = (self.__position_grid[2] + rad) % numpy.pi
# (x, y, rad)
def getPosition(self):
return tuple(self.__position_grid)
# robot moves to a certain grid
def walkToPosition(self, new_position):
# for debug
print 'walk. '
# x changes
if new_position[0] != self.__position_grid[0]:
if new_position[1] != self.__position_grid[1]:
raise Exception('wrong target position. ')
# make sure x changes and y does not
dist = abs(new_position[0] - self.__position_grid[0]) * 0.05
if new_position[0] > self.__position_grid[0]:
if self.__position_grid[2] == 0:
# wont turn
pass
elif self.__position_grid[2] == numpy.pi / 2:
# right turn pi / 2
self.turn(- numpy.pi / 2)
elif self.__position_grid[2] == numpy.pi:
self.turn(- numpy.pi)
elif self.__position_grid[2] == numpy.pi * 3 / 2:
self.turn(numpy.pi / 2)
else:
raise ValueError
else:
示例10: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import waitUntilMoveIsFinished [as 别名]
#.........这里部分代码省略.........
valence_index = int(valence * 5) + 5
arousal_index = 10 - (int(arousal * 5) + 5)
# Eyes.
hex_eye_colour = eye_colour_lookup_table[arousal_index][valence_index]
eye_duration = 0.1
# Motion.
# Head pitch - inversely proportional to arousal.
# Head pitch has a range of approx +0.5 to -0.5 radians so divide normalised arousal value by 2.
head_pitch = arousal / 2 * -1
motion_names.append("HeadPitch")
motion_times.append([0.5, 2, 4])
motion_keys.append([0.0, head_pitch, 0.0])
# Stance (torso position + arms) - directly proportional to valence
# Shoulders have a pitch of +2 to -2 radians.
# Used in absolute mode, central pitch value is 1.4 radians.
shoulder_pitch = 1.4 - valence * 0.5
motion_names.append("LShoulderPitch")
motion_times.append([0.5, 2, 4])
motion_keys.append([1.45726, shoulder_pitch, 1.45726])
motion_names.append("RShoulderPitch")
motion_times.append([0.5, 2, 4])
motion_keys.append([1.4, shoulder_pitch, 1.4])
shoulder_roll = valence * 0.8
motion_names.append("LShoulderRoll")
motion_times.append([0.5, 2, 4])
motion_keys.append([0.5, -shoulder_roll, 0.3])
motion_names.append("RShoulderRoll")
motion_times.append([0.5, 2, 4])
motion_keys.append([-0.5, shoulder_roll, -0.3])
# Ankles have a pitch of approx +0.9 to -1.1radians.
# Used in absolute mode, central pitch value is 0.08 radians.
# ankle_pitch = 0.08 - valence * 0.05
#
# motion_names.append("LAnklePitch")
# motion_times.append([0.5, 2, 4])
# motion_keys.append([0.08, ankle_pitch, 0.08])
#
# motion_names.append("RAnklePitch")
# motion_times.append([0.5, 2, 4])
# motion_keys.append([0.08, ankle_pitch, 0.08])
# OUTPUTS
# Speech.
# self.tts.post.say(string_to_say)
# Eyes.
self.leds.fadeRGB("FaceLeds", hex_eye_colour, eye_duration)
# self.leds.reset("FaceLeds")
# Motion.
if self.state_activity == "WAITING_FOR_FEEDBACK" and self.do_it_once == True:
# self.posture.goToPosture("StandInit", 0.3)
self.motion.angleInterpolation(motion_names, motion_keys, motion_times, True)
self.motion.waitUntilMoveIsFinished()
# self.posture.goToPosture("StandInit", 0.3)
self.do_it_once = False
if self.activity != "drawing_nao":
# Speech.
# The pitch and volume modifier values need scaled, final value to be determined. e.g. a value of 4 will divide the parameter by 4 to give a +/- of 25% of the default value
speech_parameter_scaling_value = 4
string_to_say = "I am feeling " + emotion_name
scaled_pitch_modifier = 1 + (
speech_parameter_lookup_table[arousal_index][valence_index][0] / speech_parameter_scaling_value
)
# NAO can only increase pitch! So need to check if a pitch reduction required and negate it. Range 1.0 - 4.0.
if scaled_pitch_modifier < 1.0:
scaled_pitch_modifier = 1.0
# NAO volume (gain) range 0.0 - 1.0.
scaled_volume_modifier = 0.5 + (
speech_parameter_lookup_table[arousal_index][valence_index][1] / speech_parameter_scaling_value
)
# self.tts.setParameter("pitchShift", scaled_pitch_modifier)
# self.tts.setVolume(scaled_volume_modifier)
# Reset speech parameters to nominal.
# self.tts.setParameter("pitchShift", 0)
# self.tts.setVolume(0.5)
def current_state_callback(self, data):
self.state_activity = data.data
self.do_it_once = True
def activity_callback(self, data):
self.activity = data.data
def stop_request_callback(self, data):
self.motion.rest()
self.leds.reset("FaceLeds")
rospy.signal_shutdown("Interaction exited")
示例11: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import waitUntilMoveIsFinished [as 别名]
#.........这里部分代码省略.........
"""
quaternion_robot_map=[data.pose.pose.orientation.x,data.pose.pose.orientation.y,data.pose.pose.orientation.z,data.pose.pose.orientation.w]
euler = euler_from_quaternion(quaternion_robot_map)
angle_goal =self.angle_goal_to_map(position,euler) # on obtient l'angle relatif entre le robot et le goal
# translater jusqua la position : on traduit langle relatif en coord x,y relatives
# quelle est la distance entre le robot et le goal?
dist_rel = sqrt( pow(self.coord[0]-data.pose.pose.position.x,2) + pow(self.coord[1]-data.pose.pose.position.y,2) )
print "dist_rel= " , dist_rel
print "cos(angle_goal)",cos(angle_goal)
print "sin(angle_goal)",sin(angle_goal)
rel_x=cos(angle_goal)*dist_rel
rel_y=sin(angle_goal)*dist_rel
print "rel_x",rel_x
print "rel_y",rel_y
"""
self.tosend = [trans[0],trans[1],0]
if data.pose.pose.position.z>HAUTEUR_ERREUR : # to avoid the bug of bad calibration that makes the robot fly
print "bug calib or not detected "
self.move=False
#self.command_head=[yawtosend,pitchtosend] # TODO
else:
#self.command_head=[yawtosend,pitchtosend]
if (abs(self.tosend[0])>FINESSE or abs(self.tosend[1])>FINESSE or abs(self.tosend[2])>FINESSE ):
self.move=True
print "True"
else:
self.move=False
self.motionProxy.waitUntilMoveIsFinished()
print "goal reached"
rospy.signal_shutdown(' goal reached ')
"""
def position_callback(self,data):
print "callback"
quaternion=[data.pose.pose.orientation.x,data.pose.pose.orientation.y,data.pose.pose.orientation.z,data.pose.pose.orientation.w]
euler=euler_from_quaternion(quaternion)
if abs(euler[2])>1.57: # on doit savoir dans quel sens il est pou savoir si il avance ou recule..?
sens=FRONT
print "FRONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNT"
else:
sens=BACK
if len(self.coord) == 1:
self.tosend = [0,0,self.angle_to_turn(quaternion)]
elif len(self.coord) == 2:
self.tosend = [(self.coord[0]-data.pose.pose.position.x)*sens,(self.coord[1]-data.pose.pose.position.y)*sens,0]
elif len(self.coord) == 3:
self.tosend = [(self.coord[0]-data.pose.pose.position.x)*sens,(self.coord[1]-data.pose.pose.position.y)*sens,self.angle_to_turn(quaternion)]
#--- gestion de l inclinaison de la tete
(trans,rot) = self.listener.lookupTransform("map", "axis_camera", rospy.Time(0))
示例12: StiffnessOn
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import waitUntilMoveIsFinished [as 别名]
from naoqi import ALProxy
def StiffnessOn(proxy):
# We use the "Body" name to signify the collection of all joints
pNames = "Body"
pStiffnessLists = 1.0
pTimeLists = 1.0
proxy.stiffnessInterpolation(pNames, pStiffnessLists, pTimeLists)
def StiffnessOff(proxy):
# We use the "Body" name to signify the collection of all joints
pNames = "Body"
pStiffnessLists = 0.0
pTimeLists = 1.0
proxy.stiffnessInterpolation(pNames, pStiffnessLists, pTimeLists)
motion = ALProxy("ALMotion", "nao.local", 9559)
tts = ALProxy("ALTextToSpeech", "nao.local", 9559)
postureProxy = ALProxy("ALRobotPosture", "nao.local", 9559)
StiffnessOn(motion)
postureProxy.goToPosture("StandInit", 0.5)
motion.moveInit()
motion.post.moveTo(0.5, 0, 0)
tts.post.say("Hello, I am Nao and I'm walking. How are you today?")
motion.waitUntilMoveIsFinished()
postureProxy.goToPosture("LyingBack", 0.5)
StiffnessOff(motion)